├── .DS_Store ├── Colab_Codes ├── Advanced_Search_on_Linear_Data_Structures.ipynb ├── Colab Notebooks │ ├── chapter_14_sorting.ipynb │ ├── chapter_14_sorting_2.ipynb │ ├── chapter_15_bit_manipulation.ipynb │ ├── chapter_6_linear_data_structure.depre.ipynb │ ├── chapter_6_linear_data_structure.ipynb │ ├── chapter_8_heap_priority_queue.ipynb │ ├── graph_data_structure.ipynb │ ├── graph_search.ipynb │ ├── graph_search_application.ipynb │ ├── linear_search_two_pointer.ipynb │ ├── suffix_array.ipynb │ ├── tree_data_structure.ipynb │ └── tree_search.ipynb ├── chapter_combinatorial_search.ipynb ├── chapter_decrease_and_conquer.ipynb ├── chapter_python_comparison_sorting.ipynb ├── chapter_python_datastrcutures.ipynb ├── chapter_search_strategies.ipynb ├── chapter_sorting_and_selection_algorithms.ipynb └── chapter_tree_data_structure_and_traversal.ipynb ├── Easy-Book ├── IEEEbib.bst ├── chapters │ ├── chapter_10_non_linear_backtracking.tex │ ├── chapter_12_dynamicprogramming.tex │ ├── chapter_12_tree_algorithm.tex │ ├── chapter_13_greedy_algo.tex │ ├── chapter_13_tree_algorithm.tex │ ├── chapter_13_tree_traversal.tex │ ├── chapter_14_sorting.tex │ ├── chapter_15_bit-manipulation.tex │ ├── chapter_16_math.tex │ ├── chapter_1_introductionCodingInterview.tex │ ├── chapter_2_introduction_algo.tex │ ├── chapter_3_iteration_recursion.tex │ ├── chapter_5_algorithm_analysis.tex │ ├── chapter_7_graph_implementation.tex │ ├── chapter_8_heap_priority_queue.tex │ ├── chapter_abstract_data_strctures.tex │ ├── chapter_advanced_data_structures.tex │ ├── chapter_advanced_graph_algorithm.pdf │ ├── chapter_advanced_graph_algorithm.synctex.gz │ ├── chapter_advanced_graph_algorithm.tex │ ├── chapter_advanced_linear_search.tex │ ├── chapter_code_data_structure.tex │ ├── chapter_combinatorial_search.tex │ ├── chapter_combinatorial_search_old.tex │ ├── chapter_combinatorics.pdf │ ├── chapter_combinatorics.synctex.gz │ ├── chapter_combinatorics.tex │ ├── chapter_decrease_and_conquer.tex │ ├── chapter_hands_on_problem_solving.tex │ ├── chapter_heuristic_search.tex │ ├── chapter_introduction_to_python.tex │ ├── chapter_non_linear_iterative_search.tex │ ├── chapter_reading_of_this_book.tex │ ├── chapter_recurrence_relation.tex │ ├── chapter_reduce_and_conquer.tex │ ├── chapter_search_strategies_back_up.tex │ ├── chapter_searching_strategies.pdf │ ├── chapter_searching_strategies.synctex.gz │ ├── chapter_searching_strategies.tex │ ├── delete │ │ ├── algorithms.tex.prec │ │ ├── basic_algorithm.tex.prec │ │ ├── data-structure.tex.prec │ │ ├── divide-conquer_deprecated.tex │ │ ├── math_bit_manipulation.tex.prec │ │ ├── problems.tex.depre │ │ ├── special_topic.tex.depre │ │ └── string_trie_tree_array.tex.prec │ ├── mastering │ │ ├── array │ │ │ ├── interval.tex │ │ │ ├── subsequence.tex │ │ │ ├── subset.tex │ │ │ └── sweep_line.tex │ │ ├── array_string.tex │ │ ├── divide_conquer_questions.tex │ │ ├── learning │ │ │ ├── search │ │ │ │ ├── binary_search.tex │ │ │ │ └── sliding_window.tex │ │ │ └── tree_data_structure.tex │ │ └── two-pointer.tex.prec │ ├── other_complete_search.tex │ ├── part3_deprc │ │ ├── example.tex │ │ └── introduction.tex │ ├── part_complete_search_introduction.tex │ ├── preface.pdf │ ├── preface.synctex.gz │ ├── preface.tex │ ├── purged.tex │ ├── question_1_dynamic_programming.tex │ ├── question_2_string_matching.tex │ ├── question_3_array_question.tex │ ├── question_4_linked_list_question.tex │ ├── question_5_pattern-matching.tex │ ├── question_6_algorithms_for_tree.tex │ ├── question_7_specific_algorithms_for_graph.tex │ ├── reading_of_this_book.tex │ └── solutions.tex ├── fig │ ├── 250px-Sudoku-by-L2G-20050714.png │ ├── 250px-Sudoku-by-L2G-20050714_solution.png │ ├── 307_RSQ_SegmentTree.png │ ├── 542px-Graph_theory_tree.png │ ├── 542px-Graph_theory_tree.svg.png │ ├── 621_Task_Scheduler_new.png │ ├── 8-queens.png │ ├── 956-ep234.png │ ├── 956_dp_table.png │ ├── Binary_Search_Depiction.png │ ├── Binary_search_tree.png │ ├── Bipartite-Graph-Example.png │ ├── BipartiteGraph_1000.gif │ ├── BipartiteGraph_1000.png │ ├── DLL1.png │ ├── DP_shortest_paths (1).png │ ├── DP_shortest_paths (2).png │ ├── DP_shortest_paths (3).png │ ├── DP_shortest_paths.png │ ├── Euler12-300x225.png │ ├── InsertionSort.png │ ├── LIS.png │ ├── LIS_tree.png │ ├── SCCUndirected.png │ ├── Sketch001.tif │ ├── Sliding_window_property.png │ ├── Subproblem_graph.png │ ├── TQoyH.png │ ├── Trie.png │ ├── activation_records.jpg │ ├── activation_records.png │ ├── all_path_demo.png │ ├── all_paths.png │ ├── all_paths_demo.png │ ├── array_representation.png │ ├── array_sorting_algorithms.png │ ├── back_tree_possibility.png │ ├── bellman-ford-D (2).png │ ├── bellman-ford-D.png │ ├── bellman_ford_0.png │ ├── bellman_ford_0_dag.png │ ├── bellman_ford_0_tp.png │ ├── bellman_ford_1.png │ ├── bellman_ford_1_dag.png │ ├── bellman_ford_1_tp.png │ ├── bellman_ford_2.png │ ├── bellman_ford_3.png │ ├── bellman_ford_4.png │ ├── bfs_example_1.png │ ├── bfs_free_tree.png │ ├── bfs_shortest_dis.png │ ├── bfs_vis.png │ ├── bidrectional_search.png │ ├── big_o_complexity_chart.png │ ├── binary_search_lower_bound.png │ ├── binary_search_lower_upper.png │ ├── binary_search_upper_bound.png │ ├── binary_tree.png │ ├── binary_tree1.png │ ├── binary_tree_example.png │ ├── branch_and_bound_backtracking.png │ ├── branch_and_bound_best_first.png │ ├── breath_first_graph_search_process0.png │ ├── breath_first_graph_search_process1.png │ ├── breath_first_graph_search_process10.png │ ├── breath_first_graph_search_process11.png │ ├── breath_first_graph_search_process2.png │ ├── breath_first_graph_search_process3.png │ ├── breath_first_graph_search_process4.png │ ├── breath_first_graph_search_process5.png │ ├── breath_first_graph_search_process6.png │ ├── breath_first_graph_search_process7.png │ ├── breath_first_graph_search_process8.png │ ├── breath_first_graph_search_process9.png │ ├── breath_first_graph_search_tree.png │ ├── brute_force_matching.png │ ├── bst_duplicate.png │ ├── bst_duplicate_counter.png │ ├── bst_example.png │ ├── bst_insert_9.png │ ├── bst_insertion.png │ ├── bstdlloriginalbst.png │ ├── bstdllreturndll.png │ ├── bubble_sort.png │ ├── bubblepass.png │ ├── bucket_sort.png │ ├── category_tag.png │ ├── cc_directed.png │ ├── cc_undirected.png │ ├── chapter_advanced_graph │ │ ├── DP_shortest_paths (3).png │ │ ├── directed_cyclic_graph.png │ │ ├── scc.png │ │ ├── ts_1.png │ │ ├── ts_2.png │ │ └── undirected_cyclic_graph.png │ ├── circular_linked_list.png │ ├── circularlinkedlist.png │ ├── climbing_stair.png │ ├── combination.png │ ├── combination_rslt.png │ ├── common_data_structure_operations.png │ ├── complexity_cheatsheet.png │ ├── component_graph_vs_dfs_tree.png │ ├── counting_sort.png │ ├── counting_sort_1.png │ ├── cycle_detect.png │ ├── cyclic_graph_searching.png │ ├── cyclic_shift.png │ ├── data_structures.png │ ├── deep_copy_1.png │ ├── deep_copy_2.png │ ├── deep_copy_3.png │ ├── deep_copy_4.png │ ├── deep_copy_5.png │ ├── depth_first_graph_search_edges(1).png │ ├── depth_first_graph_search_edges.png │ ├── depth_first_graph_search_process0.png │ ├── depth_first_graph_search_process1.png │ ├── depth_first_graph_search_process10.png │ ├── depth_first_graph_search_process11.png │ ├── depth_first_graph_search_process2.png │ ├── depth_first_graph_search_process3.png │ ├── depth_first_graph_search_process4.png │ ├── depth_first_graph_search_process5.png │ ├── depth_first_graph_search_process6.png │ ├── depth_first_graph_search_process7.png │ ├── depth_first_graph_search_process8.png │ ├── depth_first_graph_search_process9.png │ ├── depth_first_graph_search_tree.png │ ├── depth_first_tree_search.png │ ├── dfs_bfs.png │ ├── dfs_procedure.png │ ├── diagram.png │ ├── dijkstra_0.5.png │ ├── dijkstra_0.png │ ├── dijkstra_1.5.png │ ├── dijkstra_1.png │ ├── dijkstra_2.5.png │ ├── dijkstra_2.png │ ├── dijkstra_3.5.png │ ├── dijkstra_3.png │ ├── dijkstra_4.5.png │ ├── dijkstra_4.png │ ├── dijkstra_process.png │ ├── dijkstra_proof.png │ ├── directed_cyclic_graph.png │ ├── directed_cyclic_graph_2.png │ ├── directed_graph_negative.png │ ├── directed_scc_example.png │ ├── disjoint_set.png │ ├── divide_conquer.png │ ├── divide_dynamic.png │ ├── dp_decision_table.png │ ├── dynamic_programming_chapter.png │ ├── eight_bit_two_complement.png │ ├── example_863.png │ ├── example_graph.png │ ├── example_undirected_directed_graph.png │ ├── fibanacci.png │ ├── fibonacci_bfs.png │ ├── firstsplit.png │ ├── floyd.png │ ├── floyd_warshall_proof.png │ ├── four_umbreallas.png │ ├── free_tree.png │ ├── free_tree_search.png │ ├── full_complete_perfect_binary_tree.png │ ├── general_breath_first_search.png │ ├── general_depth_first_search.png │ ├── graph_1.png │ ├── graph_cut.png │ ├── graph_representation.png │ ├── greedy_leetcode_diff.png │ ├── greedy_schedule_all_intervals_1.png │ ├── greedy_schedule_all_intervals__sort_count.png │ ├── greedy_schedule_all_intervals_good_sort.png │ ├── greedy_schedule_all_intervals_sorting.png │ ├── greedy_schedule_all_intervals_sorting_finish.png │ ├── greedy_schedule_all_intervals_wrong_sort.png │ ├── guesswinner.png │ ├── hash_table_1.png │ ├── hash_table_2.png │ ├── hashtable_chaining.png │ ├── heapify.png │ ├── histogram.png │ ├── insertcyclicafter.png │ ├── insertcyclicbefore.png │ ├── insertion sort.png │ ├── insertion_sort.png │ ├── iteration_recursion.png │ ├── iterative_tree_traversal.png │ ├── iterative_tree_traversal_postorder.png │ ├── iterative_tree_traversal_preorder.png │ ├── kmp.png │ ├── kmp_lemma_proof.png │ ├── knight_dialer.png │ ├── kosaraju_sccs.png │ ├── lcs.png │ ├── lcs_problem.png │ ├── leetcode_discussion.png │ ├── linked_list1.png │ ├── lookup.jpg │ ├── lookup_table.jpg │ ├── lsd_radix_integer_sort.png │ ├── ltlp1.png │ ├── lumo_parition.png │ ├── maximum_depth.png │ ├── maxprofit_consecutive.png │ ├── maxprofit_peak.png │ ├── merge2.gif │ ├── merge2.png │ ├── merge_sort.png │ ├── mergesortA.png │ ├── mergesortB.png │ ├── mhz_640.jpg │ ├── middle node of a given linked list.png │ ├── middle_of_linked_list.png │ ├── min_climbing.png │ ├── min_heap_heapify_1.png │ ├── min_heap_heapify_2.png │ ├── min_heap_heapify_3.png │ ├── min_heap_heapify_4.png │ ├── min_heap_heapify_5.png │ ├── min_heap_heapify_6.png │ ├── min_heap_heapify_7.png │ ├── min_heap_insert.png │ ├── min_heap_insert_step1.png │ ├── min_heap_push.bmp │ ├── min_heap_push.png │ ├── min_path.png │ ├── minimum_window_substring.png │ ├── minimum_window_substring_process.png │ ├── monotone_stack_fig.png │ ├── msd_radix_string_sort.png │ ├── mst_example.png │ ├── mst_kruskal.png │ ├── mst_prim_1.png │ ├── mst_prim_2.png │ ├── n-ary_binary_tree.png │ ├── n_queen_diag.png │ ├── n_queen_four.png │ ├── n_queen_oddPicture1.png │ ├── n_queen_symmetry.png │ ├── naive_graph.png │ ├── notations.png │ ├── palindromPartition.png │ ├── partitionA.png │ ├── path_cycle.png │ ├── permutation.png │ ├── permutation_repeat.png │ ├── permutation_rslt.png │ ├── permutation_swap.png │ ├── prefixsum.png │ ├── preorder_traverse.png │ ├── problem_formulation_1.png │ ├── problem_formulation_1_1.png │ ├── problem_formulation_2.png │ ├── problem_formulation_3.png │ ├── problem_formulation_4.png │ ├── quicksort.png │ ├── recursion_tree_non_overlap.png │ ├── recursive_tree_1.png │ ├── recursive_tree_2.png │ ├── rotated_array.png │ ├── search_tree_dfs.png │ ├── searchsp.png │ ├── segment_tree_construction.png │ ├── segment_tree_range.png │ ├── selectionSort.png │ ├── selection_sort.png │ ├── shifing_pattern.png │ ├── shortest_path_demo (1).png │ ├── shortest_path_demo.png │ ├── shortest_path_dp_1.png │ ├── shortest_path_property_1.png │ ├── shortest_path_trees_0.png │ ├── shortest_path_trees_1.png │ ├── shortest_path_trees_2.png │ ├── shortest_path_trees_3.png │ ├── shortest_path_trees_4.png │ ├── skipping_rule_kmp.png │ ├── sliding1.png │ ├── stack_queue.gif │ ├── stack_queue_1.png │ ├── subproblem_graph_merge_sort.png │ ├── subsequence.png │ ├── subsequence_1.png │ ├── subsequence_2.png │ ├── sudoku_backtracking.png │ ├── sudoku_grid.png │ ├── summary_dp.png │ ├── sweep_line_253.png │ ├── sweep_line_min_heap.png │ ├── sweep_line_one_dimension.png │ ├── test_case_leetcode.png │ ├── time_complexity_sorting.png │ ├── topo_sort.png │ ├── topo_sort_1.png │ ├── tree traversal.png │ ├── tree_graph_1.png │ ├── tree_property.png │ ├── tree_traversal.png │ ├── tree_word_break.png │ ├── trie_compact_trie.jpg │ ├── trie_pattern.png │ ├── tsp_graph.png │ ├── two_pointers.png │ ├── ucs.png │ ├── undirected_cc_example.png │ ├── undirected_cyclic_graph.png │ ├── unique_path.png │ ├── word_break_139.png │ └── z_function.png ├── main.pdf ├── main.synctex.gz ├── main.tex ├── main_copy.tex ├── problem-catalog.tex ├── proposal.tex ├── proposal_leetcode.tex ├── purged.tex ├── refer.bib ├── sample.tex └── source-code │ ├── chapter_advanced_graph_search.ipynb │ ├── chapter_search_strategies.ipynb │ └── chapter_search_strategy_plot.ipynb ├── LICENSE ├── README.md ├── chapters_md └── discrete_programming.md ├── chapters_pdf ├── Abstract_Data_Structures.pdf ├── Python_Data_Structure.pdf ├── advanced_search_on_linear_data_structures.pdf ├── chapter_advanced_graph_algorithm.pdf ├── combinatorial_search.pdf ├── decrease_and_conquer.pdf ├── search_strategies.pdf └── sorting_algorithms_with_python3.pdf ├── figures └── book_structure.png ├── how_to_contribute.md └── unorganized_pdf ├── backtracking.pdf ├── binary_search.pdf ├── bit manipulation.pdf ├── heap_priority_queue.pdf ├── linear_data_structure.pdf ├── tree_questions.pdf ├── two_pointer.pdf └── workspace.code-workspace /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/.DS_Store -------------------------------------------------------------------------------- /Colab_Codes/Colab Notebooks/chapter_14_sorting_2.ipynb: -------------------------------------------------------------------------------- 1 | {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"chapter_14_sorting.ipynb","version":"0.3.2","provenance":[]},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"metadata":{"id":"B0qx9rvaser4","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":34},"outputId":"7c9daf13-4598-4e08-bc63-f6ab19c419da","executionInfo":{"status":"ok","timestamp":1549672814254,"user_tz":480,"elapsed":610,"user":{"displayName":"Li Yin","photoUrl":"https://lh5.googleusercontent.com/-KgiTKdqPRUg/AAAAAAAAAAI/AAAAAAAAAIE/aHQ6xO5vQpY/s64/photo.jpg","userId":"13365523799853678553"}}},"cell_type":"code","source":["tup = (3, 6, 8, 2, 78, 1, 23, 45, 9)\n","sorted(tup)"],"execution_count":1,"outputs":[{"output_type":"execute_result","data":{"text/plain":["[1, 2, 3, 6, 8, 9, 23, 45, 78]"]},"metadata":{"tags":[]},"execution_count":1}]},{"metadata":{"id":"eA8dMPkksqly","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":71},"outputId":"613cc186-cd57-4439-9f7f-6b122cd3d85b","executionInfo":{"status":"ok","timestamp":1549673318708,"user_tz":480,"elapsed":276,"user":{"displayName":"Li Yin","photoUrl":"https://lh5.googleusercontent.com/-KgiTKdqPRUg/AAAAAAAAAAI/AAAAAAAAAIE/aHQ6xO5vQpY/s64/photo.jpg","userId":"13365523799853678553"}}},"cell_type":"code","source":["from collections import defaultdict\n","import random\n","dic = defaultdict(lambda: defaultdict(list)) # a dictionary of a dictionary of list dic[a][b] = [3, 1, 2, 4]\n","for i in range(10):\n"," a = random.randint(1, 101)\n"," b = random.randint(1, 101)\n"," dic[a][b] = [random.randint(1, 101) for _ in range(10)]\n","print(dic) \n","sorted_dic = sorted(dic)\n","print(sorted_dic)"],"execution_count":8,"outputs":[{"output_type":"stream","text":["defaultdict( at 0x7faf20e3c730>, {72: defaultdict(, {59: [63, 15, 62, 83, 30, 98, 16, 44, 58, 93]}), 82: defaultdict(, {70: [89, 49, 47, 63, 90, 1, 7, 9, 78, 10]}), 53: defaultdict(, {62: [10, 99, 35, 78, 74, 44, 82, 32, 32, 52]}), 78: defaultdict(, {78: [20, 22, 100, 29, 16, 65, 56, 8, 100, 100]}), 13: defaultdict(, {44: [4, 81, 17, 92, 44, 49, 72, 24, 13, 64]}), 84: defaultdict(, {47: [76, 94, 36, 56, 60, 87, 72, 47, 75, 33]}), 49: defaultdict(, {97: [7, 47, 13, 80, 85, 59, 2, 48, 68, 65]}), 87: defaultdict(, {61: [31, 72, 71, 63, 19, 84, 78, 80, 97, 85]}), 17: defaultdict(, {92: [29, 53, 20, 14, 16, 84, 57, 40, 4, 19]}), 54: defaultdict(, {32: [2, 31, 19, 31, 68, 10, 85, 34, 25, 62]})})\n","[13, 17, 49, 53, 54, 72, 78, 82, 84, 87]\n"],"name":"stdout"}]},{"metadata":{"id":"VbmDX6yAvYax","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":34},"outputId":"441aa86e-17c6-4cbd-b923-67c1ea41e384","executionInfo":{"status":"ok","timestamp":1549674562513,"user_tz":480,"elapsed":273,"user":{"displayName":"Li Yin","photoUrl":"https://lh5.googleusercontent.com/-KgiTKdqPRUg/AAAAAAAAAAI/AAAAAAAAAIE/aHQ6xO5vQpY/s64/photo.jpg","userId":"13365523799853678553"}}},"cell_type":"code","source":["'''sort_list_of_tuple()'''\n","\n","lst = [(1, 8, 2), (3, 2, 9), (1, 7, 10), (1, 7, 1), (11, 1, 5), (6, 3, 10), (32, 18, 9)]\n","sorted_lst = sorted(lst, key = lambda x: x[0]) # sort in the order of the first element, and descresing order of the second element, and incresing of the third element\n","print(sorted_lst)"],"execution_count":16,"outputs":[{"output_type":"stream","text":["[(1, 8, 2), (1, 7, 10), (1, 7, 1), (3, 2, 9), (6, 3, 10), (11, 1, 5), (32, 18, 9)]\n"],"name":"stdout"}]},{"metadata":{"id":"tXDvRwd_047E","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":34},"outputId":"231e3bd1-06df-4e6c-e4e8-ccfc7803ee62","executionInfo":{"status":"ok","timestamp":1549674993085,"user_tz":480,"elapsed":306,"user":{"displayName":"Li Yin","photoUrl":"https://lh5.googleusercontent.com/-KgiTKdqPRUg/AAAAAAAAAAI/AAAAAAAAAIE/aHQ6xO5vQpY/s64/photo.jpg","userId":"13365523799853678553"}}},"cell_type":"code","source":["lst = [(1, 8, 2), (3, 2, 9), (1, 7, 10), (1, 7, 1), (11, 1, 5), (6, 3, 10), (32, 18, 9)]\n","sorted_lst = sorted(lst, key = lambda x: (x[0], -x[1], x[2])) # sort in the order of the first element, and descresing order of the second element, and incresing of the third element\n","print(sorted_lst)"],"execution_count":17,"outputs":[{"output_type":"stream","text":["[(1, 8, 2), (1, 7, 1), (1, 7, 10), (3, 2, 9), (6, 3, 10), (11, 1, 5), (32, 18, 9)]\n"],"name":"stdout"}]}]} -------------------------------------------------------------------------------- /Colab_Codes/Colab Notebooks/chapter_15_bit_manipulation.ipynb: -------------------------------------------------------------------------------- 1 | {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"chapter_15_bit_manipulation.ipynb","version":"0.3.2","provenance":[]},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"metadata":{"id":"6HDn2LSnUIhV","colab_type":"code","colab":{}},"cell_type":"code","source":["\n","'''built-in functions'''\n","print(bin(1), bin(-1))\n","print(bin(126), bin(-126))\n","a = bin(88)\n","a1 = bin(-88)\n","print(a)\n","print(a1)\n","b = int('01011000', 2)\n","c = int('88', 10)\n","print(b, c)\n","\n","d = chr(88)\n","print(d)\n","\n","e = ord('a')\n","print(e)\n","\n","empty_bytes = bytes(4)\n","print(type(empty_bytes))\n","print(empty_bytes)\n","\n","# Cast bytes to bytearray\n","mutable_bytes = bytearray(b'\\x00\\x0F')\n","\n","# Bytearray allows modification\n","mutable_bytes[0] = 255\n","mutable_bytes.append(255)\n","print(mutable_bytes)\n","\n","# Cast bytearray back to bytes\n","immutable_bytes = bytes(mutable_bytes)\n","print(immutable_bytes)\n","\n","# Some bytes to play with\n","byte1 = int('11110000', 2) # 240\n","byte2 = int('00001111', 2) # 15\n","byte3 = int('01010101', 2) # 85\n","\n","# Ones Complement (Flip the bits)\n","print(~byte1)\n","\n","# AND\n","print(byte1 & byte2)\n","\n","# OR\n","print(byte1 | byte2)\n","\n","# XOR\n","print(byte1 ^ byte3)\n","\n","# Shifting right will lose the right-most bit\n","print(byte2 >> 3)\n","\n","# Shifting left will add a 0 bit on the right side\n","print(byte2 << 1)\n","\n","# See if a single bit is set\n","bit_mask = int('00000001', 2) # Bit 1\n","print(bit_mask & byte1) # Is bit set in byte1?\n","print(bit_mask & byte2) # Is bit set in byte2?\n","\n","'''Combined bit manipulation'''\n","def get_bit(val, i):\n"," mask = 1 << i\n"," if val & mask:\n"," return 1\n"," return 0\n","\n","# i i-1 i-2 ... 2 1 0, keep these positions\n","def clear_bits_left_right(val, i):\n"," print('val', bin(val))\n"," mask = (1 << i) -1\n"," print('mask', bin(mask))\n"," return bin(val & (mask))\n","# i i-1 i-2 ... 2 1 0, erase these positions\n","def clear_bits_right_left(val, i):\n"," print('val', bin(val))\n"," mask = (1 << i) -1\n"," print('mask', bin(~mask))\n"," return bin(val & (~mask))\n","\n","\n","print(get_bit(5,1))\n","\n","print(clear_bits_left_right(int('11111111',2), 5))\n","print(clear_bits_right_left(int('11111111',2), 5))\n","\n","'''applications'''\n","def twos_complement(val, bits):\n"," # first flip implemented with xor of val with all 1's\n"," flip_val = val ^ (1 << bits - 1)\n"," #flip_val = ~val we only give 3 bits\n"," return bin(flip_val + 1)\n","\n","\n","def twos_complement2(val, bits):\n"," zeroFound = False\n"," ans = 0\n"," mask = 1\n"," for i in range(bits):\n"," b = (val & (mask)) # get ith bit\n"," print(b)\n"," b = not b # flipped\n"," if not zeroFound:\n"," if not b: # found zero, flip to one, else flip to zero: no operation needed\n"," print('found')\n"," ans = ans | (mask) # set ith bit\n"," zeroFound = True\n"," else:\n"," if b:\n"," ans = ans | (mask)\n"," mask = mask << 1 # change mask to the next bit\n"," return bin(ans)\n","\n","def twos_complement_result(x):\n"," ans1 = -x\n"," ans2 = ~x + 1\n"," print(ans1, ans2)\n"," print(bin(ans1), bin(ans2))\n"," return ans1\n","\n","def strip_last_set_bit(val):\n"," print(bin(val))\n"," return bin(val & (val - 1))\n","\n","def get_lowest_set_bit(val):\n"," return val ^ (val & (val -1))\n"," return (val & (-val))\n","\n","print(twos_complement(5, 8))\n","print(twos_complement2(5, 8))\n","print(strip_last_set_bit(5))\n","print(get_lowest_set_bit(8))\n","\n","twos_complement_result(8)"],"execution_count":0,"outputs":[]}]} -------------------------------------------------------------------------------- /Colab_Codes/Colab Notebooks/chapter_6_linear_data_structure.depre.ipynb: -------------------------------------------------------------------------------- 1 | {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"chapter_6_linear_data_structure.ipynb","version":"0.3.2","provenance":[]},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"metadata":{"id":"3i76tIL3-e9f","colab_type":"code","colab":{}},"cell_type":"code","source":["class Student:\n"," def __init__(self, name, grade, age):\n"," self.name = name\n"," self.grade = grade\n"," self.age = age\n"," def __repr__(self):\n"," return repr((self.name, self.grade, self.age))\n"," \n"," def __cmp__(self, other):\n"," return cmp((self.name, self.grade, self.age), (other.name, other.grade, other.age))\n","# def __hash__(self):\n","# return hash((self.name, self.grade, self.age))\n"," \n","# def __lt__(self, other):\n","# return cmp((self.name, self.grade, self.age), (other.name, other.grade, other.age)) < 0\n","# def __gt__(self, other):\n","# return cmp((self.name, self.grade, self.age), (other.name, other.grade, other.age)) > 0\n","# def __eq__(self, other):\n","# return cmp((self.name, self.grade, self.age), (other.name, other.grade, other.age)) == 0\n","# def __le__(self, other):\n","# return cmp((self.name, self.grade, self.age), (other.name, other.grade, other.age)) <= 0\n","# def __ge__(self, other):\n","# return cmp((self.name, self.grade, self.age), (other.name, other.grade, other.age)) >= 0\n","# def __ne__(self, other):\n","# return cmp((self.name, self.grade, self.age), (other.name, other.grade, other.age)) != 0"],"execution_count":0,"outputs":[]},{"metadata":{"id":"D7cql5y2_DYq","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":72},"outputId":"0af43264-6e4a-4d7a-e5b8-70eb7b71daa9","executionInfo":{"status":"ok","timestamp":1549751870866,"user_tz":480,"elapsed":300,"user":{"displayName":"Li Yin","photoUrl":"https://lh5.googleusercontent.com/-KgiTKdqPRUg/AAAAAAAAAAI/AAAAAAAAAIE/aHQ6xO5vQpY/s64/photo.jpg","userId":"13365523799853678553"}}},"cell_type":"code","source":["a =Student('John', 'A', 14)\n","print(type(('John', 'A', 14)), type(a))\n","print(hash(a))\n","print(a)"],"execution_count":58,"outputs":[{"output_type":"stream","text":[" \n","-9223363270192343580\n","('John', 'A', 14)\n"],"name":"stdout"}]},{"metadata":{"id":"9WTYRI2yNA4G","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":338},"outputId":"613e4070-7e98-4da7-e9ad-bffec3f9121c","executionInfo":{"status":"error","timestamp":1549749345765,"user_tz":480,"elapsed":334,"user":{"displayName":"Li Yin","photoUrl":"https://lh5.googleusercontent.com/-KgiTKdqPRUg/AAAAAAAAAAI/AAAAAAAAAIE/aHQ6xO5vQpY/s64/photo.jpg","userId":"13365523799853678553"}}},"cell_type":"code","source":["b = Student('Alex', 'A', 14)\n","print(a == b)\n","print(sorted([a,b]))"],"execution_count":56,"outputs":[{"output_type":"error","ename":"NameError","evalue":"ignored","traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)","\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mStudent\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Alex'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'A'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m14\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msorted\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m\u001b[0m in \u001b[0;36m__eq__\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m 17\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mcmp\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgrade\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mage\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgrade\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mage\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 18\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__eq__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 19\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mcmp\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgrade\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mage\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgrade\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mage\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 20\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__le__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 21\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mcmp\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgrade\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mage\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgrade\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mage\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m<=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;31mNameError\u001b[0m: name 'cmp' is not defined"]}]},{"metadata":{"id":"ylfCmcuAaTEA","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":227},"outputId":"29974383-bd6e-427d-94d9-0141947e36c8","executionInfo":{"status":"error","timestamp":1549752233299,"user_tz":480,"elapsed":333,"user":{"displayName":"Li Yin","photoUrl":"https://lh5.googleusercontent.com/-KgiTKdqPRUg/AAAAAAAAAAI/AAAAAAAAAIE/aHQ6xO5vQpY/s64/photo.jpg","userId":"13365523799853678553"}}},"cell_type":"code","source":["key1 = hash(('John', 'A', 14))\n","key2 = hash(('John', 'A', 14))\n","print(key1, key2)\n","d = {('John', 'A', 14): 'A+'}\n","print(d[key1], d['John', 'A', 14])"],"execution_count":77,"outputs":[{"output_type":"stream","text":["1266846023488010213 1266846023488010213\n"],"name":"stdout"},{"output_type":"error","ename":"KeyError","evalue":"ignored","traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)","\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkey2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0md\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'John'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'A'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m14\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;34m'A+'\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0md\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mkey1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0md\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'John'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'A'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m14\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m","\u001b[0;31mKeyError\u001b[0m: 1266846023488010213"]}]}]} -------------------------------------------------------------------------------- /Colab_Codes/Colab Notebooks/chapter_6_linear_data_structure.ipynb: -------------------------------------------------------------------------------- 1 | {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"Untitled","version":"0.3.2","views":{},"default_view":{},"provenance":[]},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"cell_type":"code","execution_count":0,"metadata":{},"outputs":[],"source":[""]}]} -------------------------------------------------------------------------------- /Colab_Codes/Colab Notebooks/chapter_8_heap_priority_queue.ipynb: -------------------------------------------------------------------------------- 1 | {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"chapter_8_heap_priority_queue.ipynb","version":"0.3.2","provenance":[],"collapsed_sections":[]},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"metadata":{"id":"XVLSsH816Oz9","colab_type":"text"},"cell_type":"markdown","source":["## Basic implementation"]},{"metadata":{"id":"RbAXuUtD6Swz","colab_type":"code","colab":{}},"cell_type":"code","source":["class Heap:\n"," def __init__(self):\n"," self.heap = [None]\n"," self.size = 0\n"," def __str__(self):\n"," out = ''\n"," for i in range(1, len(self.heap)):\n"," out += str(self.heap[i]) + ' '\n"," return out\n"," def _float(self, index): # enforce min-heap, leaf-to-root\n"," while index // 2: # while parent exist\n"," p_index = index // 2\n"," print('p', p_index, index)\n"," if self.heap[index] < self.heap[p_index]: # a violation\n"," # swap\n"," self.heap[index], self.heap[p_index] = self.heap[p_index], self.heap[index]\n"," else:\n"," break\n"," index = p_index # move up the node\n"," def insert(self, val):\n"," self.heap.append(val)\n"," self.size += 1\n"," self._float(index = self.size)\n"," \n"," def _sink(self, index): # enforce min-heap, root-to-leaf\n"," while 2 * index <= self.size:\n"," li = 2 * index\n"," ri = li + 1\n"," mi = index\n"," if self.heap[li] < self.heap[mi]:\n"," mi = li\n"," if ri <= self.size and self.heap[ri] < self.heap[mi]:\n"," mi = ri\n"," if mi != index:\n"," # swap index with mi\n"," self.heap[index], self.heap[mi] = self.heap[mi], self.heap[index]\n"," else:\n"," break\n"," index = mi\n"," def pop(self):\n"," val = self.heap[1]\n"," self.heap[1] = self. heap.pop()\n"," self.size -= 1\n"," self._sink(index = 1)\n"," return val\n"," \n"," def _float_till_root(self, index): # enforce min-heap, leaf-to-root\n"," while index // 2: # while parent exist\n"," p_index = index // 2\n"," print('p', p_index, index)\n"," if self.heap[index] < self.heap[p_index]: # a violation\n"," # swap\n"," self.heap[index], self.heap[p_index] = self.heap[p_index], self.heap[index]\n"," index = p_index # move up the node\n"," \n"," def heapify(self, lst):\n"," self.heap = [None] + lst\n"," self.size = len(lst)\n"," for i in range(self.size, self.size // 2, -1):\n"," print(self.heap[i])\n"," self._float_till_root(i)\n"," print('after', self.heap)\n"," \n"," def _sink_till_leaf(self, index): # enforce min-heap, root-to-leaf\n"," while 2 * index < self.size:\n"," li = 2 * index\n"," ri = li + 1\n"," mi = li if self.heap[li] < self.heap[ri] else ri\n"," if self.heap[index] > self.heap[mi]:\n"," # swap index with mi\n"," self.heap[index], self.heap[mi] = self.heap[mi], self.heap[index]\n"," index = mi\n"," \n"," def heapify_sink(self, lst):\n"," self.heap = [None] + lst\n"," self.size = len(lst)\n"," for i in range(self.size//2, 0, -1):\n"," self._sink(i)\n"," \n"," def heapsort(self, a):\n"," self.heapify_sink(a)\n"," n = len(a)\n"," for i in range(n, 1, -1): # position to put the root node\n"," self.heap[i], self.heap[1] = self.heap[1], self.heap[i] #swap root with i\n"," self.size -= 1\n"," self._sink(1) # sink dow the new root\n"," print(self.heap)\n"," \n"," "],"execution_count":0,"outputs":[]},{"metadata":{"id":"5-FHH-6o6xPB","colab_type":"code","outputId":"ee4f66eb-affb-4277-c1f7-4895e073e45a","executionInfo":{"status":"ok","timestamp":1550521262381,"user_tz":480,"elapsed":336,"user":{"displayName":"Li Yin","photoUrl":"https://lh5.googleusercontent.com/-KgiTKdqPRUg/AAAAAAAAAAI/AAAAAAAAAIE/aHQ6xO5vQpY/s64/photo.jpg","userId":"13365523799853678553"}},"colab":{"base_uri":"https://localhost:8080/","height":311}},"cell_type":"code","source":["h = Heap()\n","lst = [21, 1, 45, 78, 3, 5]\n","for v in lst:\n"," h.insert(v)\n"," print(h)\n","print('heapify with insertion: ', h)\n","h.pop()\n","print('after pop(): ', h)\n","h.pop()\n","print(h)"],"execution_count":0,"outputs":[{"output_type":"stream","text":["21 \n","p 1 2\n","1 21 \n","p 1 3\n","1 21 45 \n","p 2 4\n","1 21 45 78 \n","p 2 5\n","p 1 2\n","1 3 45 78 21 \n","p 3 6\n","p 1 3\n","1 3 5 78 21 45 \n","heapify with insertion: 1 3 5 78 21 45 \n","after pop(): 3 21 5 78 45 \n","5 21 45 78 \n"],"name":"stdout"}]},{"metadata":{"id":"WzVkLBxHMMKI","colab_type":"code","outputId":"4f89ad5a-fb4c-4cb8-c3d6-229a408fcccd","executionInfo":{"status":"ok","timestamp":1550534069698,"user_tz":480,"elapsed":924,"user":{"displayName":"Li Yin","photoUrl":"https://lh5.googleusercontent.com/-KgiTKdqPRUg/AAAAAAAAAAI/AAAAAAAAAIE/aHQ6xO5vQpY/s64/photo.jpg","userId":"13365523799853678553"}},"colab":{"base_uri":"https://localhost:8080/","height":139}},"cell_type":"code","source":["h = Heap()\n","lst = [21, 1, 45, 78, 3, 5]\n","h.heapify_sink(lst)\n","print('heapify with heapify:', h)"],"execution_count":14,"outputs":[{"output_type":"stream","text":["45\n","after [None, 21, 1, 5, 78, 3, 45]\n","1\n","after [None, 21, 1, 5, 78, 3, 45]\n","21\n","after [None, 1, 3, 5, 78, 21, 45]\n","heapify with heapify: 1 3 5 78 21 45 \n"],"name":"stdout"}]},{"metadata":{"id":"TgA1qpeyarvs","colab_type":"code","outputId":"27a2fd8a-a52b-4867-d3fa-5efab881f033","executionInfo":{"status":"ok","timestamp":1550524082582,"user_tz":480,"elapsed":337,"user":{"displayName":"Li Yin","photoUrl":"https://lh5.googleusercontent.com/-KgiTKdqPRUg/AAAAAAAAAAI/AAAAAAAAAIE/aHQ6xO5vQpY/s64/photo.jpg","userId":"13365523799853678553"}},"colab":{"base_uri":"https://localhost:8080/","height":237}},"cell_type":"code","source":["h = Heap()\n","h.heapsort(lst)\n","print(h)"],"execution_count":0,"outputs":[{"output_type":"stream","text":["45\n","after [None, 21, 1, 45, 78, 3, 5]\n","1\n","after [None, 21, 1, 45, 78, 3, 5]\n","21\n","after [None, 1, 3, 45, 78, 21, 5]\n","[None, 3, 5, 45, 78, 21, 1]\n","[None, 5, 21, 45, 78, 3, 1]\n","[None, 21, 78, 45, 5, 3, 1]\n","[None, 45, 78, 21, 5, 3, 1]\n","[None, 78, 45, 21, 5, 3, 1]\n","78 45 21 5 3 1 \n"],"name":"stdout"}]},{"metadata":{"id":"tTDxuoKlcyzD","colab_type":"text"},"cell_type":"markdown","source":["### through heapq"]},{"metadata":{"id":"x0oarRTYc1fH","colab_type":"code","colab":{}},"cell_type":"code","source":["from heapq import heapify, heappop\n","def heapsort(a):\n"," heapify(a)\n"," return [heappop(a) for i in range(len(a))]\n"],"execution_count":0,"outputs":[]},{"metadata":{"id":"A4yuYo2Hc8Ny","colab_type":"code","outputId":"702ef55b-c9a0-4dd6-91cc-c0d81e6a9b1d","executionInfo":{"status":"ok","timestamp":1550525084329,"user_tz":480,"elapsed":381,"user":{"displayName":"Li Yin","photoUrl":"https://lh5.googleusercontent.com/-KgiTKdqPRUg/AAAAAAAAAAI/AAAAAAAAAIE/aHQ6xO5vQpY/s64/photo.jpg","userId":"13365523799853678553"}},"colab":{"base_uri":"https://localhost:8080/","height":35}},"cell_type":"code","source":["lst = [21, 1, 45, 78, 3, 5]\n","heapsort(lst)"],"execution_count":0,"outputs":[{"output_type":"execute_result","data":{"text/plain":["[1, 3, 5, 21, 45, 78]"]},"metadata":{"tags":[]},"execution_count":74}]}]} -------------------------------------------------------------------------------- /Colab_Codes/Colab Notebooks/suffix_array.ipynb: -------------------------------------------------------------------------------- 1 | {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"suffix_array.ipynb","version":"0.3.2","provenance":[],"toc_visible":true},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"metadata":{"id":"3s7lvSxaj9Fi","colab_type":"text"},"cell_type":"markdown","source":["## sort cyclic shifts of string s + '$' to construct the suffix array"]},{"metadata":{"id":"JjYArMUrkDIu","colab_type":"code","colab":{}},"cell_type":"code","source":["from collections import OrderedDict\n","\n","def getCharOrder(s):\n"," n = len(s)\n"," numChars = 256\n"," count = [0]*numChars # totally 256 chars, if you want, can print it out to see these chars\n"," \n"," order = [0]*(n)\n"," \n"," #count the occurrence of each char\n"," for c in s:\n"," count[ord(c)] += 1\n"," \n"," # prefix sum of each char\n"," for i in range(1, numChars):\n"," count[i] += count[i-1]\n"," \n"," # assign from count down to be stable\n"," for i in range(n-1,-1,-1):\n"," count[ord(s[i])] -=1\n"," order[count[ord(s[i])]] = i # put the index into the order instead the suffix string\n"," \n"," return order\n"," "],"execution_count":0,"outputs":[]},{"metadata":{"id":"CXthy2Rqt6nm","colab_type":"code","colab":{}},"cell_type":"code","source":["def getCharClass(order, cls):\n"," n = len(order)\n"," cls = [0]*n\n"," # if it all differs, then cls[i] = order[i]\n"," cls[order[0]] = 0 #the 6th will be 0\n"," for i in range(1, n):\n"," # use order[i] as index, so the last index\n"," if s[order[i]] != s[order[i-1]]:\n"," print('diff',s[order[i]],s[order[i-1]])\n"," cls[order[i]] = cls[order[i-1]] + 1\n"," else:\n"," cls[order[i]] = cls[order[i-1]]\n"," return cls\n"," "],"execution_count":0,"outputs":[]},{"metadata":{"id":"yfCeF3b77m4M","colab_type":"code","colab":{}},"cell_type":"code","source":["'''It is a counting sort using the first part as class'''\n","def sortDoubled(s, L, order, cls):\n"," n = len(s)\n"," count = [0] * n\n"," new_order = [0] * n\n"," # their key is the class\n"," for i in range(n):\n"," count[cls[i]] += 1\n"," \n"," # prefix sum\n"," for i in range(1, n):\n"," count[i] += count[i-1]\n"," \n"," # assign from count down to be stable\n"," # sort the first half\n"," for i in range(n-1, -1, -1):\n"," start = (order[i] - L + n) % n #get the start index of the first half, \n"," count[cls[start]] -= 1\n"," new_order[count[cls[start]]] = start\n"," \n"," return new_order"],"execution_count":0,"outputs":[]},{"metadata":{"id":"2I1nIvImB3O8","colab_type":"code","colab":{}},"cell_type":"code","source":["def updateClass(order, cls, L):\n"," n = len(order)\n"," new_cls = [0]*n\n"," # if it all differs, then cls[i] = order[i]\n"," new_cls[order[0]] = 0 #the 6th will be 0\n"," for i in range(1, n):\n"," cur_order, prev_order = order[i], order[i-1]\n"," # use order[i] as index, so the last index\n"," if cls[cur_order] != cls[prev_order] or cls[(cur_order+L) % n] != cls[(prev_order+L) % n]:\n"," new_cls[cur_order] = new_cls[prev_order] + 1\n"," else:\n"," new_cls[cur_order] = new_cls[prev_order]\n"," return new_cls"],"execution_count":0,"outputs":[]},{"metadata":{"id":"2Wv3muUHkNl_","colab_type":"code","colab":{}},"cell_type":"code","source":["\n","def cyclic_shifts_sort(s):\n"," s = s + '$'\n"," n = len(s)\n"," order = getCharOrder(s)\n"," cls = getCharClass(s, order)\n"," print(order, cls)\n"," L = 1\n"," while L < n:\n"," order = sortDoubled(s, 1, order, cls)\n"," cls = updateClass(order, cls, L)\n"," print(order, cls)\n"," L *= 2\n"," \n"," return order"],"execution_count":0,"outputs":[]},{"metadata":{"id":"OpqYr3Z6rsM_","colab_type":"code","outputId":"eb382cee-6f8d-459c-911f-10c955b45dad","executionInfo":{"status":"ok","timestamp":1549232253713,"user_tz":480,"elapsed":336,"user":{"displayName":"Li Yin","photoUrl":"https://lh5.googleusercontent.com/-KgiTKdqPRUg/AAAAAAAAAAI/AAAAAAAAAIE/aHQ6xO5vQpY/s64/photo.jpg","userId":"13365523799853678553"}},"colab":{"base_uri":"https://localhost:8080/","height":146}},"cell_type":"code","source":["s = 'ababaa'\n","cyclic_shifts_sort(s)"],"execution_count":32,"outputs":[{"output_type":"stream","text":["diff a $\n","diff b a\n","[6, 0, 2, 4, 5, 1, 3] [1, 2, 1, 2, 1, 1, 0]\n","[6, 5, 4, 0, 2, 1, 3] [3, 4, 3, 4, 2, 1, 0]\n","[6, 5, 4, 0, 2, 3, 1] [3, 6, 4, 5, 2, 1, 0]\n","[6, 5, 4, 0, 2, 3, 1] [3, 6, 4, 5, 2, 1, 0]\n"],"name":"stdout"},{"output_type":"execute_result","data":{"text/plain":["[6, 5, 4, 0, 2, 3, 1]"]},"metadata":{"tags":[]},"execution_count":32}]},{"metadata":{"id":"5nNbGVRTjvvL","colab_type":"text"},"cell_type":"markdown","source":[""]}]} -------------------------------------------------------------------------------- /Colab_Codes/Colab Notebooks/tree_data_structure.ipynb: -------------------------------------------------------------------------------- 1 | {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"tree_data_structure.ipynb","version":"0.3.2","provenance":[],"toc_visible":true},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"metadata":{"id":"3A2mprldYvXe","colab_type":"text"},"cell_type":"markdown","source":["### N-aray Tree"]},{"metadata":{"id":"h5LNx9p_ZxtH","colab_type":"text"},"cell_type":"markdown","source":["#### Define Tree Node"]},{"metadata":{"id":"9R_XYWC2Yz-G","colab_type":"code","colab":{}},"cell_type":"code","source":["class NaryNode:\n"," '''Define a n-ary node'''\n"," def __init__(self, n, val):\n"," self.children = [None] * n\n"," self.val = val\n"," "],"execution_count":0,"outputs":[]},{"metadata":{"id":"Xx5WEdJDZ4-q","colab_type":"text"},"cell_type":"markdown","source":["#### Define a Tree and implement operations"]},{"metadata":{"id":"qtAos_DOZwkw","colab_type":"code","colab":{}},"cell_type":"code","source":[""],"execution_count":0,"outputs":[]},{"metadata":{"id":"wLPjQrfnZbQY","colab_type":"text"},"cell_type":"markdown","source":["### Binary Tree"]},{"metadata":{"id":"oUZYimKbZ1ZL","colab_type":"text"},"cell_type":"markdown","source":["#### Define Tree Node"]},{"metadata":{"id":"ZKknhNURZdA0","colab_type":"code","colab":{}},"cell_type":"code","source":["class BinaryNode:\n"," '''Define a classical binary tree node'''\n"," def __init__(self, val):\n"," self.left = None\n"," self.right = None\n"," self.val = val"],"execution_count":0,"outputs":[]},{"metadata":{"id":"yPukXXkXZ_zn","colab_type":"text"},"cell_type":"markdown","source":["#### Define a Tree and implement operations\n"," 1\n"," / \\ \n"," 2 3\n"," / \\ \\\n","4 5 6 "]},{"metadata":{"id":"CyXwZ9sf8dyG","colab_type":"code","colab":{}},"cell_type":"code","source":["root = BinaryNode(1)\n","left = BinaryNode(2)\n","right = BinaryNode(3)\n","root.left = left\n","root.right = right\n","left.left = BinaryNode(4)\n","left.right = BinaryNode(5)\n","right.right = BinaryNode(6)"],"execution_count":0,"outputs":[]},{"metadata":{"id":"gOHqKKfY_Ug0","colab_type":"code","colab":{}},"cell_type":"code","source":["def constructTree(a, idx):\n"," '''construct a binary tree recursively from input array a'''\n"," if idx >= len(a):\n"," return None\n"," node = BinaryNode(a[idx])\n"," node.left = constructTree(a, 2*idx + 1)\n"," node.right = constructTree(a, 2*idx + 2)\n"," return node"],"execution_count":0,"outputs":[]},{"metadata":{"id":"STvuN-5p_5Di","colab_type":"code","colab":{}},"cell_type":"code","source":["nums = [1, 2, 3, 4, 5, None, 6]\n","root = constructTree(nums, 0)"],"execution_count":0,"outputs":[]},{"metadata":{"id":"hrJC3v5ZAvD-","colab_type":"text"},"cell_type":"markdown","source":["#### To show the nodes at each level, we use LevelOrder function to print out the tree:"]},{"metadata":{"id":"uPxVdjRrA0UB","colab_type":"code","colab":{}},"cell_type":"code","source":["def LevelOrder(root):\n"," q = [root]\n"," while q:\n"," new_q = []\n"," for n in q:\n"," if n is not None:\n"," print(n.val, end=',')\n"," if n.left:\n"," new_q.append(n.left)\n"," if n.right:\n"," new_q.append(n.right)\n"," q = new_q\n"," print('\\n')\n"],"execution_count":0,"outputs":[]},{"metadata":{"id":"Pl2HGcHkA4rT","colab_type":"code","outputId":"2282a8ed-e1c1-4dae-b83c-0c2a8c19b470","executionInfo":{"status":"ok","timestamp":1550969967703,"user_tz":480,"elapsed":336,"user":{"displayName":"Li Yin","photoUrl":"https://lh5.googleusercontent.com/-KgiTKdqPRUg/AAAAAAAAAAI/AAAAAAAAAIE/aHQ6xO5vQpY/s64/photo.jpg","userId":"13365523799853678553"}},"colab":{"base_uri":"https://localhost:8080/","height":127}},"cell_type":"code","source":["LevelOrder(root)"],"execution_count":0,"outputs":[{"output_type":"stream","text":["1,\n","\n","2,3,\n","\n","4,5,None,6,\n","\n"],"name":"stdout"}]},{"metadata":{"id":"2edkOHbCCV7n","colab_type":"text"},"cell_type":"markdown","source":[""]}]} -------------------------------------------------------------------------------- /Colab_Codes/Colab Notebooks/tree_search.ipynb: -------------------------------------------------------------------------------- 1 | {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"tree_search.ipynb","version":"0.3.2","provenance":[]},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"metadata":{"id":"-N44hhD6CqRT","colab_type":"code","colab":{}},"cell_type":"code","source":[""],"execution_count":0,"outputs":[]},{"metadata":{"id":"8xckq2iGCtG8","colab_type":"text"},"cell_type":"markdown","source":["## DFS tree search"]},{"metadata":{"id":"dw0xDCnDCyLo","colab_type":"text"},"cell_type":"markdown","source":["### A general purpose search"]},{"metadata":{"id":"c9xcMvZxC0zK","colab_type":"code","colab":{}},"cell_type":"code","source":["def dfs(t, s):\n"," '''implement the dfs recursive of tree'''\n"," print(s)\n"," for neighbor in t[s]:\n"," dfs(t, neighbor)\n"," return"],"execution_count":0,"outputs":[]},{"metadata":{"id":"pOnCVL5eDIh-","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":121},"outputId":"7c437d60-4881-4eea-b4ba-c9675519a7e2","executionInfo":{"status":"ok","timestamp":1551054538760,"user_tz":480,"elapsed":403,"user":{"displayName":"Li Yin","photoUrl":"https://lh5.googleusercontent.com/-KgiTKdqPRUg/AAAAAAAAAAI/AAAAAAAAAIE/aHQ6xO5vQpY/s64/photo.jpg","userId":"13365523799853678553"}}},"cell_type":"code","source":["t = {1: [2, 3], 2: [4, 5],\n"," 3: [], 4: [6], 5: [], 6: []}\n","dfs(t, 1)"],"execution_count":4,"outputs":[{"output_type":"stream","text":["1\n","2\n","4\n","6\n","5\n","3\n"],"name":"stdout"}]}]} -------------------------------------------------------------------------------- /Easy-Book/chapters/chapter_13_tree_traversal.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex]{subfiles} 2 | \begin{document} 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | %%%%%%%%%%%%% Tree Traverse 5 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6 | As the second Chapter related to trees, it is time for us to learn how to complete search a given tree and learn the different applications of trees as mentioned in Chapter~\ref{chapter_}. Same as a graph data structure, the first thing before thinking about any algorithms is to learn methods to traverse the tree. As in graph, there are two broad ways to iterate all nodes and edges in the tree, Depth-first-search(DFS) and Breath-first-search(BFS). Gladly, due to simpler structure the tree is and it has no cycles, the traverse of a tree is easier to implement than that of a general graph, because there are no cycles in the tree and it is not possible to reach a node from multiple directions. 7 | 8 | \paragraph{Tree Traversal} We first talk about general traversal of trees, first start with the free trees, which are just simplified version of graph search implementation without the state records. We mainly focus on the implementation of rooted trees and learn both recursive and iterative implementation. These contents will be shown in: 9 | \begin{enumerate} 10 | \item Depth-first-search based Tree Traversal in Section~\ref{dfs_tree_traversal}. 11 | \item Breath-first-search based Tree Traversal in Section~\ref{bfs_tree_traversal}. 12 | \end{enumerate} 13 | 14 | \paragraph{Applications} We then focus on the applications of trees, mainly with different types of search trees, include binary search tree (BST), segment tree, trie for string and order statistic trees. We would learn how to do search in these different trees and how to implement basic operations to make it a data structure such as insert, delete, and construction. 15 | \begin{enumerate} 16 | \item Binary Search Tree in Section~\ref{}. 17 | \item Segment Tree in Section~\ref{}. 18 | \item Trie for string in Section~\ref{}. 19 | \end{enumerate} 20 | 21 | \begin{figure}[h] 22 | \centering 23 | \includegraphics[width=0.6\columnwidth]{fig/example_graph.png} 24 | \caption{Example Graph vs converted tree, where we delete edge $3->5$ and $5->6$.} 25 | \label{example_graph_tree} 26 | \end{figure} 27 | 28 | 29 | 30 | 31 | \end{document} -------------------------------------------------------------------------------- /Easy-Book/chapters/chapter_7_graph_implementation.tex: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | %%%%%%%%%%%%% Graph 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | \documentclass[../main.tex]{subfiles} 5 | \begin{document} 6 | \begin{figure}[!ht] 7 | \centering 8 | % \includegraphics[width=\columnwidth]{fig/graph_1.png} 9 | % \caption{An undirected graph} 10 | % \label{fig:graph_1} 11 | 12 | \includegraphics[width=\columnwidth]{fig/example_undirected_directed_graph.png} 13 | \caption{Example of undirected and directed graph: mark the vertices and edges} 14 | \label{fig:graph_2} 15 | \end{figure} 16 | Graph is a natural way to represent connections and reasoning between things or events. A graph is made up of \textit{vertices} (or nodes, points) are connected by \textit{edges} (arcs, or lines). A graph structure is shown in Fig.~\ref{fig:graph_2}. There are many fields in that heavily rely on the graph, such as the probabilistic graphical models applied in computer vision, route problems, network flow in network science, link structures of a website in social media in computer science. 17 | 18 | In this chapter, we present graph as a data structure. However, graph is really a broad way to model problems; for example, we can model the possible solution space as a graph and apply graph search to find the possible solution to a problem. So, do not let the physical graph data structures limit our imagination. 19 | 20 | 21 | 22 | As the first chapter related to graph, we mainly focus on explain related concepts, terminologies, graph representation, and the basic exhaustive search methods on real graph data structures: 23 | \begin{itemize} 24 | \item Knowing the definition and the \textbf{terminologies} commonly used in Section~\ref{graph_terminology}. 25 | \item \textbf{Representing the graph} data structures and implement these representation in Python in Section~\ref{graph_representation}. 26 | \item Learn the most basic graph search: Breath-first-search and Depth-first search in Section~\ref{sec_bfs}. 27 | \end{itemize} 28 | 29 | \paragraph{Arrangement of Graph in the Book} Searching in graph which lies at the heart of the field of graph algorithms, therefore, we put effort in this book to explain the behavior, properties of them compared with a lot other books. More advanced searching techniques and applications will be detailed in Chapter~\ref{chapter_non_linear_searching} in the part ~\ref{part_complete_searching}. And more advanced graph algorithms that build upon the basic searching techniques will be taught in Chapter ~\ref{chapter_advanced_non_linear_search} in part ~\ref{part_advanced_topics}. And graph related questions instead will be categorized in Chapter ~\ref{chapter_graph_problem} in Part ~\ref{part_question}. 30 | 31 | %\section{Graph Traversal} 32 | % \begin{figure}[h] 33 | % \centering 34 | % % \includegraphics[width=0.6\columnwidth]{fig/dfs_bfs.png} 35 | % % \caption{BFS VS DFS} 36 | % % \label{fig:bfs_dfs} 37 | % \includegraphics[width=0.6\columnwidth]{fig/example_graph.png} 38 | % \caption{Example Graph} 39 | % \label{example_graph} 40 | % \end{figure} 41 | % The breadth first search (BFS) and the depth first search (DFS) are the two algorithms used for traversing and searching a node in a graph. They can also be used to find out whether a node is reachable from a given node or not. %In Fig.~\ref{fig:bfs_dfs} shows the BFS and DFS traverse ordering. Starting from a given vertex $u$, BFS will traverse all of its adjacency nodes $v_i$ and print out them, and then continue to the adjacency nodes of $v_i$, while the DFS will traverse all of its adjacency nodes, but in a recursively way, which it recursively traverse the adjacency nodes of the current node untill reaching to a node that has no outgoing nodes. 42 | 43 | % Both BFS and DFS has a time complexity of $O(V+E)$ with adjacency list and $O(V^2)$ with adjacency matrix. 44 | 45 | 46 | 47 | % A basic DFS and BFS implementation will only need state (1) and (3). While in some advanced extension of DFS and BFS, state (2) might be needed. Searching is an universal approach in problem solving. With searching, it literally search in the solution space and find the solutions. In this chapter, we focus on the basic Breadth-first and Depth-first Search algorithms executed on real graph data structure, and then exploring how to apply the DFS and BFS techniques on problem solution space, and introduce an optimized searching technique called \textit{Backtracking}. 48 | % \begin{enumerate} 49 | % \item Breath-first Search in Section~\ref{sec_bfs}. 50 | % \item Depth-first Search in Section~\ref{searching_dfs}. 51 | % \item Graph Search for Problem Solving 52 | % \item Backtracking 53 | % \end{enumerate} 54 | 55 | \paragraph{Graph in Interviews} Graph solution for some problems are most likely to be the naive solution, and it is a nice first step to give the naive algorithm design and analysis before moving on to more advanced solutions, such as divide and conquer, dynamic programming, or greedy algorithm. For some problems, graph search might be the only solution, so learning how to pruning the searching space with techniques like bidirectional search and backtracking would become handy. 56 | 57 | \section{Introduction and Terminologies} 58 | \label{graph_terminology} 59 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 60 | % matrix and graph 61 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 62 | % \section{Graphs} 63 | % \label{chapter_graph_matrix} 64 | Graph is a widely used data structure to model real-world problems. A graph is a collection of \textit{vertices} and \textit{edges} (which connects two vertices). 65 | 66 | 67 | 68 | %%%%%%%%%%%%%graph representation%%%%%%%%%%%%%%%%%%%%%%%%%% 69 | 70 | 71 | \end{document} -------------------------------------------------------------------------------- /Easy-Book/chapters/chapter_advanced_graph_algorithm.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/chapters/chapter_advanced_graph_algorithm.pdf -------------------------------------------------------------------------------- /Easy-Book/chapters/chapter_advanced_graph_algorithm.synctex.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/chapters/chapter_advanced_graph_algorithm.synctex.gz -------------------------------------------------------------------------------- /Easy-Book/chapters/chapter_combinatorics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/chapters/chapter_combinatorics.pdf -------------------------------------------------------------------------------- /Easy-Book/chapters/chapter_combinatorics.synctex.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/chapters/chapter_combinatorics.synctex.gz -------------------------------------------------------------------------------- /Easy-Book/chapters/chapter_heuristic_search.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex]{subfiles} 2 | \begin{document} 3 | A \textit{heuristic} search is a method that: 4 | \begin{enumerate} 5 | \item sacrifices completeness to increase efficiency; that it might not always find the best solution, but can be guaranteed to find a good solution in a reasonable time. 6 | \item it is useful in solving tough problems which could not be solved any other way or solutions that take an infinite time or very long time to compute. 7 | \item Classical example of heuristic search methods is the travelling salesman problem. 8 | 9 | \end{enumerate} 10 | \section{Hill Climbing} 11 | \section{Simulated Annealing} 12 | \section{Best-first Search} 13 | \section{The $A^{*}$ Algorithm} 14 | \section{Graceful dacay of admissibility} 15 | 16 | \section{Summary and comparison with Complete Search} 17 | We will address how to write search algorithms. In particular we will examine: 18 | \begin{enumerate} 19 | \item the data structure to keep unexplored nodes. We use a queue (often called a list in many AI books) called OPEN. 20 | \item expansion of a node (or generation of its successors). All the successors of a node can be generated at once (method most commonly used) or they could be generated one at a time either in a systematic way or in a random way. The number of successors is called the branching factor. 21 | \item strategies for selecting which node to expand next. Different algorithms result from different choices (e.g. depth-first when successor nodes are added at the beginning of the queue, breadth-first when successor nodes are added at the end of the queue, etc), 22 | test for goal. We will assume the existence of a predicate that applied to a state will return true or false. 23 | \item bookkeeping (keeping track of visited nodes, keeping track of path to goal, etc). Keeping track of visited nodes is usually done by keeping them in a queue (or, better a hash-table) called CLOSED. This prevents getting trapped into loops or repeating work but results in a large space complexity. This is (most often) necessary when optimal solutions are sought, but can be (mostly) avoided in other cases. 24 | \item Keeping track of the path followed is not always necessary (when the problem is to find a goal state and knowing how to get there is not important). 25 | \end{enumerate} 26 | properties of search algorithms and the solutions they find: 27 | \begin{enumerate} 28 | 29 | \item Termination: the computation is guaranteed to terminate, no matter how large the search space is. 30 | \item Completeness: an algorithm is complete if it terminates with a solution when one exists. 31 | \item Admissibility: an algorithm is admissible if it is guaranteed to return an optimal solution whenever a solution exists. 32 | \item Space complexity and Time complexity: how the size of the memory and the time needed to run the algorithm grows depending on branching factor, depth of solution, number of nodes, etc. 33 | \end{enumerate} 34 | Let's briefly examine the properties of some commonly used uninformed search algorithms. 35 | 36 | Depth-First Search 37 | 38 | Termination: 39 | guaranteed for a finite space if repeated nodes are checked. Guaranteed when a depth bound is used. Not guaranteed otherwise. 40 | Completeness: 41 | not guaranteed in general. Guaranteed if the search space is finite (exhaustive search) and repeated nodes are checked. 42 | Admissibility: 43 | not guaranteed. 44 | 45 | Breadth-First Search 46 | 47 | Termination: 48 | guaranteed for finite space. Guaranteed when a solution exists. 49 | Completeness: 50 | guaranteed. 51 | Admissibility: 52 | the algorithm will always find the shortest path (it might not be the optimal path, if arcs have different costs). 53 | 54 | Depth-First Search Iterative-Deepening 55 | 56 | Termination: 57 | guaranteed for finite space. Guaranteed when a solution exists. 58 | Completeness: 59 | guaranteed. 60 | Admissibility: 61 | the algorithm will always find the shortest path (it might not be the optimal path, if arcs have different costs). 62 | 63 | classes of search algorithms. We can classify search algorithms along multiple dimensions. Here are some of the most common: 64 | uninformed (depth-first, breadth-first, uniform cost, depth-limited, iterative deepening) versus informed (greedy, A*, IDA*, SMA*) 65 | local (greedy, hill-climbing) versus global (uniform cost, A*, etc) 66 | systematic (depth-first, A*, etc) versus stochastic (simulated annealing, genetic algorithms) 67 | 68 | \end{document} -------------------------------------------------------------------------------- /Easy-Book/chapters/chapter_non_linear_iterative_search.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex]{subfiles} 2 | \begin{document} 3 | Up till now, we have learned both DFS and BFS in graph search. From the last chapter, we have seen how the backtracking method utilized DFS to solve enumeration and CSP based problems. The type of problem we should solve with backtracking is the one that requires enumeration all possibilities. We have seen that most of the time, backtracking comes with high complexity. If the problem only requires us to find if 4 | \section{Bidirectional BFS} 5 | \url{http://theoryofprogramming.com/2018/01/21/bidirectional-search/} 6 | \section{} 7 | \end{document} -------------------------------------------------------------------------------- /Easy-Book/chapters/chapter_searching_strategies.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/chapters/chapter_searching_strategies.pdf -------------------------------------------------------------------------------- /Easy-Book/chapters/chapter_searching_strategies.synctex.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/chapters/chapter_searching_strategies.synctex.gz -------------------------------------------------------------------------------- /Easy-Book/chapters/delete/algorithms.tex.prec: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex]{subfiles} 2 | \begin{document} 3 | % \chapter{Introduction} 4 | % To introduce the algorithms, start with the brute force, then go to the efficient algorithms, including the analysis of complexity. In this chapter, we start with the basic algorithms, sorting, and basic algorithm theory, divide and conquer, dynamic programming, greedy algirhtm. Then in another part we introduce more specific popular algorithms. 5 | % \subfile{chapters/part3/introduction} 6 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7 | %%%%%%%%%%%%% Divide and Conqure and Trees 8 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9 | % \chapter{Divide and Conquer} 10 | % \label{divide-conquer} 11 | % \subfile{chapters/part3/divide-conquer ***} 12 | 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14 | %%%%%%%%%%%%% Dynamic Programming 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | 17 | 18 | 19 | 20 | \end{document} -------------------------------------------------------------------------------- /Easy-Book/chapters/delete/basic_algorithm.tex.prec: -------------------------------------------------------------------------------- 1 | \documentclass[../main-book.tex]{subfiles} 2 | \begin{document} 3 | % \chapter{Introduction} 4 | % To introduce the algorithms, start with the brute force, then go to the efficient algorithms, including the analysis of complexity. In this chapter, we start with the basic algorithms, sorting, and basic algorithm theory, divide and conquer, dynamic programming, greedy algirhtm. Then in another part we introduce more specific popular algorithms. 5 | % \subfile{chapters/part3/introduction} 6 | 7 | 8 | 9 | 10 | \end{document} -------------------------------------------------------------------------------- /Easy-Book/chapters/delete/data-structure.tex.prec: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex]{subfiles} 2 | \begin{document} 3 | %%%%%%%%%%%%%%%% 4 | % CHAPTER Two! % 5 | %%%%%%%%%%%%%%%% 6 | In the programming, data structures are used to store data and make operations on them so that we can conduct different algorithms on them in order to solve real-world problems and meet certain efficiency. The comparison between varies of data structures are highly dependable on the context of the problem we are facing. Being familiar with data structures is a must for us to understand and implement algorithms following this part. The concepts of data structures and the real data types and/or built-in modules in Python goes hand in hand for the real understanding. Thus, in our book, we insist on learning the concepts, real implementation with basic built-in data types: list/ dict/ string/ together. On this base, we learn built-in modules which implements these data structures for us directly and with good efficiency. 7 | 8 | On high level, data structures can be categories as two main types: \textit{Liner} (Chapter~\ref{chapter_linear_data_structure}) and \textit{Non-liner} (include: Heap and Graph in Chapter~\ref{chapter_non_linear_data_structure} and Chapter~\ref{chapter_tree}). Before we move ahead to learn these data structures, it is essential for us to understand how normally data structures are categorized based on specific characters: 9 | \begin{itemize} 10 | \item \textbf{Mutable vs Immutable} In the sense of if modification of the items of the data structures is allowed, there are \textit{mutable} and \textit{immutable} data structures. 11 | \item \textbf{Static vs Dynamic} Moreover, we can categorize the data structures as \textit{static data structures} and \textit{dynamic data structures} according to if we can change the size of the created data structures. In static data structure the size of the structure is fixed since its creation. While, in dynamic data structure, the size of the structure is not fixed and can be modified through operations such as Insertion and Append. Dynamic data structures are designed to facilitate change of data structures in the run time. 12 | \end{itemize} 13 | 14 | The implementation of different data structures can vary as the programming languages. To make the contents more compact and make the reference more convenient, in this part, we combine data strutures from the programming literature with corresponding data structures (either built-in or external modules) come from Python. Due to this understanding, for each data structure, the contents are organized as: 15 | \begin{itemize} 16 | \item firstly we will introduce the concept of the data structures including definition, pros, and cons; 17 | \item secondly, the common basic operations with concepts and time complexity: Access, Search, Insertion, Deletion. \item lastly, to complete the picture, we introduce Python's data structures (either built-in or external) with their methods and corresponding operations. 18 | \end{itemize} 19 | 20 | % The contents of this part is organized as: Array (Section~\ref{}), Linked List (singly or doubly linked lists), Hashmap(Section~\ref{}), Queue and Stack (Section~\ref{}). 21 | 22 | Divide and Conquer serves as the fundalmental problem solving methodology for the software programming, Data structures on the other hand plays the role of laying the foundation for any problem-solving paradigm or say algorithms to run on. Therefore, the content of this chapter will serve as the footstone for the purpose of the whole book -- ``crackin'' the LeetCode problems. The purpose of this part is to give beginners a chance to learn different data structures and its Python implementation systematically and practically in the sense of problem solving. For medium or higher level audiences, the organization of this part can help them review their knowledge base efficiently. 23 | 24 | % to typical application of each data structure. The goal of this part is, when we are handling practical real-world problem, we can first come up with the possibly the optimal data structure to model the problem and apply algorithms on to get our answers. Also, this part gives beginners a chance to learn common to high-end data structures in Python before we head off to solving LeetCode problems. 25 | 26 | % All the data structures are containers of information, and each is structured differently for the others to fit in a certain need. In Chapter~\ref{chapter_basic_data_structure}, we will include the most basic and fundamental linear data structures in software programming: Array and String, Linked List, Hashmap, Queue and Stack. In Chapter~\ref{chapter_advanced_data_structure} will include the non-linear data Structure, including Heap, Tree, and Graph. 27 | 28 | % Each data structure is for its unique purpose, for example, we introduce Monotone Queue in Section~\ref{section_mono_stack} which is rarely covered in most of algorithms books. We will show how using this type of data structure can help us achieve liner time performance for challenging LeetCode problems. 29 | 30 | % However, we will included the categorized type of problems in Part~\ref{part_specific_algorithms} Specific Algorithms so that in this part, we can focus on the concepts and not the specific algorithms. Also, this structure can benefit the beginners, to start from the basic. And becaues in Part~\ref{part_algorithms} we will include comprehensive explanation of each algorithm methodology. And in Part~\ref{part_specific_algorithms} we complete the picture, combing the data structure and the algorithms to solve real problems. 31 | % chapter 6 32 | \chapter{Linear Data Structure} 33 | \label{chapter_linear_data_structure} 34 | \subfile{chapters/chapter_6_linear_data-structure} 35 | 36 | % chapter 7 37 | \chapter{Graphs and Trees} 38 | \label{chapter_non_linear_data_structure} 39 | \subfile{chapters/chapter_7_advanced_data_structure} 40 | \end{document} -------------------------------------------------------------------------------- /Easy-Book/chapters/delete/math_bit_manipulation.tex.prec: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex]{subfiles} 2 | \begin{document} 3 | 4 | 5 | 6 | 7 | % \chapter{Specific Algorithms} 8 | % \subfile{chapters/part4/two-pointer} 9 | % \label{algo_for_array} 10 | 11 | \end{document} 12 | % \section{How to solve in brute force} 13 | % What is the time complexity in brute force, what is divide and conquer, what types of questions (description and time complexity) can be potentially resolved by the divide and conquer. 14 | 15 | -------------------------------------------------------------------------------- /Easy-Book/chapters/delete/problems.tex.depre: -------------------------------------------------------------------------------- 1 | \documentclass[../problem_catalog.tex]{subfiles} 2 | \begin{document} 3 | 4 | \part{Questions on Special Topics} 5 | % This part maybe we can categorize according to different types of problems, repeat, sum, subarray, subsequence, and so. 6 | In this part, we mainly focusing on solving LeetCode Problems and see how our learned algorithm methodology ranging from sorting, learning, to divide and conquer can be applied to solve real problems. 7 | 8 | % However, before we move forward to solve these problems directly, we first introduce more algorithms which most of them are not shown in most of the algorithm related books, and these algorithms are derived from our learned basic algorihtms and tuned to solve a more specific problem and are almost the most time or space efficient. Thus, the first chapter in this part is \textbf{Specific Algorithms}, and we will walk through these algorithms by using LeetCode problems as examples. 9 | 10 | However, we are not giving you problems after each algorithms chapters to practise on and for each problem, to offer you some solutions and simple explanation. We are focusing on \textbf{systematizing} the problems by a theme: including Dynamic Programming (Chapter~\ref{dp_problem}), Array(Chapter~\ref{array_problem}), String(Chapter~\ref{string_problem}), Tree(Chapter~\ref{tree_problem}), and Graph(Chapter~\ref{graph_problem}). 11 | 12 | First, dynamic programming is challenging but constantly be seen in the interviews. Therefore, we categorize the dynamic programming problems into different types and practice and summarize on each type's special characters in order to attack them one by one. After this chapter, I believe you would have better understanding and hands-on practice of dynamic programming which you once thought are abstract and obscure. 13 | 14 | The later section of this part is categorized by different data structures of inputs we are given in the problems. I found it reasonable because for array, we normally use it to save numerical information or string, and it would either be math related or string pattern matching. The following chapter is to categorize the string related problems. For string problem, it would be more pattern matching other than computation. After this, it would be tree related tree, which tree traversal and divide and conquer would play big role. Same for the graph problems. 15 | 16 | % This Chapter would include a large amout of LeetCode problems and each put under a category. The purpose of doing so is to find some common solution for a certain type of problems. This is a great way to learn and digest the algorihtms we learned and become practical. For all the problems, I would explain the native way and how we can further improve it and most of the time, what is the possible best solution we can work out. All of these solutions would not purely based on my own personal knowledge, I would refer the best solution and the most elegant code out there. 17 | 18 | % \chapter{Divide and Conquer Questions} 19 | % \subfile{chapters/part4/divide_conquer_questions} 20 | % \label{divide_and_conquer problem} 21 | 22 | \chapter{Dynamic Programming Questions (15\%)} 23 | \subfile{chapters/part4/dynamic_programming} 24 | \label{dp_problem} 25 | 26 | \chapter{String pattern Matching} 27 | \label{topic_string_processing} 28 | \subfile{chapters/part4/special_topics/string_matching} 29 | 30 | % % \subfile{chapters/part4/special_topics/string_trie_tree_array} 31 | % \section{LeetCode Problems} 32 | % \begin{enumerate} 33 | % \item 14. Longest Common Prefix (easy) 34 | % \end{enumerate} 35 | % \end{document} 36 | 37 | 38 | %%%%%%%%%%%%%%%%%Second part%%%%%%%%%%%%%%%%% 39 | \part{Questions by Data Structures} 40 | \chapter{Array Questions(15\%)} 41 | \subfile{chapters/part4/array_question} 42 | \label{array_problem} 43 | 44 | \chapter{Linked List, Stack, Queue, and Heap Questions (12\%)} %(44+34+9+31) 45 | \label{other_linear_datastrcutre_problem} 46 | \subfile{chapters/part4/linked_list_question} 47 | 48 | 49 | \chapter{String Questions (15\%)} 50 | \subfile{chapters/part4/pattern-matching} 51 | \label{string_problem} 52 | 53 | \chapter{Tree Questions(10\%)} 54 | \subfile{chapters/part4/algorithms_for_tree } 55 | \label{tree_problem} 56 | 57 | \chapter{Graph Questions (15\%)} 58 | \subfile{chapters/part4/specific_algorithms_for_graph} 59 | \label{graph_problem} 60 | 61 | 62 | \end{document} -------------------------------------------------------------------------------- /Easy-Book/chapters/delete/special_topic.tex.depre: -------------------------------------------------------------------------------- 1 | \documentclass[../main-book.tex]{subfiles} 2 | \begin{document} 3 | 4 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 5 | %%%%%%%%%%%%%%%%%%%%%%% Pattern Matching%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7 | \chapter{String Pattern Matching} 8 | \label{chapter_pattern_matching} 9 | \subfile{chapters/part4/special_topics/string_matching} 10 | 11 | % \subfile{chapters/part4/special_topics/string_trie_tree_array} 12 | \section{LeetCode Problems} 13 | \begin{enumerate} 14 | \item 14. Longest Common Prefix (easy) 15 | \end{enumerate} 16 | \end{document} -------------------------------------------------------------------------------- /Easy-Book/chapters/delete/string_trie_tree_array.tex.prec: -------------------------------------------------------------------------------- 1 | \documentclass[string_matching.tex]{subfiles} 2 | \begin{document} 3 | 4 | %%%%%%%%%%%%Suffix Tree%%%%%%%%%%%%%%%% 5 | \subsection{Suffix Tree and Suffix Array} 6 | %A suffix tree is a compressed trie built on all |T| suffixes of T. with \$ appended. For example, if our text is the string T= banana\$, then our suffix tree will be built on {banana\$, anana\$, nana\$, ana\$, na\$, a\$}. The suffix starting at the ith index is denoted T[i:]. %For a non-leaf node of the suffix tree, define 7 | %the letter depth of the node as the length of the prefix stored in the node. 8 | Suffix Tree ans Suffix array are two efficient data structures related to string processing. Given a suffix trie T, and a string q, how can we answer the following questions: 9 | \begin{enumerate} 10 | \item determine whether q is a substring of T? 11 | \item check whether q is a suffix of T? 12 | \item count how many times q appears in T? 13 | \item find the longest repeat in T? 14 | \item find the longest common substring of T and q? 15 | \item find the longest palindromic substring in T. 16 | \end{enumerate} 17 | 18 | Given a string S = 'acacag\$', which uses \$ as the end symbol, with length 7 together with the end symbol. A \textit{suffix Trie} of S is a tree that contains all possible Suffixes of S as listed in the left figure. The Trie will have 7 total paths (leaf nodes), and each path from root to leaf represents suffix of the string. When two suffixes, e.g., 'cag\$' and 'cacag\$', shares the same first two vertices 'ca' before they split. The leaves we use the starting indices of the suffixes. The suffix Tree of S is a compressed trie of all suffixes shown in the right of the figure. 19 | \paragraph{Build Suffix Tree} 20 | The naive way of building suffix tree takes $O(n^2)$ to build the suffix tree for the string S of length n. The following are very abstract steps to build a suffix tree from given text. 21 | \begin{enumerate} 22 | \item Generate all suffixes of given text. 23 | \item Consider all suffixes as individual words and build a compressed trie. 24 | \end{enumerate} 25 | 26 | Building efficient suffix tree takes a lot of time and it is complex. Thus we use another data structures called Suffix Array, which has similar functionalities as suffix tree but way simpler to implement. Thus we focus on the suffix array instead in the following subsection. 27 | 28 | % Applications include: 29 | % \begin{enumerate} 30 | % \item Substring Check 31 | % \item Searching All Patterns 32 | % \item Longest Repeated Substring 33 | % \item Build Linear Time Suffix Array 34 | % \item Longest Common Substring 35 | % \item Longest Palindromic Substring 36 | % \end{enumerate} 37 | 38 | \paragraph{Suffix Array: Replacement of Suffix Tree} 39 | A suffix array is a sorted array of all suffixes of a given string. From the below figure we can see from left to right leaves, we have the suffix tree and suffix array similar. 40 | \paragraph{Naive Constructure: $O(n^2\log{n})$} A simple method to construct suffix array is to make an array of all suffixes and then sort the array. Following is implementation of simple method. Because the sorting takes $O(n\log{n})$, as every comparison is a comparison of two strings and the comparison takes $O(n)$ time, it makes the tatal time to be $O(n^2\log{n})$. 41 | \begin{lstlisting}[language=Python] 42 | import collections 43 | from operator import itemgetter 44 | def naiveSuffixArray(S): 45 | n = len(S) 46 | SA = collections.defaultdict(int) 47 | for i in range(n): 48 | SA[i] = S[i:] 49 | SA = sorted(SA.items(), key = lambda x:x[1]) #sort a dictionary by values 50 | return SA 51 | 52 | S = "acacag" 53 | print(naiveSuffixArray(S)) 54 | \end{lstlisting} 55 | 56 | \end{document} 57 | -------------------------------------------------------------------------------- /Easy-Book/chapters/mastering/array/interval.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/chapters/mastering/array/interval.tex -------------------------------------------------------------------------------- /Easy-Book/chapters/mastering/array/sweep_line.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../../main.tex]{subfiles} 2 | \begin{document} 3 | Sweep Line is a type of algorithm that mainly used to solve problems with intervals of one-dimensional. Let us look at one example: 4 | 1. 253. Meeting Rooms II 5 | 6 | Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of conference rooms required. 7 | \begin{lstlisting} 8 | Example 1: 9 | 10 | Input: [[0, 30],[5, 10],[15, 20]] 11 | Output: 2 12 | 13 | Example 2: 14 | 15 | Input: [[7,10],[2,4]] 16 | Output: 1 17 | \end{lstlisting} 18 | It would help a lot if at first we can draw one example with cooridinates. 19 | \begin{figure}[h] 20 | \centering 21 | \includegraphics[width = 0.6\columnwidth]{fig/sweep_line_253.png} 22 | \caption{Interval questions} 23 | \label{fig:interval} 24 | \end{figure} 25 | First, the simplest situation is when we only need one meeting room is there is no intersection between these time intervals. If we add one interval that only intersect with one of the previous intervals, this means we need two conference rooms. So to find the minimum conference rooms we need, we need to find the maximum number of intersection between these time intervals. The most native solution is to scan all the time slot in one for loop, and at another inner loop go through all the intervals, if this time slot is in this intervals, then we increase the minimum number of meeting room counter. This gives us time complexity of $O(n*m)$, where $n$ is the number of intervals and $m$ is the total number of time slots. The Python code is as follows, unfortunately, with this solution we have LTE error. 26 | \begin{lstlisting}[language = Python] 27 | # Definition for an interval. 28 | # class Interval(object): 29 | # def __init__(self, s=0, e=0): 30 | # self.start = s 31 | # self.end = e 32 | 33 | from collections import defaultdict 34 | from heapq import heappush, heappop 35 | from sys import maxint 36 | class Solution(object): 37 | def minMeetingRooms(self, intervals): 38 | """ 39 | :type intervals: List[Interval] 40 | :rtype: int 41 | """ 42 | if not intervals: 43 | return 0 44 | #solution 1, voting, time complexity is O(e1-s1), 71/77 test, TLE 45 | votes = defaultdict(int) 46 | num_rooms = 0 47 | for interval in intervals: 48 | s=interval.start 49 | e=interval.end 50 | for i in range(s+1,e+1): 51 | votes[i]+=1 52 | num_rooms = max(num_rooms, votes[i]) 53 | return num_rooms 54 | \end{lstlisting} 55 | \subsection{Speedup with Sweep Line} 56 | Now, let us see how to speed up this process. We can use Sweep Line method. For the sweep line, we have three basic implementations: one-dimensional, min-heap, or map based. 57 | \subsubsection{One-dimensional Implementation} 58 | To get the maximum number of intersection of all the intervals, it is not necessarily to scan all the time slots, how about just scan the key slot: the starts and ends . Thus, what we can do is to open an array and put all the start or end slot into the array, and with $1$ to mark it as start and $0$ to mark it as end. Then we sort this array. Till this point, how to get the maximum intersection? We go through this sorted array, if we get a start our current number of room needed will increase by one, otherwise, if we encounter an end slot, it means one meeting room is freed, thus we decrease the current on-going meeting room by one. We use another global variable to track the maximum number of rooms needed in this whole process. Great, because now our time complexity is decided by the number of slots $2n$, with the sorting algorithm, which makes the whole time complexity $O(nlogn)$ and space complexity $n$. This speeded up algorithm is called Sweep Line algorithm. Before we write our code, we better check the \textit{special cases}, what if there is one slot that is marked as start in one interval but is the end of another interval. This means we can not increase the counting at first, but we need to decrease, so that the sorting should be based on the first element of the tuple, and followed by the second element of the tuple. For example, the simple case $[[13,15],[1,13]]$, we only need maximum of one meeting room. Thus it can be implemented as: 59 | \begin{figure}[h] 60 | \centering 61 | \includegraphics[width=0.6\columnwidth]{fig/sweep_line_one_dimension.png} 62 | \caption{One-dimensional Sweep Line} 63 | \label{fig:one_dim_sl} 64 | \end{figure} 65 | \begin{lstlisting}[language=Python] 66 | def minMeetingRooms(self, intervals): 67 | if not intervals: 68 | return 0 69 | #solution 2 70 | slots = [] 71 | # put slots into one-dimensional axis 72 | for i in intervals: 73 | slots.append((i.start, 1)) 74 | slots.append((i.end, 0)) 75 | # sort these slots on this dimension 76 | #slots.sort(key = lambda x: (x[0], x[1])) 77 | slots.sort() 78 | 79 | # now execute the counting 80 | crt_room, max_room = 0, 0 81 | for s in slots: 82 | if s[1]==0: # if it ends, decrease 83 | crt_room-=1 84 | else: 85 | crt_room+=1 86 | max_room = max(max_room, crt_room) 87 | return max_room 88 | \end{lstlisting} 89 | \subsubsection{Min-heap Implementation} 90 | \begin{figure}[h] 91 | \centering 92 | \includegraphics[width=0.6\columnwidth]{fig/sweep_line_min_heap.png} 93 | \caption{Min-heap for Sweep Line} 94 | \label{fig:min_heap_sl} 95 | \end{figure} 96 | Instead of opening an array to save all the time slots, we can directly sort the intervals in the order of the start time. We can see Fig.~\ref{fig:min_heap_sl}, we go through the intervals and visit their end time, the first one we encounter is $30$, we put it in a min-heap, and then we visit the next interval $[5, 10]$, $5$ is smaller than the previous end time $30$, it means this interval intersected with a previous interval, so the number of maximum rooms increase $1$, we get $2$ rooms now. We put $10$ into the min-heap. Next, we visit $[15, 20]$, $15$ is larger than the first element in the min-heap $10$, it means that these two intervals can be merged into one $[5, 20]$, so we need to update the end time $10$ to $20$. 97 | 98 | This way, the time complexity is still the same which is decided by the sorting algorithm. While the space complexity is decided by real situation, it varies from $O(1)$ (no intersection) to $O(n)$ (all the meetings are intersected at at least one time slot). 99 | \begin{lstlisting}[language=Python] 100 | def minMeetingRooms(self, intervals): 101 | if not intervals: 102 | return 0 103 | #solution 2 104 | intervals.sort(key=lambda x:x.start) 105 | h = [intervals[0].end] 106 | rooms = 1 107 | for i in intervals[1:]: 108 | s,e=i.start, i.end 109 | e_before = h[0] 110 | if s& intervals) { 133 | map mp; 134 | for (auto val : intervals) { 135 | ++mp[val.start]; 136 | --mp[val.end]; 137 | } 138 | int max_room = 0, crt_room = 0; 139 | for (auto val : mp) { 140 | crt_room += val.second; 141 | max_room = max(max_room, crt_room); 142 | } 143 | return max_room; 144 | } 145 | }; 146 | \end{lstlisting} 147 | 148 | \subsection{LeetCode Problems} 149 | \begin{enumerate} 150 | \item \textbf{986. Interval List Intersections} Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order. Return the intersection of these two interval lists. 151 | \begin{lstlisting}[numbers=none] 152 | Input: A = [[0,2],[5,10],[13,23],[24,25]], B = [[1,5],[8,12],[15,24],[25,26]] 153 | Output: [[1,2],[5,5],[8,10],[15,23],[24,24],[25,25]] 154 | Reminder: The inputs and the desired output are lists of Interval objects, and not arrays or lists. 155 | \end{lstlisting} 156 | \end{enumerate} 157 | 158 | \end{document} -------------------------------------------------------------------------------- /Easy-Book/chapters/mastering/divide_conquer_questions.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../specific-algorithms.tex]{subfiles} 2 | \begin{document} 3 | \begin{examples} 4 | 5 | 6 | \item House Robber (198) 7 | 8 | Solution: If we use brute force is $O(2^n)$. Use divide and conquer, here because we use half and half. Which we need to get rid of. 9 | \begin{lstlisting}[language = Python] 10 | def rob(self, nums): 11 | """ 12 | :type nums: List[int] 13 | :rtype: int 14 | """ 15 | memo=[[-1 for _ in range(len(nums))] for _ in range(len(nums))] 16 | 17 | def dp(l,r): 18 | nonlocal memo 19 | if l==r: 20 | return nums[l] 21 | if l>r: 22 | return 0 23 | if l=k''' 70 | n1=len(nums1) 71 | n2=len(nums2) 72 | memo=[[[None for k in range(k+1)] for col in range(n2+1) ] for row in range(n1+1)] 73 | def dp(i,j,k): 74 | if k==0: 75 | return 0 76 | if memo[i][j][k] is None: 77 | max1,max2,max3=-1,-1,-1 78 | if i[0+6, 6–6=0, 0+4=4, 4–2=2, ] Set the first to 0+6, nums[i-1]+nums[i]. 123 | 124 | r = max(left\_subarray, right\_subarry, max(right\_subarry)-min(left\_subarray)), Thus, the real operation is max(right\_subarry)-min(left\_subarray). The time complexity would be decreased to $O(nlgn)$ from the brute force $O(n^2)$. So this example shows the divide and conquer. However, it might not be the best solution. Try the BCR with $O(n)$. 125 | \begin{lstlisting}[language=Python] 126 | class Solution(object): 127 | def maxProfit(self, prices): 128 | """ 129 | :type prices: List[int] 130 | :rtype: int 131 | """ 132 | if len(prices)<=1: 133 | return 0 134 | 135 | r = -maxint 136 | min_price = maxint 137 | for price in prices: 138 | if price= rods[i]: 95 | dp[j-rods[i]] = max(dp[j-rods[i]], old_dp[j]+min(rods[i], j)) 96 | else: 97 | dp[rods[i]-j] = max(dp[rods[i]-j], old_dp[j]+min(rods[i], j)) 98 | # blue arrow 99 | dp[j+rods[i]] = max(dp[j+rods[i]], old_dp[j]) 100 | # the red line is saved in dp indirectly 101 | return dp[0] 102 | \end{lstlisting} 103 | \end{examples} 104 | \end{document} -------------------------------------------------------------------------------- /Easy-Book/chapters/part3_deprc/introduction.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../algorithms.tex]{subfiles} 2 | \begin{document} 3 | % \chapter{Introduction} 4 | In this chapter, I will mainly discuss some problems so that we can see how different approaches and algorithms can make difference on the time and space complexity. 5 | \section{Maximum Subarray} 6 | LeetCode 53. Maximum Subarray 7 | 8 | Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array $[-2,1,-3,4,-1,2,1,-5,4]$, the contiguous subarray $[4,-1,2,1]$ has the largest sum = 6. 9 | \subsection{Brute Force} 10 | The brute force solution of this problem is to use two for loops, one pointer at the start position of the subarray, the other point at the end position of the subarray. Then we get the maximum sum of these subarries. The time complexity is $O(n^3)$, where we spent $O(n)$ to the sum of each subarray. The code is writen as: 11 | \begin{lstlisting}[language=Python] 12 | for i in range(n): 13 | for j in range(i+1,n): 14 | \end{lstlisting} 15 | However, if we can get the sum of each subarray with $O(1)$. Then we can lower the complexity to $O(n^2)$. Here one solution is to trade space for efficiency. the sum of subarray from index $i$ to $j$ is $sum(i,j)=sum(0,j)-sum(0,i)$. We can pre compute the accumulated sum to each index and save it in an array of the same size, which gives us $O(n^2)$ time complexity and $O(n)$ space complexity. 16 | \subsection{Divide and Conquer} 17 | To further improve the efficiency, we use divide and conquer, where we divide one array into two halves: the maximum subarray might located on the left size, or the right side, or some in the left side and some in the right size, which crossed the bound. $T(n) = max(T(left),T(right), T(cross))$, max is for merging and the T(cross) is for the case that the potential subarray across the mid point. For the complexity, $T(n)=2T(n/2)+n$, if we use the master method, it would give us $O(nlgn)$. With this solution, we use $O(lgn)$ space for the recursive function stack space. 18 | \begin{lstlisting}[language=Python] 19 | def maxSubArray(self, nums): 20 | """ 21 | :type nums: List[int] 22 | :rtype: int 23 | """ 24 | def getCrossMax(low,mid,high): 25 | left_sum,right_sum =0,0 26 | left_max, right_max = -maxint, -maxint 27 | left_i,right_j=-1,-1 28 | for i in xrange(mid,low-1,-1): #[) 29 | left_sum+=nums[i] 30 | if left_sum>left_max: 31 | left_max= left_sum 32 | left_i = i 33 | for j in xrange(mid+1,high+1): 34 | right_sum+=nums[j] 35 | if right_sum>right_max: 36 | right_max= right_sum 37 | right_j = j 38 | return (left_i,right_j,left_max+right_max) 39 | 40 | def maxSubarray(low,high): 41 | if low==high: 42 | return (low,high, nums[low]) 43 | mid = (low+high)//2 44 | rslt=[] 45 | #left_low, left_high, left_sum = maxSubarray(low,mid) #[low,mid] 46 | rslt.append(maxSubarray(low,mid)) #[low,mid] 47 | #right_low,right_high,right_sum = maxSubarray(mid+1,high)#[mid+1,high] 48 | rslt.append(maxSubarray(mid+1,high)) 49 | #cross_low,cross_high,cross_sum = getCrossMax(low, mid, high) 50 | rslt.append(getCrossMax(low, mid, high)) 51 | return max(rslt, key=lambda x: x[2]) 52 | return maxSubarray(0,len(nums)-1)[2] 53 | \end{lstlisting} 54 | \subsection{Dynamic Programming} 55 | Using dynamic programming: the $f$ memorize the maximum subarray value till $j$, $f[ j ] = max f [ j- 1] + S [ j ] , S [ j ]$. This would gave us $O(n)$ time complexity and $O(n)$ space complexity. 56 | \subsection{Greedy Algorithm} 57 | Because $sum(i,j)=sum(0,j)-sum(0,i)$, to till index $j$, we use $f(j)$ represents the maximum subarray value. which gives us relation $f(j) = sum(0,j)-min(Sum(0,i))_{i in [0,j] }, j>=1$ 58 | \subsection{Prefix Sum} 59 | convert this problem to best time to buy and sell stock problem. $[0, -2, -1, -4, 0, -1, 1, 2, -3, 1]$, which is to find the maximum benefit, => O(n), use prefix$\_$sum, the difference is we set prefix$\_$sum to 0 when it is smaller than 0, $O(n)$. Or we can try two pointers. 60 | \begin{lstlisting} 61 | from sys import maxint 62 | class Solution(object): 63 | def maxSubArray(self, nums): 64 | """ 65 | :type nums: List[int] 66 | :rtype: int 67 | """ 68 | max_so_far = -maxint - 1 69 | prefix_sum= 0 70 | for i in range(0, len(nums)): 71 | prefix_sum+= nums[i] 72 | if (max_so_far < prefix_sum): 73 | max_so_far = prefix_sum 74 | 75 | if prefix_sum< 0: 76 | prefix_sum= 0 77 | return max_so_far 78 | \end{lstlisting} 79 | From this problem, we get a peek how using different methods can gradually improve the algorithms' performance. 80 | 81 | \end{document} -------------------------------------------------------------------------------- /Easy-Book/chapters/part_complete_search_introduction.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex]{subfiles} 2 | \begin{document} 3 | Finding a solution to a problem in 4 | Computer Science and Artificial Intelligence is often thought 5 | as a process of search through the space of possible solutions (state space), either carried on some data strutcures, or calculated in the search space of a problem domain. 6 | 7 | \paragraph{Searching Strategies} In this part, we will first learn the basic searching algorithms carried out on explicit data strucutres in Chapter~\ref{chapter_basic_searching}. This will include: 8 | \begin{enumerate} 9 | \item General Searching Strategies 10 | \item Linear Search 11 | \item Tree Search 12 | \item Graph Search 13 | \end{enumerate} 14 | In this chapter, we only explain different strategies on explicitly defineded data structures to keep it simple and clean. The main purpose is to learn the fundamenal concepts and properties to lay the ground for the mode advanced algorithms. 15 | 16 | \paragraph{Uninformed search vs informed search} Searching can be categorized as \textbf{uninformed search} (also called \textbf{blind search}) and \textbf{informed search}(also called \textbf{heuristic search}) strategies. The uninformed search means that the strategies have no additional information about states beyond that provided in the problem definition. All they can do is to generate successors and distinguish a goal state from a non-goal state. And we categorize their strategies by the \textit{order} in which nodes are expanded. On the other hand, strategies that know whether one non-goal state is ``more promising" than another are the informed search. In this book, we only cover common uninformed search strategies. 17 | 18 | 19 | \paragraph{Advanced uninformed searching} learning the basics and knowing the properties, we can move on to more advanced uninformed searching techniques in Chapter~\ref{} that has better efficiency. The content will included: 20 | \begin{enumerate} 21 | \item Advanced Linear Searching such as Binary Search and Two-pointer technique; 22 | \item Recursive Backtracking: 23 | \item Bidirectional BFS. 24 | \end{enumerate} 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | \textbf{ Complete Search} and \textbf{partial search} are the two main branches in the Searching paradigm. 34 | 35 | Complete search is one that guarantees that if a path/solution to the goal/requirement exists, the algorithm will reach the goal given enough time, this is denoted as \textit{completeness}. Complete search is thought of as a \textit{universal solution} to problem solving. On the other hand, Partial Search a.k.a Local Search will not always find the correct or optimal solution if one exists because it usually sacrifice completeness for greater efficiency. 36 | 37 | In this part of this book, we will learn the Complete Search instead of the partial search due to its practicity solving the LeetCode Problems. The name ``Complete Search'' does not necessarily mean they are not efficient and a brute force solution all the time. For instance, the \textbf{backtracking} and \textbf{Bi-directional Search} they are more efficient that a brute force exhaustive search solutions. 38 | 39 | Complete Search algorithms can be categorized into: 40 | \begin{itemize} 41 | \item Explicit VS Virtual Search Space: Explicit complete search is carried on data structures, linear structures or non-linear data structures like graph/ trees. In Explicit Search, the search space size is the size of the targeting data structure size. We will need to find a sub-structure of the given data structure. Virtual space based search is to find a set of value assignments to certain variables that satisfy specific mathematical equations/inequations, or sometimes to maximize or minimiaze a certain function of these variables. This type of problems is known as \textbf{constraint satisfaction problem}. Such as backtracking an optimized search algorithms for virtual space. 42 | \item Linear VS Non-linear Complete Search: Linear search checks every record in a linear fashion, such as sliding window algorithm, binary search, sweep linear. On the other hand, Non-linear Search is applied on non-linear data structures and follows graph fashion. 43 | \item Iterative VS Recursive Search: For example, most linear search is iterative. Breath-first-search for graph and level-by-level search for trees are iterative too. Recursive Search are algorithms implemented with recursion, such as Depth-first-search for graph, or DFS based tree traversal, or backtracking. 44 | \end{itemize} 45 | 46 | \paragraph{How to Learn Complete Search?} Up till now, we have already learned the explicit complete search carried out on different data structures in Part~\ref{part_data_structure}. In this part, we will complete the complete search topic with more advanced and efficient searching algorithms applied either on real data structures or result space. Also, this part will give us more examples of how to apply the algorithm design methodogy as divide and conquer, use the basic data structures we learned before to design \textbf{complete search} algorithms with efficiency and elegance. 47 | 48 | \paragraph{Organization of Complete Search} This part follows the same organization as of Part~\ref{part_data_structure}, it is composed of linear search or non-linear search. For each type of algorithm, we will explain how to use it on cases like: explicit or virtual search space. 49 | 50 | \begin{itemize} 51 | \item Linear Search (Chapter~\ref{chapter_linear_searching}) which describes the common algorithms that carries on Linear data structures: Array, Linked List and String. 52 | \item Non-linear Search (Chapter~\ref{chapter_non_linear_searching}) encompasses the most common and basic search techniques for graph and tree data structures. The two most basic search techniques: Breadth-first-search and Depth-first-search serves as the basis to the following more advanced graph algorithms in the next chapter. 53 | \item Advanced Non-linear Search ( Chapter~\ref{chapter_advanced_non_linear_search}) includes more advanced concepts of graph and more advanced graph search algorithms that solve common problems defined in graph. The problems specifically we include are: Connected Components, topological sort, cycle detection, minimum spanning trees and shortest path related problems. 54 | \end{itemize} 55 | 56 | In this part, for graph algorithms, we will only cover medium level, and leave out the more advanced ones in Part~\ref{part_advanced_topics}. 57 | 58 | \paragraph{Searching Methodology} 59 | Before we head to more specific searching algorithms, we shall define the searching algorithm design methodology more clearer: 60 | 61 | 62 | \end{document} -------------------------------------------------------------------------------- /Easy-Book/chapters/preface.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/chapters/preface.pdf -------------------------------------------------------------------------------- /Easy-Book/chapters/preface.synctex.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/chapters/preface.synctex.gz -------------------------------------------------------------------------------- /Easy-Book/chapters/preface.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex]{subfiles} 2 | \begin{document} 3 | 4 | %%%%%%%%%%% 5 | % Preface % 6 | %%%%%%%%%%% 7 | \chapter*{Preface} 8 | Graduating with a Computer science or engineering degree? Converting from physics, or math, or any unrelated field to computer science? Dreaming of getting a job as a software engineer in game-playing companies such as Google, Facebook, Amazon, Microsoft, Oracle, LinkedIn, and so on? Unfortunately, there are the most challenging ``coding interview'' guarding the door to these top-notch tech companies. The interview process can be intimidating, with the interviewer scrutinizing every punch of your typing or scribbling on the whiteboard. Meanwhile, you are required to express whatever is on your mind to walk your interviewer through the design and analysis process and end the interview with clean and supposedly functional code. %I was one of you two years ago. 9 | 10 | What kind of weapons or martial arts do we need to toughen ourselves up so that we can knock down the ``watchdog'' and kick it in? By weapons and martial arts, I mean books and resources. Naturally, you pull out your first or second year college textbook \textit{Introduction to Algorithms} from bookshelf, dust it off, and are determined to read this $1000$-plus-pages massive book to refresh your brain with data structures, divide and conquer, dynamic programming, greedy algorithm and so on. If you are bit more knowledgeable, you would be able to find another widely used book--\textit{Cracking the Coding Interviews} and online coding websites--LeetCode and LintCode--to prepare. How much time do you think you need to put in? A month? Two months? Or three months? You would think after this, you are done with the interview, but for software engineers, it is not uncommon to switch companies frequently. Then you need to start the whole process again until you gain a free pass to ``coding interviews'' via becoming an experienced senior engineer or manager. %I was there 11 | 12 | I was in the exact same shoes. My first war started in the fall of 2015, continued for two months and ended without a single victory. I gave up the whole interview thing until two years ago when my life (I mean finances) situation demanded me to get an internship. This time, I got to know LeetCode and started to be more problem and practice driven from the beginning. `Cause God knows how much I did not want to redo this process, I naturally started to dig, summarize or create, and document problem-patterns, from sources such as both English and Chinese blogs, class slides, competitive programming guideline and so on. 13 | 14 | I found I was not content with just passing interviews. I wanted to seek the \textit{source} of the wisdom of algorithmic problem solving--the principles. I wanted to reorganize my continuously growing knowledge in algorithms in a way that is as clear and concise as possible. I wanted to attach math that closely relates to the topic of algorithmic problem solving, which would ease my nerves when reading related books. But meanwhile I tried to avoid getting too deep and theoretical which may potentially deviate me from the topic and adds more stress. All in all, we are not majoring in math, which is not ought to be easy; we use it as a practical tool, a powerful one! When it comes to data structures, I wanted to connect the \textit{abstract} structures to real Python objects and modules, so that when I'm using data structures in Python, I know the underlying data structures and their responding behaviors and efficiency. I felt more at ease seeing each particular algorithm explained with the source principle of algorithm design--\textit{why} it is so, instead of treating each as a standalone case and telling me ``what'' it is. %In all, I do not want to worship each algorithm like it's only genius-capable of invention. 15 | 16 | Three or four months in midst of the journey of searching for answers to the above ``wantes'', the idea of writing a book on this topic appeared in my mind. I did not do any market research, and did not know anything about writing a book. I just embarked on the boat, drifted along, and as I was farther and deeper in the ocean of writing the book, I realized how much work it can be. If you are reading this sometime in the future, then I landed. The long process is more of an \textit{agile} development in software engineering; knowledge, findings, and guidelines are added piece by piece, constantly going through revision. 17 | Yet, when I started to do research, I found that there are plenty of books out there focusing on either teaching algorithmic knowledge (\textit{Introduction to Algorithms}, \textit{Algorithmic Problem Solving}, etc) or introducing interview processes and solving interview problems(\textit{Cracking the Coding Interview}, \textit{Coding Interview Questions}, etc), but barely any that combines the two. This book naturally makes up this role in the categorization; learning the algorithmic problem solving by analyzing and practicing interview problems creates a reciprocal relationship--creating passion and confidence to make 1+1=4. 18 | 19 | What's my expectation? First, your feeling of enjoyment when reading and practicing along with the book is of the upmost importance to me. Second, I really wish that you would be able to sleep well right the night before the interview which proves that your investment both financially and timewise was worthwhile. 20 | % There is no way back, with the thought and the real action of writing a book with the all the features I wanted. It was onlyIt was only when kept reading, practicing, thinking, searching 21 | % Another thing, I I preferred to use real code and that I can run and play with conveniently instead of using pseudo-code. that I am inclined to grasp a well understanding of the algorithmic problem solving skills, categorizing problem-patterns, connecting conceptual data structures to Python modules, and documenting all these so that I won't need to repeat this tedious process ever again. I wanted to over-qualify so that I would be able to sleep tight before the interviews. 22 | 23 | % I started to document what I learned from either in English community or Chinese community in the blogs, until one day the idea of writing a book on this topic appears in my mind. I mean why not? There are plenty of books out there focusing on either teaching algorithmic knowledge (\textit{Introduction to Algorithms}, \textit{Algorithmic Problem Solving}, etc) or introducing interview process and solving interview problems(\textit{Cracking the Coding Interview}, \textit{Coding Interview Questions}, etc), but barely any that combines the two. This book naturally make up this role in the categorization; learning the algorithmic problem solving by analyzing and practicing interview problems -- a reciprocal relationship that makes 1+1=4: Algorithms, Interviews, Passion, and Confidence. 24 | 25 | In all, this is a book that unites the algorithmic problem solving, Coding Interviews, and Python objects and modules. I tried hard to do a good job. This book differs from books focusing on extracting the exact formulation of problems from the fuzzy and obscure world. We focus on learning the principle of algorithm design and analysis and practicing it using well-defined classical problems. This knowledge will also help you define a problem more easily in your job. 26 | 27 | % As one of you, these are the features that I want to see from a book to ease our nerves, and I wish it is what you want and what works for you too. 28 | % \begin{itemize} 29 | % \item 30 | % I want the book to tell me the fundamental principles of problem modeling and problem solving. That it starts with a global picture of algorithmic problem solving. In the search of the answer, I found it is hard, not many books try to seek the source of principles. 31 | % I want these principles to be well-explained but not too theoretical and comes with practice guideline. 32 | % \item I want to read real code, not pseudo-code. 33 | % \item I want to learn some math that can serves as a tool to learn the algorithm design and analysis, but not get too deep and theoretical that would deviate me from the main purpose. 34 | % \item 35 | % I want to learn data structures, and know how it is related to the programming languages. Connecting the dots between theoretical data structures and python modules. So when I'm really using a data structure, I have a clue of its underlying data structure, expected behavior and efficiency. 36 | % \item I want each particular algorithm explained with the principle algorithm design, not treating each as a standalone case. That would be a pain to treat them alone and learn one by one 37 | % \item I want a whole problem-pattern section, where problems are categorized and how each type can be solved is summarized and padded with real examples. 38 | % \item I do not want traditional book that comes with after class exercises (never really did it out of my will), practicing online and be competitive can be fun. 39 | % \end{itemize} 40 | 41 | 42 | % . 43 | 44 | % It is fair to say that most technical books are written by expert-already, that is kind of traditional software engineering, they first start to plot or design the requirement, write the book, and polishing. While, this book is different, it is a process from newbie to someone great (not saying experts, because once you learn more, you figure they are way more that are out of the scope) 45 | 46 | Li Yin 47 | 48 | \mbox{}\\ 49 | %\mbox{}\\ 50 | \noindent Li Yin \\ 51 | \noindent \url{http://liyinscience.com} 52 | 53 | 8/30/2019 54 | 55 | 56 | 57 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 58 | % Give credit where credit is due. % 59 | % Say thanks! % 60 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 61 | \section*{Acknowledgements} 62 | 63 | \end{document} 64 | -------------------------------------------------------------------------------- /Easy-Book/chapters/purged.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/chapters/purged.tex -------------------------------------------------------------------------------- /Easy-Book/chapters/reading_of_this_book.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main.tex]{subfiles} 2 | \begin{document} 3 | \section{move} 4 | 5 | 6 | \end{document} -------------------------------------------------------------------------------- /Easy-Book/chapters/solutions.tex: -------------------------------------------------------------------------------- 1 | \documentclass[../main-book.tex]{subfiles} 2 | \begin{document} 3 | % \begin{multicols}{2}\raggedcolumns 4 | \shipoutAnswer 5 | % \end{multicols} 6 | \end{document} -------------------------------------------------------------------------------- /Easy-Book/fig/250px-Sudoku-by-L2G-20050714.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/250px-Sudoku-by-L2G-20050714.png -------------------------------------------------------------------------------- /Easy-Book/fig/250px-Sudoku-by-L2G-20050714_solution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/250px-Sudoku-by-L2G-20050714_solution.png -------------------------------------------------------------------------------- /Easy-Book/fig/307_RSQ_SegmentTree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/307_RSQ_SegmentTree.png -------------------------------------------------------------------------------- /Easy-Book/fig/542px-Graph_theory_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/542px-Graph_theory_tree.png -------------------------------------------------------------------------------- /Easy-Book/fig/542px-Graph_theory_tree.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/542px-Graph_theory_tree.svg.png -------------------------------------------------------------------------------- /Easy-Book/fig/621_Task_Scheduler_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/621_Task_Scheduler_new.png -------------------------------------------------------------------------------- /Easy-Book/fig/8-queens.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/8-queens.png -------------------------------------------------------------------------------- /Easy-Book/fig/956-ep234.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/956-ep234.png -------------------------------------------------------------------------------- /Easy-Book/fig/956_dp_table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/956_dp_table.png -------------------------------------------------------------------------------- /Easy-Book/fig/Binary_Search_Depiction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/Binary_Search_Depiction.png -------------------------------------------------------------------------------- /Easy-Book/fig/Binary_search_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/Binary_search_tree.png -------------------------------------------------------------------------------- /Easy-Book/fig/Bipartite-Graph-Example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/Bipartite-Graph-Example.png -------------------------------------------------------------------------------- /Easy-Book/fig/BipartiteGraph_1000.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/BipartiteGraph_1000.gif -------------------------------------------------------------------------------- /Easy-Book/fig/BipartiteGraph_1000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/BipartiteGraph_1000.png -------------------------------------------------------------------------------- /Easy-Book/fig/DLL1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/DLL1.png -------------------------------------------------------------------------------- /Easy-Book/fig/DP_shortest_paths (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/DP_shortest_paths (1).png -------------------------------------------------------------------------------- /Easy-Book/fig/DP_shortest_paths (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/DP_shortest_paths (2).png -------------------------------------------------------------------------------- /Easy-Book/fig/DP_shortest_paths (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/DP_shortest_paths (3).png -------------------------------------------------------------------------------- /Easy-Book/fig/DP_shortest_paths.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/DP_shortest_paths.png -------------------------------------------------------------------------------- /Easy-Book/fig/Euler12-300x225.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/Euler12-300x225.png -------------------------------------------------------------------------------- /Easy-Book/fig/InsertionSort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/InsertionSort.png -------------------------------------------------------------------------------- /Easy-Book/fig/LIS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/LIS.png -------------------------------------------------------------------------------- /Easy-Book/fig/LIS_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/LIS_tree.png -------------------------------------------------------------------------------- /Easy-Book/fig/SCCUndirected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/SCCUndirected.png -------------------------------------------------------------------------------- /Easy-Book/fig/Sketch001.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/Sketch001.tif -------------------------------------------------------------------------------- /Easy-Book/fig/Sliding_window_property.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/Sliding_window_property.png -------------------------------------------------------------------------------- /Easy-Book/fig/Subproblem_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/Subproblem_graph.png -------------------------------------------------------------------------------- /Easy-Book/fig/TQoyH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/TQoyH.png -------------------------------------------------------------------------------- /Easy-Book/fig/Trie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/Trie.png -------------------------------------------------------------------------------- /Easy-Book/fig/activation_records.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/activation_records.jpg -------------------------------------------------------------------------------- /Easy-Book/fig/activation_records.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/activation_records.png -------------------------------------------------------------------------------- /Easy-Book/fig/all_path_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/all_path_demo.png -------------------------------------------------------------------------------- /Easy-Book/fig/all_paths.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/all_paths.png -------------------------------------------------------------------------------- /Easy-Book/fig/all_paths_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/all_paths_demo.png -------------------------------------------------------------------------------- /Easy-Book/fig/array_representation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/array_representation.png -------------------------------------------------------------------------------- /Easy-Book/fig/array_sorting_algorithms.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/array_sorting_algorithms.png -------------------------------------------------------------------------------- /Easy-Book/fig/back_tree_possibility.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/back_tree_possibility.png -------------------------------------------------------------------------------- /Easy-Book/fig/bellman-ford-D (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bellman-ford-D (2).png -------------------------------------------------------------------------------- /Easy-Book/fig/bellman-ford-D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bellman-ford-D.png -------------------------------------------------------------------------------- /Easy-Book/fig/bellman_ford_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bellman_ford_0.png -------------------------------------------------------------------------------- /Easy-Book/fig/bellman_ford_0_dag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bellman_ford_0_dag.png -------------------------------------------------------------------------------- /Easy-Book/fig/bellman_ford_0_tp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bellman_ford_0_tp.png -------------------------------------------------------------------------------- /Easy-Book/fig/bellman_ford_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bellman_ford_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/bellman_ford_1_dag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bellman_ford_1_dag.png -------------------------------------------------------------------------------- /Easy-Book/fig/bellman_ford_1_tp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bellman_ford_1_tp.png -------------------------------------------------------------------------------- /Easy-Book/fig/bellman_ford_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bellman_ford_2.png -------------------------------------------------------------------------------- /Easy-Book/fig/bellman_ford_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bellman_ford_3.png -------------------------------------------------------------------------------- /Easy-Book/fig/bellman_ford_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bellman_ford_4.png -------------------------------------------------------------------------------- /Easy-Book/fig/bfs_example_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bfs_example_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/bfs_free_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bfs_free_tree.png -------------------------------------------------------------------------------- /Easy-Book/fig/bfs_shortest_dis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bfs_shortest_dis.png -------------------------------------------------------------------------------- /Easy-Book/fig/bfs_vis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bfs_vis.png -------------------------------------------------------------------------------- /Easy-Book/fig/bidrectional_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bidrectional_search.png -------------------------------------------------------------------------------- /Easy-Book/fig/big_o_complexity_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/big_o_complexity_chart.png -------------------------------------------------------------------------------- /Easy-Book/fig/binary_search_lower_bound.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/binary_search_lower_bound.png -------------------------------------------------------------------------------- /Easy-Book/fig/binary_search_lower_upper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/binary_search_lower_upper.png -------------------------------------------------------------------------------- /Easy-Book/fig/binary_search_upper_bound.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/binary_search_upper_bound.png -------------------------------------------------------------------------------- /Easy-Book/fig/binary_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/binary_tree.png -------------------------------------------------------------------------------- /Easy-Book/fig/binary_tree1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/binary_tree1.png -------------------------------------------------------------------------------- /Easy-Book/fig/binary_tree_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/binary_tree_example.png -------------------------------------------------------------------------------- /Easy-Book/fig/branch_and_bound_backtracking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/branch_and_bound_backtracking.png -------------------------------------------------------------------------------- /Easy-Book/fig/branch_and_bound_best_first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/branch_and_bound_best_first.png -------------------------------------------------------------------------------- /Easy-Book/fig/breath_first_graph_search_process0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/breath_first_graph_search_process0.png -------------------------------------------------------------------------------- /Easy-Book/fig/breath_first_graph_search_process1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/breath_first_graph_search_process1.png -------------------------------------------------------------------------------- /Easy-Book/fig/breath_first_graph_search_process10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/breath_first_graph_search_process10.png -------------------------------------------------------------------------------- /Easy-Book/fig/breath_first_graph_search_process11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/breath_first_graph_search_process11.png -------------------------------------------------------------------------------- /Easy-Book/fig/breath_first_graph_search_process2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/breath_first_graph_search_process2.png -------------------------------------------------------------------------------- /Easy-Book/fig/breath_first_graph_search_process3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/breath_first_graph_search_process3.png -------------------------------------------------------------------------------- /Easy-Book/fig/breath_first_graph_search_process4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/breath_first_graph_search_process4.png -------------------------------------------------------------------------------- /Easy-Book/fig/breath_first_graph_search_process5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/breath_first_graph_search_process5.png -------------------------------------------------------------------------------- /Easy-Book/fig/breath_first_graph_search_process6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/breath_first_graph_search_process6.png -------------------------------------------------------------------------------- /Easy-Book/fig/breath_first_graph_search_process7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/breath_first_graph_search_process7.png -------------------------------------------------------------------------------- /Easy-Book/fig/breath_first_graph_search_process8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/breath_first_graph_search_process8.png -------------------------------------------------------------------------------- /Easy-Book/fig/breath_first_graph_search_process9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/breath_first_graph_search_process9.png -------------------------------------------------------------------------------- /Easy-Book/fig/breath_first_graph_search_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/breath_first_graph_search_tree.png -------------------------------------------------------------------------------- /Easy-Book/fig/brute_force_matching.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/brute_force_matching.png -------------------------------------------------------------------------------- /Easy-Book/fig/bst_duplicate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bst_duplicate.png -------------------------------------------------------------------------------- /Easy-Book/fig/bst_duplicate_counter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bst_duplicate_counter.png -------------------------------------------------------------------------------- /Easy-Book/fig/bst_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bst_example.png -------------------------------------------------------------------------------- /Easy-Book/fig/bst_insert_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bst_insert_9.png -------------------------------------------------------------------------------- /Easy-Book/fig/bst_insertion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bst_insertion.png -------------------------------------------------------------------------------- /Easy-Book/fig/bstdlloriginalbst.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bstdlloriginalbst.png -------------------------------------------------------------------------------- /Easy-Book/fig/bstdllreturndll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bstdllreturndll.png -------------------------------------------------------------------------------- /Easy-Book/fig/bubble_sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bubble_sort.png -------------------------------------------------------------------------------- /Easy-Book/fig/bubblepass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bubblepass.png -------------------------------------------------------------------------------- /Easy-Book/fig/bucket_sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/bucket_sort.png -------------------------------------------------------------------------------- /Easy-Book/fig/category_tag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/category_tag.png -------------------------------------------------------------------------------- /Easy-Book/fig/cc_directed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/cc_directed.png -------------------------------------------------------------------------------- /Easy-Book/fig/cc_undirected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/cc_undirected.png -------------------------------------------------------------------------------- /Easy-Book/fig/chapter_advanced_graph/DP_shortest_paths (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/chapter_advanced_graph/DP_shortest_paths (3).png -------------------------------------------------------------------------------- /Easy-Book/fig/chapter_advanced_graph/directed_cyclic_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/chapter_advanced_graph/directed_cyclic_graph.png -------------------------------------------------------------------------------- /Easy-Book/fig/chapter_advanced_graph/scc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/chapter_advanced_graph/scc.png -------------------------------------------------------------------------------- /Easy-Book/fig/chapter_advanced_graph/ts_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/chapter_advanced_graph/ts_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/chapter_advanced_graph/ts_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/chapter_advanced_graph/ts_2.png -------------------------------------------------------------------------------- /Easy-Book/fig/chapter_advanced_graph/undirected_cyclic_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/chapter_advanced_graph/undirected_cyclic_graph.png -------------------------------------------------------------------------------- /Easy-Book/fig/circular_linked_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/circular_linked_list.png -------------------------------------------------------------------------------- /Easy-Book/fig/circularlinkedlist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/circularlinkedlist.png -------------------------------------------------------------------------------- /Easy-Book/fig/climbing_stair.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/climbing_stair.png -------------------------------------------------------------------------------- /Easy-Book/fig/combination.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/combination.png -------------------------------------------------------------------------------- /Easy-Book/fig/combination_rslt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/combination_rslt.png -------------------------------------------------------------------------------- /Easy-Book/fig/common_data_structure_operations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/common_data_structure_operations.png -------------------------------------------------------------------------------- /Easy-Book/fig/complexity_cheatsheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/complexity_cheatsheet.png -------------------------------------------------------------------------------- /Easy-Book/fig/component_graph_vs_dfs_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/component_graph_vs_dfs_tree.png -------------------------------------------------------------------------------- /Easy-Book/fig/counting_sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/counting_sort.png -------------------------------------------------------------------------------- /Easy-Book/fig/counting_sort_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/counting_sort_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/cycle_detect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/cycle_detect.png -------------------------------------------------------------------------------- /Easy-Book/fig/cyclic_graph_searching.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/cyclic_graph_searching.png -------------------------------------------------------------------------------- /Easy-Book/fig/cyclic_shift.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/cyclic_shift.png -------------------------------------------------------------------------------- /Easy-Book/fig/data_structures.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/data_structures.png -------------------------------------------------------------------------------- /Easy-Book/fig/deep_copy_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/deep_copy_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/deep_copy_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/deep_copy_2.png -------------------------------------------------------------------------------- /Easy-Book/fig/deep_copy_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/deep_copy_3.png -------------------------------------------------------------------------------- /Easy-Book/fig/deep_copy_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/deep_copy_4.png -------------------------------------------------------------------------------- /Easy-Book/fig/deep_copy_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/deep_copy_5.png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_graph_search_edges(1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_graph_search_edges(1).png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_graph_search_edges.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_graph_search_edges.png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_graph_search_process0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_graph_search_process0.png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_graph_search_process1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_graph_search_process1.png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_graph_search_process10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_graph_search_process10.png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_graph_search_process11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_graph_search_process11.png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_graph_search_process2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_graph_search_process2.png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_graph_search_process3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_graph_search_process3.png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_graph_search_process4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_graph_search_process4.png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_graph_search_process5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_graph_search_process5.png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_graph_search_process6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_graph_search_process6.png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_graph_search_process7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_graph_search_process7.png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_graph_search_process8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_graph_search_process8.png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_graph_search_process9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_graph_search_process9.png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_graph_search_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_graph_search_tree.png -------------------------------------------------------------------------------- /Easy-Book/fig/depth_first_tree_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/depth_first_tree_search.png -------------------------------------------------------------------------------- /Easy-Book/fig/dfs_bfs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dfs_bfs.png -------------------------------------------------------------------------------- /Easy-Book/fig/dfs_procedure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dfs_procedure.png -------------------------------------------------------------------------------- /Easy-Book/fig/diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/diagram.png -------------------------------------------------------------------------------- /Easy-Book/fig/dijkstra_0.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dijkstra_0.5.png -------------------------------------------------------------------------------- /Easy-Book/fig/dijkstra_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dijkstra_0.png -------------------------------------------------------------------------------- /Easy-Book/fig/dijkstra_1.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dijkstra_1.5.png -------------------------------------------------------------------------------- /Easy-Book/fig/dijkstra_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dijkstra_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/dijkstra_2.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dijkstra_2.5.png -------------------------------------------------------------------------------- /Easy-Book/fig/dijkstra_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dijkstra_2.png -------------------------------------------------------------------------------- /Easy-Book/fig/dijkstra_3.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dijkstra_3.5.png -------------------------------------------------------------------------------- /Easy-Book/fig/dijkstra_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dijkstra_3.png -------------------------------------------------------------------------------- /Easy-Book/fig/dijkstra_4.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dijkstra_4.5.png -------------------------------------------------------------------------------- /Easy-Book/fig/dijkstra_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dijkstra_4.png -------------------------------------------------------------------------------- /Easy-Book/fig/dijkstra_process.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dijkstra_process.png -------------------------------------------------------------------------------- /Easy-Book/fig/dijkstra_proof.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dijkstra_proof.png -------------------------------------------------------------------------------- /Easy-Book/fig/directed_cyclic_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/directed_cyclic_graph.png -------------------------------------------------------------------------------- /Easy-Book/fig/directed_cyclic_graph_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/directed_cyclic_graph_2.png -------------------------------------------------------------------------------- /Easy-Book/fig/directed_graph_negative.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/directed_graph_negative.png -------------------------------------------------------------------------------- /Easy-Book/fig/directed_scc_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/directed_scc_example.png -------------------------------------------------------------------------------- /Easy-Book/fig/disjoint_set.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/disjoint_set.png -------------------------------------------------------------------------------- /Easy-Book/fig/divide_conquer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/divide_conquer.png -------------------------------------------------------------------------------- /Easy-Book/fig/divide_dynamic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/divide_dynamic.png -------------------------------------------------------------------------------- /Easy-Book/fig/dp_decision_table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dp_decision_table.png -------------------------------------------------------------------------------- /Easy-Book/fig/dynamic_programming_chapter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/dynamic_programming_chapter.png -------------------------------------------------------------------------------- /Easy-Book/fig/eight_bit_two_complement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/eight_bit_two_complement.png -------------------------------------------------------------------------------- /Easy-Book/fig/example_863.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/example_863.png -------------------------------------------------------------------------------- /Easy-Book/fig/example_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/example_graph.png -------------------------------------------------------------------------------- /Easy-Book/fig/example_undirected_directed_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/example_undirected_directed_graph.png -------------------------------------------------------------------------------- /Easy-Book/fig/fibanacci.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/fibanacci.png -------------------------------------------------------------------------------- /Easy-Book/fig/fibonacci_bfs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/fibonacci_bfs.png -------------------------------------------------------------------------------- /Easy-Book/fig/firstsplit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/firstsplit.png -------------------------------------------------------------------------------- /Easy-Book/fig/floyd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/floyd.png -------------------------------------------------------------------------------- /Easy-Book/fig/floyd_warshall_proof.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/floyd_warshall_proof.png -------------------------------------------------------------------------------- /Easy-Book/fig/four_umbreallas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/four_umbreallas.png -------------------------------------------------------------------------------- /Easy-Book/fig/free_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/free_tree.png -------------------------------------------------------------------------------- /Easy-Book/fig/free_tree_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/free_tree_search.png -------------------------------------------------------------------------------- /Easy-Book/fig/full_complete_perfect_binary_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/full_complete_perfect_binary_tree.png -------------------------------------------------------------------------------- /Easy-Book/fig/general_breath_first_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/general_breath_first_search.png -------------------------------------------------------------------------------- /Easy-Book/fig/general_depth_first_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/general_depth_first_search.png -------------------------------------------------------------------------------- /Easy-Book/fig/graph_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/graph_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/graph_cut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/graph_cut.png -------------------------------------------------------------------------------- /Easy-Book/fig/graph_representation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/graph_representation.png -------------------------------------------------------------------------------- /Easy-Book/fig/greedy_leetcode_diff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/greedy_leetcode_diff.png -------------------------------------------------------------------------------- /Easy-Book/fig/greedy_schedule_all_intervals_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/greedy_schedule_all_intervals_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/greedy_schedule_all_intervals__sort_count.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/greedy_schedule_all_intervals__sort_count.png -------------------------------------------------------------------------------- /Easy-Book/fig/greedy_schedule_all_intervals_good_sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/greedy_schedule_all_intervals_good_sort.png -------------------------------------------------------------------------------- /Easy-Book/fig/greedy_schedule_all_intervals_sorting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/greedy_schedule_all_intervals_sorting.png -------------------------------------------------------------------------------- /Easy-Book/fig/greedy_schedule_all_intervals_sorting_finish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/greedy_schedule_all_intervals_sorting_finish.png -------------------------------------------------------------------------------- /Easy-Book/fig/greedy_schedule_all_intervals_wrong_sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/greedy_schedule_all_intervals_wrong_sort.png -------------------------------------------------------------------------------- /Easy-Book/fig/guesswinner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/guesswinner.png -------------------------------------------------------------------------------- /Easy-Book/fig/hash_table_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/hash_table_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/hash_table_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/hash_table_2.png -------------------------------------------------------------------------------- /Easy-Book/fig/hashtable_chaining.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/hashtable_chaining.png -------------------------------------------------------------------------------- /Easy-Book/fig/heapify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/heapify.png -------------------------------------------------------------------------------- /Easy-Book/fig/histogram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/histogram.png -------------------------------------------------------------------------------- /Easy-Book/fig/insertcyclicafter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/insertcyclicafter.png -------------------------------------------------------------------------------- /Easy-Book/fig/insertcyclicbefore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/insertcyclicbefore.png -------------------------------------------------------------------------------- /Easy-Book/fig/insertion sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/insertion sort.png -------------------------------------------------------------------------------- /Easy-Book/fig/insertion_sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/insertion_sort.png -------------------------------------------------------------------------------- /Easy-Book/fig/iteration_recursion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/iteration_recursion.png -------------------------------------------------------------------------------- /Easy-Book/fig/iterative_tree_traversal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/iterative_tree_traversal.png -------------------------------------------------------------------------------- /Easy-Book/fig/iterative_tree_traversal_postorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/iterative_tree_traversal_postorder.png -------------------------------------------------------------------------------- /Easy-Book/fig/iterative_tree_traversal_preorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/iterative_tree_traversal_preorder.png -------------------------------------------------------------------------------- /Easy-Book/fig/kmp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/kmp.png -------------------------------------------------------------------------------- /Easy-Book/fig/kmp_lemma_proof.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/kmp_lemma_proof.png -------------------------------------------------------------------------------- /Easy-Book/fig/knight_dialer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/knight_dialer.png -------------------------------------------------------------------------------- /Easy-Book/fig/kosaraju_sccs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/kosaraju_sccs.png -------------------------------------------------------------------------------- /Easy-Book/fig/lcs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/lcs.png -------------------------------------------------------------------------------- /Easy-Book/fig/lcs_problem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/lcs_problem.png -------------------------------------------------------------------------------- /Easy-Book/fig/leetcode_discussion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/leetcode_discussion.png -------------------------------------------------------------------------------- /Easy-Book/fig/linked_list1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/linked_list1.png -------------------------------------------------------------------------------- /Easy-Book/fig/lookup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/lookup.jpg -------------------------------------------------------------------------------- /Easy-Book/fig/lookup_table.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/lookup_table.jpg -------------------------------------------------------------------------------- /Easy-Book/fig/lsd_radix_integer_sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/lsd_radix_integer_sort.png -------------------------------------------------------------------------------- /Easy-Book/fig/ltlp1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/ltlp1.png -------------------------------------------------------------------------------- /Easy-Book/fig/lumo_parition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/lumo_parition.png -------------------------------------------------------------------------------- /Easy-Book/fig/maximum_depth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/maximum_depth.png -------------------------------------------------------------------------------- /Easy-Book/fig/maxprofit_consecutive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/maxprofit_consecutive.png -------------------------------------------------------------------------------- /Easy-Book/fig/maxprofit_peak.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/maxprofit_peak.png -------------------------------------------------------------------------------- /Easy-Book/fig/merge2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/merge2.gif -------------------------------------------------------------------------------- /Easy-Book/fig/merge2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/merge2.png -------------------------------------------------------------------------------- /Easy-Book/fig/merge_sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/merge_sort.png -------------------------------------------------------------------------------- /Easy-Book/fig/mergesortA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/mergesortA.png -------------------------------------------------------------------------------- /Easy-Book/fig/mergesortB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/mergesortB.png -------------------------------------------------------------------------------- /Easy-Book/fig/mhz_640.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/mhz_640.jpg -------------------------------------------------------------------------------- /Easy-Book/fig/middle node of a given linked list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/middle node of a given linked list.png -------------------------------------------------------------------------------- /Easy-Book/fig/middle_of_linked_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/middle_of_linked_list.png -------------------------------------------------------------------------------- /Easy-Book/fig/min_climbing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/min_climbing.png -------------------------------------------------------------------------------- /Easy-Book/fig/min_heap_heapify_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/min_heap_heapify_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/min_heap_heapify_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/min_heap_heapify_2.png -------------------------------------------------------------------------------- /Easy-Book/fig/min_heap_heapify_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/min_heap_heapify_3.png -------------------------------------------------------------------------------- /Easy-Book/fig/min_heap_heapify_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/min_heap_heapify_4.png -------------------------------------------------------------------------------- /Easy-Book/fig/min_heap_heapify_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/min_heap_heapify_5.png -------------------------------------------------------------------------------- /Easy-Book/fig/min_heap_heapify_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/min_heap_heapify_6.png -------------------------------------------------------------------------------- /Easy-Book/fig/min_heap_heapify_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/min_heap_heapify_7.png -------------------------------------------------------------------------------- /Easy-Book/fig/min_heap_insert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/min_heap_insert.png -------------------------------------------------------------------------------- /Easy-Book/fig/min_heap_insert_step1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/min_heap_insert_step1.png -------------------------------------------------------------------------------- /Easy-Book/fig/min_heap_push.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/min_heap_push.bmp -------------------------------------------------------------------------------- /Easy-Book/fig/min_heap_push.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/min_heap_push.png -------------------------------------------------------------------------------- /Easy-Book/fig/min_path.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/min_path.png -------------------------------------------------------------------------------- /Easy-Book/fig/minimum_window_substring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/minimum_window_substring.png -------------------------------------------------------------------------------- /Easy-Book/fig/minimum_window_substring_process.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/minimum_window_substring_process.png -------------------------------------------------------------------------------- /Easy-Book/fig/monotone_stack_fig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/monotone_stack_fig.png -------------------------------------------------------------------------------- /Easy-Book/fig/msd_radix_string_sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/msd_radix_string_sort.png -------------------------------------------------------------------------------- /Easy-Book/fig/mst_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/mst_example.png -------------------------------------------------------------------------------- /Easy-Book/fig/mst_kruskal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/mst_kruskal.png -------------------------------------------------------------------------------- /Easy-Book/fig/mst_prim_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/mst_prim_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/mst_prim_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/mst_prim_2.png -------------------------------------------------------------------------------- /Easy-Book/fig/n-ary_binary_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/n-ary_binary_tree.png -------------------------------------------------------------------------------- /Easy-Book/fig/n_queen_diag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/n_queen_diag.png -------------------------------------------------------------------------------- /Easy-Book/fig/n_queen_four.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/n_queen_four.png -------------------------------------------------------------------------------- /Easy-Book/fig/n_queen_oddPicture1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/n_queen_oddPicture1.png -------------------------------------------------------------------------------- /Easy-Book/fig/n_queen_symmetry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/n_queen_symmetry.png -------------------------------------------------------------------------------- /Easy-Book/fig/naive_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/naive_graph.png -------------------------------------------------------------------------------- /Easy-Book/fig/notations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/notations.png -------------------------------------------------------------------------------- /Easy-Book/fig/palindromPartition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/palindromPartition.png -------------------------------------------------------------------------------- /Easy-Book/fig/partitionA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/partitionA.png -------------------------------------------------------------------------------- /Easy-Book/fig/path_cycle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/path_cycle.png -------------------------------------------------------------------------------- /Easy-Book/fig/permutation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/permutation.png -------------------------------------------------------------------------------- /Easy-Book/fig/permutation_repeat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/permutation_repeat.png -------------------------------------------------------------------------------- /Easy-Book/fig/permutation_rslt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/permutation_rslt.png -------------------------------------------------------------------------------- /Easy-Book/fig/permutation_swap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/permutation_swap.png -------------------------------------------------------------------------------- /Easy-Book/fig/prefixsum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/prefixsum.png -------------------------------------------------------------------------------- /Easy-Book/fig/preorder_traverse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/preorder_traverse.png -------------------------------------------------------------------------------- /Easy-Book/fig/problem_formulation_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/problem_formulation_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/problem_formulation_1_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/problem_formulation_1_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/problem_formulation_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/problem_formulation_2.png -------------------------------------------------------------------------------- /Easy-Book/fig/problem_formulation_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/problem_formulation_3.png -------------------------------------------------------------------------------- /Easy-Book/fig/problem_formulation_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/problem_formulation_4.png -------------------------------------------------------------------------------- /Easy-Book/fig/quicksort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/quicksort.png -------------------------------------------------------------------------------- /Easy-Book/fig/recursion_tree_non_overlap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/recursion_tree_non_overlap.png -------------------------------------------------------------------------------- /Easy-Book/fig/recursive_tree_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/recursive_tree_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/recursive_tree_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/recursive_tree_2.png -------------------------------------------------------------------------------- /Easy-Book/fig/rotated_array.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/rotated_array.png -------------------------------------------------------------------------------- /Easy-Book/fig/search_tree_dfs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/search_tree_dfs.png -------------------------------------------------------------------------------- /Easy-Book/fig/searchsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/searchsp.png -------------------------------------------------------------------------------- /Easy-Book/fig/segment_tree_construction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/segment_tree_construction.png -------------------------------------------------------------------------------- /Easy-Book/fig/segment_tree_range.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/segment_tree_range.png -------------------------------------------------------------------------------- /Easy-Book/fig/selectionSort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/selectionSort.png -------------------------------------------------------------------------------- /Easy-Book/fig/selection_sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/selection_sort.png -------------------------------------------------------------------------------- /Easy-Book/fig/shifing_pattern.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/shifing_pattern.png -------------------------------------------------------------------------------- /Easy-Book/fig/shortest_path_demo (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/shortest_path_demo (1).png -------------------------------------------------------------------------------- /Easy-Book/fig/shortest_path_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/shortest_path_demo.png -------------------------------------------------------------------------------- /Easy-Book/fig/shortest_path_dp_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/shortest_path_dp_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/shortest_path_property_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/shortest_path_property_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/shortest_path_trees_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/shortest_path_trees_0.png -------------------------------------------------------------------------------- /Easy-Book/fig/shortest_path_trees_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/shortest_path_trees_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/shortest_path_trees_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/shortest_path_trees_2.png -------------------------------------------------------------------------------- /Easy-Book/fig/shortest_path_trees_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/shortest_path_trees_3.png -------------------------------------------------------------------------------- /Easy-Book/fig/shortest_path_trees_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/shortest_path_trees_4.png -------------------------------------------------------------------------------- /Easy-Book/fig/skipping_rule_kmp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/skipping_rule_kmp.png -------------------------------------------------------------------------------- /Easy-Book/fig/sliding1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/sliding1.png -------------------------------------------------------------------------------- /Easy-Book/fig/stack_queue.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/stack_queue.gif -------------------------------------------------------------------------------- /Easy-Book/fig/stack_queue_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/stack_queue_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/subproblem_graph_merge_sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/subproblem_graph_merge_sort.png -------------------------------------------------------------------------------- /Easy-Book/fig/subsequence.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/subsequence.png -------------------------------------------------------------------------------- /Easy-Book/fig/subsequence_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/subsequence_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/subsequence_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/subsequence_2.png -------------------------------------------------------------------------------- /Easy-Book/fig/sudoku_backtracking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/sudoku_backtracking.png -------------------------------------------------------------------------------- /Easy-Book/fig/sudoku_grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/sudoku_grid.png -------------------------------------------------------------------------------- /Easy-Book/fig/summary_dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/summary_dp.png -------------------------------------------------------------------------------- /Easy-Book/fig/sweep_line_253.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/sweep_line_253.png -------------------------------------------------------------------------------- /Easy-Book/fig/sweep_line_min_heap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/sweep_line_min_heap.png -------------------------------------------------------------------------------- /Easy-Book/fig/sweep_line_one_dimension.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/sweep_line_one_dimension.png -------------------------------------------------------------------------------- /Easy-Book/fig/test_case_leetcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/test_case_leetcode.png -------------------------------------------------------------------------------- /Easy-Book/fig/time_complexity_sorting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/time_complexity_sorting.png -------------------------------------------------------------------------------- /Easy-Book/fig/topo_sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/topo_sort.png -------------------------------------------------------------------------------- /Easy-Book/fig/topo_sort_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/topo_sort_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/tree traversal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/tree traversal.png -------------------------------------------------------------------------------- /Easy-Book/fig/tree_graph_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/tree_graph_1.png -------------------------------------------------------------------------------- /Easy-Book/fig/tree_property.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/tree_property.png -------------------------------------------------------------------------------- /Easy-Book/fig/tree_traversal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/tree_traversal.png -------------------------------------------------------------------------------- /Easy-Book/fig/tree_word_break.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/tree_word_break.png -------------------------------------------------------------------------------- /Easy-Book/fig/trie_compact_trie.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/trie_compact_trie.jpg -------------------------------------------------------------------------------- /Easy-Book/fig/trie_pattern.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/trie_pattern.png -------------------------------------------------------------------------------- /Easy-Book/fig/tsp_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/tsp_graph.png -------------------------------------------------------------------------------- /Easy-Book/fig/two_pointers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/two_pointers.png -------------------------------------------------------------------------------- /Easy-Book/fig/ucs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/ucs.png -------------------------------------------------------------------------------- /Easy-Book/fig/undirected_cc_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/undirected_cc_example.png -------------------------------------------------------------------------------- /Easy-Book/fig/undirected_cyclic_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/undirected_cyclic_graph.png -------------------------------------------------------------------------------- /Easy-Book/fig/unique_path.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/unique_path.png -------------------------------------------------------------------------------- /Easy-Book/fig/word_break_139.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/word_break_139.png -------------------------------------------------------------------------------- /Easy-Book/fig/z_function.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/fig/z_function.png -------------------------------------------------------------------------------- /Easy-Book/main.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/main.pdf -------------------------------------------------------------------------------- /Easy-Book/main.synctex.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/Easy-Book/main.synctex.gz -------------------------------------------------------------------------------- /Easy-Book/refer.bib: -------------------------------------------------------------------------------- 1 | @book{cormen2009introduction, 2 | title={Introduction to algorithms}, 3 | author={Cormen, Thomas H}, 4 | year={2009}, 5 | publisher={MIT press} 6 | } 7 | @book{halim2013competitive, 8 | title={Competitive Programming 3}, 9 | author={Halim, Steven and Halim, Felix}, 10 | year={2013}, 11 | publisher={Lulu Independent Publish} 12 | } 13 | @book{slatkin2015effective, 14 | title={Effective Python: 59 Specific Ways to Write Better Python}, 15 | author={Slatkin, Brett}, 16 | year={2015}, 17 | publisher={Pearson Education} 18 | } 19 | 20 | @misc{bworld, 21 | author = {Hua hua jiang}, 22 | title = {{Leetcode blogs}}, 23 | howpublished = "\url{https://zxi.mytechroad.com/blog/category}", 24 | year = {2018}, 25 | note = "[Online; accessed 19-July-2018]" 26 | } 27 | 28 | @book{beazley2009python, 29 | title={Python essential reference}, 30 | author={Beazley, David M}, 31 | year={2009}, 32 | publisher={Addison-Wesley Professional} 33 | } 34 | 35 | @article{baka2017python, 36 | title={Python Data Structures and Algorithms: Improve application performance with graphs, stacks, and queues}, 37 | author={Baka, Benjamin}, 38 | year={2017}, 39 | publisher={Packt Publishing} 40 | } 41 | 42 | @misc{CP, 43 | title = {{Competitive Programming}}, 44 | howpublished = "\url{https://cp-algorithms.com/}", 45 | year = {2019}, 46 | note = "[Online; accessed 19-July-2018]" 47 | } 48 | 49 | @misc{cs_princeton, 50 | title = {{cs princeton}}, 51 | howpublished = "\url{https://aofa.cs.princeton.edu/60trees/}", 52 | year = {2019}, 53 | note = "[Online; accessed 19-July-2018]" 54 | } 55 | 56 | 57 | 58 | @book{skiena1998algorithm, 59 | title={The algorithm design manual: Text}, 60 | author={Skiena, Steven S}, 61 | volume={1}, 62 | year={1998}, 63 | publisher={Springer Science \& Business Media} 64 | } 65 | %%%%%%python 66 | @book{phillips2010python, 67 | title={Python 3 Object Oriented Programming}, 68 | author={Phillips, Dusty}, 69 | year={2010}, 70 | publisher={Packt Publishing Ltd} 71 | } 72 | 73 | 74 | 75 | %https://www2.cs.duke.edu/courses/fall05/cps234/notes/lecture07.pdf 76 | 77 | %https://cp-algorithms.com/ -------------------------------------------------------------------------------- /chapters_md/discrete_programming.md: -------------------------------------------------------------------------------- 1 | sfsfsfs -------------------------------------------------------------------------------- /chapters_pdf/Abstract_Data_Structures.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/chapters_pdf/Abstract_Data_Structures.pdf -------------------------------------------------------------------------------- /chapters_pdf/Python_Data_Structure.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/chapters_pdf/Python_Data_Structure.pdf -------------------------------------------------------------------------------- /chapters_pdf/advanced_search_on_linear_data_structures.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/chapters_pdf/advanced_search_on_linear_data_structures.pdf -------------------------------------------------------------------------------- /chapters_pdf/chapter_advanced_graph_algorithm.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/chapters_pdf/chapter_advanced_graph_algorithm.pdf -------------------------------------------------------------------------------- /chapters_pdf/combinatorial_search.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/chapters_pdf/combinatorial_search.pdf -------------------------------------------------------------------------------- /chapters_pdf/decrease_and_conquer.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/chapters_pdf/decrease_and_conquer.pdf -------------------------------------------------------------------------------- /chapters_pdf/search_strategies.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/chapters_pdf/search_strategies.pdf -------------------------------------------------------------------------------- /chapters_pdf/sorting_algorithms_with_python3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/chapters_pdf/sorting_algorithms_with_python3.pdf -------------------------------------------------------------------------------- /figures/book_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/figures/book_structure.png -------------------------------------------------------------------------------- /how_to_contribute.md: -------------------------------------------------------------------------------- 1 | # How to contribute to this project? 2 | The projects requires you to edit on Latex source file located in [Easy-Book](Easy-Book) folder. You can either set up a [local Visual Code environment for latex](https://dev.to/ucscmozilla/how-to-create-and-compile-latex-documents-on-visual-studio-code-3jbk), or you can directly use [Github Codespaces](https://github.com/features/codespaces). 3 | 4 | To submite a change, please use Pull Requests. 5 | 6 | ## What help is needed? 7 | 1. Content editing. 8 | 2. Better figure, if you know a better way to draw graph than using GraphViz, let me know. 9 | 3. Complete some chapters, including both theoretical and the problem patterns. 10 | 4. Improve the content. -------------------------------------------------------------------------------- /unorganized_pdf/backtracking.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/unorganized_pdf/backtracking.pdf -------------------------------------------------------------------------------- /unorganized_pdf/binary_search.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/unorganized_pdf/binary_search.pdf -------------------------------------------------------------------------------- /unorganized_pdf/bit manipulation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/unorganized_pdf/bit manipulation.pdf -------------------------------------------------------------------------------- /unorganized_pdf/heap_priority_queue.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/unorganized_pdf/heap_priority_queue.pdf -------------------------------------------------------------------------------- /unorganized_pdf/linear_data_structure.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/unorganized_pdf/linear_data_structure.pdf -------------------------------------------------------------------------------- /unorganized_pdf/tree_questions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/unorganized_pdf/tree_questions.pdf -------------------------------------------------------------------------------- /unorganized_pdf/two_pointer.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyin2015/python-coding-interview/f97739853abd6965d5128bbfbd5b402d445b4f40/unorganized_pdf/two_pointer.pdf -------------------------------------------------------------------------------- /unorganized_pdf/workspace.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": ".." 5 | }, 6 | { 7 | "path": "../../cv_ai_applications" 8 | } 9 | ], 10 | "settings": {} 11 | } --------------------------------------------------------------------------------