Copy disabled (too large)
Download .txt
Showing preview only (21,215K chars total). Download the full file to get everything.
Repository: krahets/hello-algo
Branch: main
Commit: edd13d4c861b
Files: 7125
Total size: 15.6 MB
Directory structure:
gitextract_4c8t4fps/
├── .gitattributes
├── .github/
│ ├── pull_request_template.md
│ └── workflows/
│ ├── c.yml
│ ├── cpp.yml
│ ├── dart.yml
│ ├── dotnet.yml
│ ├── go.yml
│ ├── java.yml
│ ├── javascript.yml
│ ├── kotlin.yml
│ ├── python.yml
│ ├── ruby.yml
│ ├── rust.yml
│ ├── swift.yml
│ └── typescript.yml
├── .gitignore
├── Dockerfile
├── LICENSE
├── README.md
├── codes/
│ ├── Dockerfile
│ ├── c/
│ │ ├── .gitignore
│ │ ├── CMakeLists.txt
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── array.c
│ │ │ ├── linked_list.c
│ │ │ └── my_list.c
│ │ ├── chapter_backtracking/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── n_queens.c
│ │ │ ├── permutations_i.c
│ │ │ ├── permutations_ii.c
│ │ │ ├── preorder_traversal_i_compact.c
│ │ │ ├── preorder_traversal_ii_compact.c
│ │ │ ├── preorder_traversal_iii_compact.c
│ │ │ ├── preorder_traversal_iii_template.c
│ │ │ ├── subset_sum_i.c
│ │ │ ├── subset_sum_i_naive.c
│ │ │ └── subset_sum_ii.c
│ │ ├── chapter_computational_complexity/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── iteration.c
│ │ │ ├── recursion.c
│ │ │ ├── space_complexity.c
│ │ │ ├── time_complexity.c
│ │ │ └── worst_best_time_complexity.c
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── binary_search_recur.c
│ │ │ ├── build_tree.c
│ │ │ └── hanota.c
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── climbing_stairs_backtrack.c
│ │ │ ├── climbing_stairs_constraint_dp.c
│ │ │ ├── climbing_stairs_dfs.c
│ │ │ ├── climbing_stairs_dfs_mem.c
│ │ │ ├── climbing_stairs_dp.c
│ │ │ ├── coin_change.c
│ │ │ ├── coin_change_ii.c
│ │ │ ├── edit_distance.c
│ │ │ ├── knapsack.c
│ │ │ ├── min_cost_climbing_stairs_dp.c
│ │ │ ├── min_path_sum.c
│ │ │ └── unbounded_knapsack.c
│ │ ├── chapter_graph/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── graph_adjacency_list.c
│ │ │ ├── graph_adjacency_list_test.c
│ │ │ ├── graph_adjacency_matrix.c
│ │ │ ├── graph_bfs.c
│ │ │ └── graph_dfs.c
│ │ ├── chapter_greedy/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── coin_change_greedy.c
│ │ │ ├── fractional_knapsack.c
│ │ │ ├── max_capacity.c
│ │ │ └── max_product_cutting.c
│ │ ├── chapter_hashing/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── array_hash_map.c
│ │ │ ├── hash_map_chaining.c
│ │ │ ├── hash_map_open_addressing.c
│ │ │ └── simple_hash.c
│ │ ├── chapter_heap/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── my_heap.c
│ │ │ ├── my_heap_test.c
│ │ │ └── top_k.c
│ │ ├── chapter_searching/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── binary_search.c
│ │ │ ├── binary_search_edge.c
│ │ │ ├── binary_search_insertion.c
│ │ │ └── two_sum.c
│ │ ├── chapter_sorting/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── bubble_sort.c
│ │ │ ├── bucket_sort.c
│ │ │ ├── counting_sort.c
│ │ │ ├── heap_sort.c
│ │ │ ├── insertion_sort.c
│ │ │ ├── merge_sort.c
│ │ │ ├── quick_sort.c
│ │ │ ├── radix_sort.c
│ │ │ └── selection_sort.c
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── array_deque.c
│ │ │ ├── array_queue.c
│ │ │ ├── array_stack.c
│ │ │ ├── linkedlist_deque.c
│ │ │ ├── linkedlist_queue.c
│ │ │ └── linkedlist_stack.c
│ │ ├── chapter_tree/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── array_binary_tree.c
│ │ │ ├── avl_tree.c
│ │ │ ├── binary_search_tree.c
│ │ │ ├── binary_tree.c
│ │ │ ├── binary_tree_bfs.c
│ │ │ └── binary_tree_dfs.c
│ │ └── utils/
│ │ ├── CMakeLists.txt
│ │ ├── common.h
│ │ ├── common_test.c
│ │ ├── list_node.h
│ │ ├── print_util.h
│ │ ├── tree_node.h
│ │ ├── uthash.h
│ │ ├── vector.h
│ │ └── vertex.h
│ ├── cpp/
│ │ ├── .gitignore
│ │ ├── CMakeLists.txt
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── array.cpp
│ │ │ ├── linked_list.cpp
│ │ │ ├── list.cpp
│ │ │ └── my_list.cpp
│ │ ├── chapter_backtracking/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── n_queens.cpp
│ │ │ ├── permutations_i.cpp
│ │ │ ├── permutations_ii.cpp
│ │ │ ├── preorder_traversal_i_compact.cpp
│ │ │ ├── preorder_traversal_ii_compact.cpp
│ │ │ ├── preorder_traversal_iii_compact.cpp
│ │ │ ├── preorder_traversal_iii_template.cpp
│ │ │ ├── subset_sum_i.cpp
│ │ │ ├── subset_sum_i_naive.cpp
│ │ │ └── subset_sum_ii.cpp
│ │ ├── chapter_computational_complexity/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── iteration.cpp
│ │ │ ├── recursion.cpp
│ │ │ ├── space_complexity.cpp
│ │ │ ├── time_complexity.cpp
│ │ │ └── worst_best_time_complexity.cpp
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── binary_search_recur.cpp
│ │ │ ├── build_tree.cpp
│ │ │ └── hanota.cpp
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── climbing_stairs_backtrack.cpp
│ │ │ ├── climbing_stairs_constraint_dp.cpp
│ │ │ ├── climbing_stairs_dfs.cpp
│ │ │ ├── climbing_stairs_dfs_mem.cpp
│ │ │ ├── climbing_stairs_dp.cpp
│ │ │ ├── coin_change.cpp
│ │ │ ├── coin_change_ii.cpp
│ │ │ ├── edit_distance.cpp
│ │ │ ├── knapsack.cpp
│ │ │ ├── min_cost_climbing_stairs_dp.cpp
│ │ │ ├── min_path_sum.cpp
│ │ │ └── unbounded_knapsack.cpp
│ │ ├── chapter_graph/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── graph_adjacency_list.cpp
│ │ │ ├── graph_adjacency_list_test.cpp
│ │ │ ├── graph_adjacency_matrix.cpp
│ │ │ ├── graph_bfs.cpp
│ │ │ └── graph_dfs.cpp
│ │ ├── chapter_greedy/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── coin_change_greedy.cpp
│ │ │ ├── fractional_knapsack.cpp
│ │ │ ├── max_capacity.cpp
│ │ │ └── max_product_cutting.cpp
│ │ ├── chapter_hashing/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── array_hash_map.cpp
│ │ │ ├── array_hash_map_test.cpp
│ │ │ ├── built_in_hash.cpp
│ │ │ ├── hash_map.cpp
│ │ │ ├── hash_map_chaining.cpp
│ │ │ ├── hash_map_open_addressing.cpp
│ │ │ └── simple_hash.cpp
│ │ ├── chapter_heap/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── heap.cpp
│ │ │ ├── my_heap.cpp
│ │ │ └── top_k.cpp
│ │ ├── chapter_searching/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── binary_search.cpp
│ │ │ ├── binary_search_edge.cpp
│ │ │ ├── binary_search_insertion.cpp
│ │ │ ├── hashing_search.cpp
│ │ │ ├── linear_search.cpp
│ │ │ └── two_sum.cpp
│ │ ├── chapter_sorting/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── bubble_sort.cpp
│ │ │ ├── bucket_sort.cpp
│ │ │ ├── counting_sort.cpp
│ │ │ ├── heap_sort.cpp
│ │ │ ├── insertion_sort.cpp
│ │ │ ├── merge_sort.cpp
│ │ │ ├── quick_sort.cpp
│ │ │ ├── radix_sort.cpp
│ │ │ └── selection_sort.cpp
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── array_deque.cpp
│ │ │ ├── array_queue.cpp
│ │ │ ├── array_stack.cpp
│ │ │ ├── deque.cpp
│ │ │ ├── linkedlist_deque.cpp
│ │ │ ├── linkedlist_queue.cpp
│ │ │ ├── linkedlist_stack.cpp
│ │ │ ├── queue.cpp
│ │ │ └── stack.cpp
│ │ ├── chapter_tree/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── array_binary_tree.cpp
│ │ │ ├── avl_tree.cpp
│ │ │ ├── binary_search_tree.cpp
│ │ │ ├── binary_tree.cpp
│ │ │ ├── binary_tree_bfs.cpp
│ │ │ └── binary_tree_dfs.cpp
│ │ └── utils/
│ │ ├── CMakeLists.txt
│ │ ├── common.hpp
│ │ ├── list_node.hpp
│ │ ├── print_utils.hpp
│ │ ├── tree_node.hpp
│ │ └── vertex.hpp
│ ├── csharp/
│ │ ├── .editorconfig
│ │ ├── .gitignore
│ │ ├── GlobalUsing.cs
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.cs
│ │ │ ├── linked_list.cs
│ │ │ ├── list.cs
│ │ │ └── my_list.cs
│ │ ├── chapter_backtracking/
│ │ │ ├── n_queens.cs
│ │ │ ├── permutations_i.cs
│ │ │ ├── permutations_ii.cs
│ │ │ ├── preorder_traversal_i_compact.cs
│ │ │ ├── preorder_traversal_ii_compact.cs
│ │ │ ├── preorder_traversal_iii_compact.cs
│ │ │ ├── preorder_traversal_iii_template.cs
│ │ │ ├── subset_sum_i.cs
│ │ │ ├── subset_sum_i_naive.cs
│ │ │ └── subset_sum_ii.cs
│ │ ├── chapter_computational_complexity/
│ │ │ ├── iteration.cs
│ │ │ ├── recursion.cs
│ │ │ ├── space_complexity.cs
│ │ │ ├── time_complexity.cs
│ │ │ └── worst_best_time_complexity.cs
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── binary_search_recur.cs
│ │ │ ├── build_tree.cs
│ │ │ └── hanota.cs
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── climbing_stairs_backtrack.cs
│ │ │ ├── climbing_stairs_constraint_dp.cs
│ │ │ ├── climbing_stairs_dfs.cs
│ │ │ ├── climbing_stairs_dfs_mem.cs
│ │ │ ├── climbing_stairs_dp.cs
│ │ │ ├── coin_change.cs
│ │ │ ├── coin_change_ii.cs
│ │ │ ├── edit_distance.cs
│ │ │ ├── knapsack.cs
│ │ │ ├── min_cost_climbing_stairs_dp.cs
│ │ │ ├── min_path_sum.cs
│ │ │ └── unbounded_knapsack.cs
│ │ ├── chapter_graph/
│ │ │ ├── graph_adjacency_list.cs
│ │ │ ├── graph_adjacency_matrix.cs
│ │ │ ├── graph_bfs.cs
│ │ │ └── graph_dfs.cs
│ │ ├── chapter_greedy/
│ │ │ ├── coin_change_greedy.cs
│ │ │ ├── fractional_knapsack.cs
│ │ │ ├── max_capacity.cs
│ │ │ └── max_product_cutting.cs
│ │ ├── chapter_hashing/
│ │ │ ├── array_hash_map.cs
│ │ │ ├── built_in_hash.cs
│ │ │ ├── hash_map.cs
│ │ │ ├── hash_map_chaining.cs
│ │ │ ├── hash_map_open_addressing.cs
│ │ │ └── simple_hash.cs
│ │ ├── chapter_heap/
│ │ │ ├── heap.cs
│ │ │ ├── my_heap.cs
│ │ │ └── top_k.cs
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.cs
│ │ │ ├── binary_search_edge.cs
│ │ │ ├── binary_search_insertion.cs
│ │ │ ├── hashing_search.cs
│ │ │ ├── linear_search.cs
│ │ │ └── two_sum.cs
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.cs
│ │ │ ├── bucket_sort.cs
│ │ │ ├── counting_sort.cs
│ │ │ ├── heap_sort.cs
│ │ │ ├── insertion_sort.cs
│ │ │ ├── merge_sort.cs
│ │ │ ├── quick_sort.cs
│ │ │ ├── radix_sort.cs
│ │ │ └── selection_sort.cs
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── array_deque.cs
│ │ │ ├── array_queue.cs
│ │ │ ├── array_stack.cs
│ │ │ ├── deque.cs
│ │ │ ├── linkedlist_deque.cs
│ │ │ ├── linkedlist_queue.cs
│ │ │ ├── linkedlist_stack.cs
│ │ │ ├── queue.cs
│ │ │ └── stack.cs
│ │ ├── chapter_tree/
│ │ │ ├── array_binary_tree.cs
│ │ │ ├── avl_tree.cs
│ │ │ ├── binary_search_tree.cs
│ │ │ ├── binary_tree.cs
│ │ │ ├── binary_tree_bfs.cs
│ │ │ └── binary_tree_dfs.cs
│ │ ├── csharp.sln
│ │ ├── hello-algo.csproj
│ │ └── utils/
│ │ ├── ListNode.cs
│ │ ├── PrintUtil.cs
│ │ ├── TreeNode.cs
│ │ └── Vertex.cs
│ ├── dart/
│ │ ├── build.dart
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.dart
│ │ │ ├── linked_list.dart
│ │ │ ├── list.dart
│ │ │ └── my_list.dart
│ │ ├── chapter_backtracking/
│ │ │ ├── n_queens.dart
│ │ │ ├── permutations_i.dart
│ │ │ ├── permutations_ii.dart
│ │ │ ├── preorder_traversal_i_compact.dart
│ │ │ ├── preorder_traversal_ii_compact.dart
│ │ │ ├── preorder_traversal_iii_compact.dart
│ │ │ ├── preorder_traversal_iii_template.dart
│ │ │ ├── subset_sum_i.dart
│ │ │ ├── subset_sum_i_naive.dart
│ │ │ └── subset_sum_ii.dart
│ │ ├── chapter_computational_complexity/
│ │ │ ├── iteration.dart
│ │ │ ├── recursion.dart
│ │ │ ├── space_complexity.dart
│ │ │ ├── time_complexity.dart
│ │ │ └── worst_best_time_complexity.dart
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── binary_search_recur.dart
│ │ │ ├── build_tree.dart
│ │ │ └── hanota.dart
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── climbing_stairs_backtrack.dart
│ │ │ ├── climbing_stairs_constraint_dp.dart
│ │ │ ├── climbing_stairs_dfs.dart
│ │ │ ├── climbing_stairs_dfs_mem.dart
│ │ │ ├── climbing_stairs_dp.dart
│ │ │ ├── coin_change.dart
│ │ │ ├── coin_change_ii.dart
│ │ │ ├── edit_distance.dart
│ │ │ ├── knapsack.dart
│ │ │ ├── min_cost_climbing_stairs_dp.dart
│ │ │ ├── min_path_sum.dart
│ │ │ └── unbounded_knapsack.dart
│ │ ├── chapter_graph/
│ │ │ ├── graph_adjacency_list.dart
│ │ │ ├── graph_adjacency_matrix.dart
│ │ │ ├── graph_bfs.dart
│ │ │ └── graph_dfs.dart
│ │ ├── chapter_greedy/
│ │ │ ├── coin_change_greedy.dart
│ │ │ ├── fractional_knapsack.dart
│ │ │ ├── max_capacity.dart
│ │ │ └── max_product_cutting.dart
│ │ ├── chapter_hashing/
│ │ │ ├── array_hash_map.dart
│ │ │ ├── built_in_hash.dart
│ │ │ ├── hash_map.dart
│ │ │ ├── hash_map_chaining.dart
│ │ │ ├── hash_map_open_addressing.dart
│ │ │ └── simple_hash.dart
│ │ ├── chapter_heap/
│ │ │ ├── my_heap.dart
│ │ │ └── top_k.dart
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.dart
│ │ │ ├── binary_search_edge.dart
│ │ │ ├── binary_search_insertion.dart
│ │ │ ├── hashing_search.dart
│ │ │ ├── linear_search.dart
│ │ │ └── two_sum.dart
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.dart
│ │ │ ├── bucket_sort.dart
│ │ │ ├── counting_sort.dart
│ │ │ ├── heap_sort.dart
│ │ │ ├── insertion_sort.dart
│ │ │ ├── merge_sort.dart
│ │ │ ├── quick_sort.dart
│ │ │ ├── radix_sort.dart
│ │ │ └── selection_sort.dart
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── array_deque.dart
│ │ │ ├── array_queue.dart
│ │ │ ├── array_stack.dart
│ │ │ ├── deque.dart
│ │ │ ├── linkedlist_deque.dart
│ │ │ ├── linkedlist_queue.dart
│ │ │ ├── linkedlist_stack.dart
│ │ │ ├── queue.dart
│ │ │ └── stack.dart
│ │ ├── chapter_tree/
│ │ │ ├── array_binary_tree.dart
│ │ │ ├── avl_tree.dart
│ │ │ ├── binary_search_tree.dart
│ │ │ ├── binary_tree.dart
│ │ │ ├── binary_tree_bfs.dart
│ │ │ └── binary_tree_dfs.dart
│ │ └── utils/
│ │ ├── list_node.dart
│ │ ├── print_util.dart
│ │ ├── tree_node.dart
│ │ └── vertex.dart
│ ├── docker-compose.yml
│ ├── go/
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.go
│ │ │ ├── array_test.go
│ │ │ ├── linked_list.go
│ │ │ ├── linked_list_test.go
│ │ │ ├── list_test.go
│ │ │ ├── my_list.go
│ │ │ └── my_list_test.go
│ │ ├── chapter_backtracking/
│ │ │ ├── n_queens.go
│ │ │ ├── n_queens_test.go
│ │ │ ├── permutation_test.go
│ │ │ ├── permutations_i.go
│ │ │ ├── permutations_ii.go
│ │ │ ├── preorder_traversal_i_compact.go
│ │ │ ├── preorder_traversal_ii_compact.go
│ │ │ ├── preorder_traversal_iii_compact.go
│ │ │ ├── preorder_traversal_iii_template.go
│ │ │ ├── preorder_traversal_test.go
│ │ │ ├── subset_sum_i.go
│ │ │ ├── subset_sum_i_naive.go
│ │ │ ├── subset_sum_ii.go
│ │ │ └── subset_sum_test.go
│ │ ├── chapter_computational_complexity/
│ │ │ ├── iteration.go
│ │ │ ├── iteration_test.go
│ │ │ ├── recursion.go
│ │ │ ├── recursion_test.go
│ │ │ ├── space_complexity.go
│ │ │ ├── space_complexity_test.go
│ │ │ ├── time_complexity.go
│ │ │ ├── time_complexity_test.go
│ │ │ ├── worst_best_time_complexity.go
│ │ │ └── worst_best_time_complexity_test.go
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── binary_search_recur.go
│ │ │ ├── binary_search_recur_test.go
│ │ │ ├── build_tree.go
│ │ │ ├── build_tree_test.go
│ │ │ ├── hanota.go
│ │ │ └── hanota_test.go
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── climbing_stairs_backtrack.go
│ │ │ ├── climbing_stairs_constraint_dp.go
│ │ │ ├── climbing_stairs_dfs.go
│ │ │ ├── climbing_stairs_dfs_mem.go
│ │ │ ├── climbing_stairs_dp.go
│ │ │ ├── climbing_stairs_test.go
│ │ │ ├── coin_change.go
│ │ │ ├── coin_change_ii.go
│ │ │ ├── coin_change_test.go
│ │ │ ├── edit_distance.go
│ │ │ ├── edit_distance_test.go
│ │ │ ├── knapsack.go
│ │ │ ├── knapsack_test.go
│ │ │ ├── min_cost_climbing_stairs_dp.go
│ │ │ ├── min_path_sum.go
│ │ │ ├── min_path_sum_test.go
│ │ │ └── unbounded_knapsack.go
│ │ ├── chapter_graph/
│ │ │ ├── graph_adjacency_list.go
│ │ │ ├── graph_adjacency_list_test.go
│ │ │ ├── graph_adjacency_matrix.go
│ │ │ ├── graph_adjacency_matrix_test.go
│ │ │ ├── graph_bfs.go
│ │ │ ├── graph_bfs_test.go
│ │ │ ├── graph_dfs.go
│ │ │ └── graph_dfs_test.go
│ │ ├── chapter_greedy/
│ │ │ ├── coin_change_greedy.go
│ │ │ ├── coin_change_greedy_test.go
│ │ │ ├── fractional_knapsack.go
│ │ │ ├── fractional_knapsack_test.go
│ │ │ ├── max_capacity.go
│ │ │ ├── max_capacity_test.go
│ │ │ ├── max_product_cutting.go
│ │ │ └── max_product_cutting_test.go
│ │ ├── chapter_hashing/
│ │ │ ├── array_hash_map.go
│ │ │ ├── array_hash_map_test.go
│ │ │ ├── hash_collision_test.go
│ │ │ ├── hash_map_chaining.go
│ │ │ ├── hash_map_open_addressing.go
│ │ │ ├── hash_map_test.go
│ │ │ └── simple_hash.go
│ │ ├── chapter_heap/
│ │ │ ├── heap.go
│ │ │ ├── heap_test.go
│ │ │ ├── my_heap.go
│ │ │ └── top_k.go
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.go
│ │ │ ├── binary_search_edge.go
│ │ │ ├── binary_search_insertion.go
│ │ │ ├── binary_search_test.go
│ │ │ ├── hashing_search.go
│ │ │ ├── hashing_search_test.go
│ │ │ ├── linear_search.go
│ │ │ ├── linear_search_test.go
│ │ │ ├── two_sum.go
│ │ │ └── two_sum_test.go
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.go
│ │ │ ├── bubble_sort_test.go
│ │ │ ├── bucket_sort.go
│ │ │ ├── bucket_sort_test.go
│ │ │ ├── counting_sort.go
│ │ │ ├── counting_sort_test.go
│ │ │ ├── heap_sort.go
│ │ │ ├── heap_sort_test.go
│ │ │ ├── insertion_sort.go
│ │ │ ├── insertion_sort_test.go
│ │ │ ├── merge_sort.go
│ │ │ ├── merge_sort_test.go
│ │ │ ├── quick_sort.go
│ │ │ ├── quick_sort_test.go
│ │ │ ├── radix_sort.go
│ │ │ ├── radix_sort_test.go
│ │ │ ├── selection_sort.go
│ │ │ └── selection_sort_test.go
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── array_deque.go
│ │ │ ├── array_queue.go
│ │ │ ├── array_stack.go
│ │ │ ├── deque_test.go
│ │ │ ├── linkedlist_deque.go
│ │ │ ├── linkedlist_queue.go
│ │ │ ├── linkedlist_stack.go
│ │ │ ├── queue_test.go
│ │ │ └── stack_test.go
│ │ ├── chapter_tree/
│ │ │ ├── array_binary_tree.go
│ │ │ ├── array_binary_tree_test.go
│ │ │ ├── avl_tree.go
│ │ │ ├── avl_tree_test.go
│ │ │ ├── binary_search_tree.go
│ │ │ ├── binary_search_tree_test.go
│ │ │ ├── binary_tree_bfs.go
│ │ │ ├── binary_tree_bfs_test.go
│ │ │ ├── binary_tree_dfs.go
│ │ │ ├── binary_tree_dfs_test.go
│ │ │ └── binary_tree_test.go
│ │ ├── go.mod
│ │ └── pkg/
│ │ ├── list_node.go
│ │ ├── list_node_test.go
│ │ ├── print_utils.go
│ │ ├── tree_node.go
│ │ ├── tree_node_test.go
│ │ └── vertex.go
│ ├── java/
│ │ ├── .gitignore
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.java
│ │ │ ├── linked_list.java
│ │ │ ├── list.java
│ │ │ └── my_list.java
│ │ ├── chapter_backtracking/
│ │ │ ├── n_queens.java
│ │ │ ├── permutations_i.java
│ │ │ ├── permutations_ii.java
│ │ │ ├── preorder_traversal_i_compact.java
│ │ │ ├── preorder_traversal_ii_compact.java
│ │ │ ├── preorder_traversal_iii_compact.java
│ │ │ ├── preorder_traversal_iii_template.java
│ │ │ ├── subset_sum_i.java
│ │ │ ├── subset_sum_i_naive.java
│ │ │ └── subset_sum_ii.java
│ │ ├── chapter_computational_complexity/
│ │ │ ├── iteration.java
│ │ │ ├── recursion.java
│ │ │ ├── space_complexity.java
│ │ │ ├── time_complexity.java
│ │ │ └── worst_best_time_complexity.java
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── binary_search_recur.java
│ │ │ ├── build_tree.java
│ │ │ └── hanota.java
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── climbing_stairs_backtrack.java
│ │ │ ├── climbing_stairs_constraint_dp.java
│ │ │ ├── climbing_stairs_dfs.java
│ │ │ ├── climbing_stairs_dfs_mem.java
│ │ │ ├── climbing_stairs_dp.java
│ │ │ ├── coin_change.java
│ │ │ ├── coin_change_ii.java
│ │ │ ├── edit_distance.java
│ │ │ ├── knapsack.java
│ │ │ ├── min_cost_climbing_stairs_dp.java
│ │ │ ├── min_path_sum.java
│ │ │ └── unbounded_knapsack.java
│ │ ├── chapter_graph/
│ │ │ ├── graph_adjacency_list.java
│ │ │ ├── graph_adjacency_matrix.java
│ │ │ ├── graph_bfs.java
│ │ │ └── graph_dfs.java
│ │ ├── chapter_greedy/
│ │ │ ├── coin_change_greedy.java
│ │ │ ├── fractional_knapsack.java
│ │ │ ├── max_capacity.java
│ │ │ └── max_product_cutting.java
│ │ ├── chapter_hashing/
│ │ │ ├── array_hash_map.java
│ │ │ ├── built_in_hash.java
│ │ │ ├── hash_map.java
│ │ │ ├── hash_map_chaining.java
│ │ │ ├── hash_map_open_addressing.java
│ │ │ └── simple_hash.java
│ │ ├── chapter_heap/
│ │ │ ├── heap.java
│ │ │ ├── my_heap.java
│ │ │ └── top_k.java
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.java
│ │ │ ├── binary_search_edge.java
│ │ │ ├── binary_search_insertion.java
│ │ │ ├── hashing_search.java
│ │ │ ├── linear_search.java
│ │ │ └── two_sum.java
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.java
│ │ │ ├── bucket_sort.java
│ │ │ ├── counting_sort.java
│ │ │ ├── heap_sort.java
│ │ │ ├── insertion_sort.java
│ │ │ ├── merge_sort.java
│ │ │ ├── quick_sort.java
│ │ │ ├── radix_sort.java
│ │ │ └── selection_sort.java
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── array_deque.java
│ │ │ ├── array_queue.java
│ │ │ ├── array_stack.java
│ │ │ ├── deque.java
│ │ │ ├── linkedlist_deque.java
│ │ │ ├── linkedlist_queue.java
│ │ │ ├── linkedlist_stack.java
│ │ │ ├── queue.java
│ │ │ └── stack.java
│ │ ├── chapter_tree/
│ │ │ ├── array_binary_tree.java
│ │ │ ├── avl_tree.java
│ │ │ ├── binary_search_tree.java
│ │ │ ├── binary_tree.java
│ │ │ ├── binary_tree_bfs.java
│ │ │ └── binary_tree_dfs.java
│ │ └── utils/
│ │ ├── ListNode.java
│ │ ├── PrintUtil.java
│ │ ├── TreeNode.java
│ │ └── Vertex.java
│ ├── javascript/
│ │ ├── .prettierrc
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.js
│ │ │ ├── linked_list.js
│ │ │ ├── list.js
│ │ │ └── my_list.js
│ │ ├── chapter_backtracking/
│ │ │ ├── n_queens.js
│ │ │ ├── permutations_i.js
│ │ │ ├── permutations_ii.js
│ │ │ ├── preorder_traversal_i_compact.js
│ │ │ ├── preorder_traversal_ii_compact.js
│ │ │ ├── preorder_traversal_iii_compact.js
│ │ │ ├── preorder_traversal_iii_template.js
│ │ │ ├── subset_sum_i.js
│ │ │ ├── subset_sum_i_naive.js
│ │ │ └── subset_sum_ii.js
│ │ ├── chapter_computational_complexity/
│ │ │ ├── iteration.js
│ │ │ ├── recursion.js
│ │ │ ├── space_complexity.js
│ │ │ ├── time_complexity.js
│ │ │ └── worst_best_time_complexity.js
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── binary_search_recur.js
│ │ │ ├── build_tree.js
│ │ │ └── hanota.js
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── climbing_stairs_backtrack.js
│ │ │ ├── climbing_stairs_constraint_dp.js
│ │ │ ├── climbing_stairs_dfs.js
│ │ │ ├── climbing_stairs_dfs_mem.js
│ │ │ ├── climbing_stairs_dp.js
│ │ │ ├── coin_change.js
│ │ │ ├── coin_change_ii.js
│ │ │ ├── edit_distance.js
│ │ │ ├── knapsack.js
│ │ │ ├── min_cost_climbing_stairs_dp.js
│ │ │ ├── min_path_sum.js
│ │ │ └── unbounded_knapsack.js
│ │ ├── chapter_graph/
│ │ │ ├── graph_adjacency_list.js
│ │ │ ├── graph_adjacency_matrix.js
│ │ │ ├── graph_bfs.js
│ │ │ └── graph_dfs.js
│ │ ├── chapter_greedy/
│ │ │ ├── coin_change_greedy.js
│ │ │ ├── fractional_knapsack.js
│ │ │ ├── max_capacity.js
│ │ │ └── max_product_cutting.js
│ │ ├── chapter_hashing/
│ │ │ ├── array_hash_map.js
│ │ │ ├── hash_map.js
│ │ │ ├── hash_map_chaining.js
│ │ │ ├── hash_map_open_addressing.js
│ │ │ └── simple_hash.js
│ │ ├── chapter_heap/
│ │ │ ├── my_heap.js
│ │ │ └── top_k.js
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.js
│ │ │ ├── binary_search_edge.js
│ │ │ ├── binary_search_insertion.js
│ │ │ ├── hashing_search.js
│ │ │ ├── linear_search.js
│ │ │ └── two_sum.js
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.js
│ │ │ ├── bucket_sort.js
│ │ │ ├── counting_sort.js
│ │ │ ├── heap_sort.js
│ │ │ ├── insertion_sort.js
│ │ │ ├── merge_sort.js
│ │ │ ├── quick_sort.js
│ │ │ ├── radix_sort.js
│ │ │ └── selection_sort.js
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── array_deque.js
│ │ │ ├── array_queue.js
│ │ │ ├── array_stack.js
│ │ │ ├── deque.js
│ │ │ ├── linkedlist_deque.js
│ │ │ ├── linkedlist_queue.js
│ │ │ ├── linkedlist_stack.js
│ │ │ ├── queue.js
│ │ │ └── stack.js
│ │ ├── chapter_tree/
│ │ │ ├── array_binary_tree.js
│ │ │ ├── avl_tree.js
│ │ │ ├── binary_search_tree.js
│ │ │ ├── binary_tree.js
│ │ │ ├── binary_tree_bfs.js
│ │ │ └── binary_tree_dfs.js
│ │ ├── modules/
│ │ │ ├── ListNode.js
│ │ │ ├── PrintUtil.js
│ │ │ ├── TreeNode.js
│ │ │ └── Vertex.js
│ │ └── test_all.js
│ ├── kotlin/
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.kt
│ │ │ ├── linked_list.kt
│ │ │ ├── list.kt
│ │ │ └── my_list.kt
│ │ ├── chapter_backtracking/
│ │ │ ├── n_queens.kt
│ │ │ ├── permutations_i.kt
│ │ │ ├── permutations_ii.kt
│ │ │ ├── preorder_traversal_i_compact.kt
│ │ │ ├── preorder_traversal_ii_compact.kt
│ │ │ ├── preorder_traversal_iii_compact.kt
│ │ │ ├── preorder_traversal_iii_template.kt
│ │ │ ├── subset_sum_i.kt
│ │ │ ├── subset_sum_i_naive.kt
│ │ │ └── subset_sum_ii.kt
│ │ ├── chapter_computational_complexity/
│ │ │ ├── iteration.kt
│ │ │ ├── recursion.kt
│ │ │ ├── space_complexity.kt
│ │ │ ├── time_complexity.kt
│ │ │ └── worst_best_time_complexity.kt
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── binary_search_recur.kt
│ │ │ ├── build_tree.kt
│ │ │ └── hanota.kt
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── climbing_stairs_backtrack.kt
│ │ │ ├── climbing_stairs_constraint_dp.kt
│ │ │ ├── climbing_stairs_dfs.kt
│ │ │ ├── climbing_stairs_dfs_mem.kt
│ │ │ ├── climbing_stairs_dp.kt
│ │ │ ├── coin_change.kt
│ │ │ ├── coin_change_ii.kt
│ │ │ ├── edit_distance.kt
│ │ │ ├── knapsack.kt
│ │ │ ├── min_cost_climbing_stairs_dp.kt
│ │ │ ├── min_path_sum.kt
│ │ │ └── unbounded_knapsack.kt
│ │ ├── chapter_graph/
│ │ │ ├── graph_adjacency_list.kt
│ │ │ ├── graph_adjacency_matrix.kt
│ │ │ ├── graph_bfs.kt
│ │ │ └── graph_dfs.kt
│ │ ├── chapter_greedy/
│ │ │ ├── coin_change_greedy.kt
│ │ │ ├── fractional_knapsack.kt
│ │ │ ├── max_capacity.kt
│ │ │ └── max_product_cutting.kt
│ │ ├── chapter_hashing/
│ │ │ ├── array_hash_map.kt
│ │ │ ├── built_in_hash.kt
│ │ │ ├── hash_map.kt
│ │ │ ├── hash_map_chaining.kt
│ │ │ ├── hash_map_open_addressing.kt
│ │ │ └── simple_hash.kt
│ │ ├── chapter_heap/
│ │ │ ├── heap.kt
│ │ │ ├── my_heap.kt
│ │ │ └── top_k.kt
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.kt
│ │ │ ├── binary_search_edge.kt
│ │ │ ├── binary_search_insertion.kt
│ │ │ ├── hashing_search.kt
│ │ │ ├── linear_search.kt
│ │ │ └── two_sum.kt
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.kt
│ │ │ ├── bucket_sort.kt
│ │ │ ├── counting_sort.kt
│ │ │ ├── heap_sort.kt
│ │ │ ├── insertion_sort.kt
│ │ │ ├── merge_sort.kt
│ │ │ ├── quick_sort.kt
│ │ │ ├── radix_sort.kt
│ │ │ └── selection_sort.kt
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── array_deque.kt
│ │ │ ├── array_queue.kt
│ │ │ ├── array_stack.kt
│ │ │ ├── deque.kt
│ │ │ ├── linkedlist_deque.kt
│ │ │ ├── linkedlist_queue.kt
│ │ │ ├── linkedlist_stack.kt
│ │ │ ├── queue.kt
│ │ │ └── stack.kt
│ │ ├── chapter_tree/
│ │ │ ├── array_binary_tree.kt
│ │ │ ├── avl_tree.kt
│ │ │ ├── binary_search_tree.kt
│ │ │ ├── binary_tree.kt
│ │ │ ├── binary_tree_bfs.kt
│ │ │ └── binary_tree_dfs.kt
│ │ └── utils/
│ │ ├── ListNode.kt
│ │ ├── PrintUtil.kt
│ │ ├── TreeNode.kt
│ │ └── Vertex.kt
│ ├── python/
│ │ ├── .gitignore
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.py
│ │ │ ├── linked_list.py
│ │ │ ├── list.py
│ │ │ └── my_list.py
│ │ ├── chapter_backtracking/
│ │ │ ├── n_queens.py
│ │ │ ├── permutations_i.py
│ │ │ ├── permutations_ii.py
│ │ │ ├── preorder_traversal_i_compact.py
│ │ │ ├── preorder_traversal_ii_compact.py
│ │ │ ├── preorder_traversal_iii_compact.py
│ │ │ ├── preorder_traversal_iii_template.py
│ │ │ ├── subset_sum_i.py
│ │ │ ├── subset_sum_i_naive.py
│ │ │ └── subset_sum_ii.py
│ │ ├── chapter_computational_complexity/
│ │ │ ├── iteration.py
│ │ │ ├── recursion.py
│ │ │ ├── space_complexity.py
│ │ │ ├── time_complexity.py
│ │ │ └── worst_best_time_complexity.py
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── binary_search_recur.py
│ │ │ ├── build_tree.py
│ │ │ └── hanota.py
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── climbing_stairs_backtrack.py
│ │ │ ├── climbing_stairs_constraint_dp.py
│ │ │ ├── climbing_stairs_dfs.py
│ │ │ ├── climbing_stairs_dfs_mem.py
│ │ │ ├── climbing_stairs_dp.py
│ │ │ ├── coin_change.py
│ │ │ ├── coin_change_ii.py
│ │ │ ├── edit_distance.py
│ │ │ ├── knapsack.py
│ │ │ ├── min_cost_climbing_stairs_dp.py
│ │ │ ├── min_path_sum.py
│ │ │ └── unbounded_knapsack.py
│ │ ├── chapter_graph/
│ │ │ ├── graph_adjacency_list.py
│ │ │ ├── graph_adjacency_matrix.py
│ │ │ ├── graph_bfs.py
│ │ │ └── graph_dfs.py
│ │ ├── chapter_greedy/
│ │ │ ├── coin_change_greedy.py
│ │ │ ├── fractional_knapsack.py
│ │ │ ├── max_capacity.py
│ │ │ └── max_product_cutting.py
│ │ ├── chapter_hashing/
│ │ │ ├── array_hash_map.py
│ │ │ ├── built_in_hash.py
│ │ │ ├── hash_map.py
│ │ │ ├── hash_map_chaining.py
│ │ │ ├── hash_map_open_addressing.py
│ │ │ └── simple_hash.py
│ │ ├── chapter_heap/
│ │ │ ├── heap.py
│ │ │ ├── my_heap.py
│ │ │ └── top_k.py
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.py
│ │ │ ├── binary_search_edge.py
│ │ │ ├── binary_search_insertion.py
│ │ │ ├── hashing_search.py
│ │ │ ├── linear_search.py
│ │ │ └── two_sum.py
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.py
│ │ │ ├── bucket_sort.py
│ │ │ ├── counting_sort.py
│ │ │ ├── heap_sort.py
│ │ │ ├── insertion_sort.py
│ │ │ ├── merge_sort.py
│ │ │ ├── quick_sort.py
│ │ │ ├── radix_sort.py
│ │ │ └── selection_sort.py
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── array_deque.py
│ │ │ ├── array_queue.py
│ │ │ ├── array_stack.py
│ │ │ ├── deque.py
│ │ │ ├── linkedlist_deque.py
│ │ │ ├── linkedlist_queue.py
│ │ │ ├── linkedlist_stack.py
│ │ │ ├── queue.py
│ │ │ └── stack.py
│ │ ├── chapter_tree/
│ │ │ ├── array_binary_tree.py
│ │ │ ├── avl_tree.py
│ │ │ ├── binary_search_tree.py
│ │ │ ├── binary_tree.py
│ │ │ ├── binary_tree_bfs.py
│ │ │ └── binary_tree_dfs.py
│ │ ├── modules/
│ │ │ ├── __init__.py
│ │ │ ├── list_node.py
│ │ │ ├── print_util.py
│ │ │ ├── tree_node.py
│ │ │ └── vertex.py
│ │ └── test_all.py
│ ├── pythontutor/
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.md
│ │ │ ├── linked_list.md
│ │ │ └── my_list.md
│ │ ├── chapter_backtracking/
│ │ │ ├── n_queens.md
│ │ │ ├── permutations_i.md
│ │ │ ├── permutations_ii.md
│ │ │ ├── preorder_traversal_i_compact.md
│ │ │ ├── preorder_traversal_ii_compact.md
│ │ │ ├── preorder_traversal_iii_compact.md
│ │ │ ├── preorder_traversal_iii_template.md
│ │ │ ├── subset_sum_i.md
│ │ │ ├── subset_sum_i_naive.md
│ │ │ └── subset_sum_ii.md
│ │ ├── chapter_computational_complexity/
│ │ │ ├── iteration.md
│ │ │ ├── recursion.md
│ │ │ ├── space_complexity.md
│ │ │ ├── time_complexity.md
│ │ │ └── worst_best_time_complexity.md
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── binary_search_recur.md
│ │ │ ├── build_tree.md
│ │ │ └── hanota.md
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── climbing_stairs_backtrack.md
│ │ │ ├── climbing_stairs_constraint_dp.md
│ │ │ ├── climbing_stairs_dfs.md
│ │ │ ├── climbing_stairs_dfs_mem.md
│ │ │ ├── climbing_stairs_dp.md
│ │ │ ├── coin_change.md
│ │ │ ├── coin_change_ii.md
│ │ │ ├── edit_distance.md
│ │ │ ├── knapsack.md
│ │ │ ├── min_cost_climbing_stairs_dp.md
│ │ │ ├── min_path_sum.md
│ │ │ └── unbounded_knapsack.md
│ │ ├── chapter_graph/
│ │ │ ├── graph_adjacency_list.md
│ │ │ ├── graph_adjacency_matrix.md
│ │ │ ├── graph_bfs.md
│ │ │ └── graph_dfs.md
│ │ ├── chapter_greedy/
│ │ │ ├── coin_change_greedy.md
│ │ │ ├── fractional_knapsack.md
│ │ │ ├── max_capacity.md
│ │ │ └── max_product_cutting.md
│ │ ├── chapter_hashing/
│ │ │ ├── array_hash_map.md
│ │ │ ├── hash_map_chaining.md
│ │ │ └── simple_hash.md
│ │ ├── chapter_heap/
│ │ │ ├── my_heap.md
│ │ │ └── top_k.md
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.md
│ │ │ ├── binary_search_edge.md
│ │ │ ├── binary_search_insertion.md
│ │ │ └── two_sum.md
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.md
│ │ │ ├── bucket_sort.md
│ │ │ ├── counting_sort.md
│ │ │ ├── heap_sort.md
│ │ │ ├── insertion_sort.md
│ │ │ ├── merge_sort.md
│ │ │ ├── quick_sort.md
│ │ │ ├── radix_sort.md
│ │ │ └── selection_sort.md
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── array_queue.md
│ │ │ ├── array_stack.md
│ │ │ ├── linkedlist_queue.md
│ │ │ └── linkedlist_stack.md
│ │ └── chapter_tree/
│ │ ├── array_binary_tree.md
│ │ ├── binary_search_tree.md
│ │ ├── binary_tree_bfs.md
│ │ └── binary_tree_dfs.md
│ ├── ruby/
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.rb
│ │ │ ├── linked_list.rb
│ │ │ ├── list.rb
│ │ │ └── my_list.rb
│ │ ├── chapter_backtracking/
│ │ │ ├── n_queens.rb
│ │ │ ├── permutations_i.rb
│ │ │ ├── permutations_ii.rb
│ │ │ ├── preorder_traversal_i_compact.rb
│ │ │ ├── preorder_traversal_ii_compact.rb
│ │ │ ├── preorder_traversal_iii_compact.rb
│ │ │ ├── preorder_traversal_iii_template.rb
│ │ │ ├── subset_sum_i.rb
│ │ │ ├── subset_sum_i_naive.rb
│ │ │ └── subset_sum_ii.rb
│ │ ├── chapter_computational_complexity/
│ │ │ ├── iteration.rb
│ │ │ ├── recursion.rb
│ │ │ ├── space_complexity.rb
│ │ │ ├── time_complexity.rb
│ │ │ └── worst_best_time_complexity.rb
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── binary_search_recur.rb
│ │ │ ├── build_tree.rb
│ │ │ └── hanota.rb
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── climbing_stairs_backtrack.rb
│ │ │ ├── climbing_stairs_constraint_dp.rb
│ │ │ ├── climbing_stairs_dfs.rb
│ │ │ ├── climbing_stairs_dfs_mem.rb
│ │ │ ├── climbing_stairs_dp.rb
│ │ │ ├── coin_change.rb
│ │ │ ├── coin_change_ii.rb
│ │ │ ├── edit_distance.rb
│ │ │ ├── knapsack.rb
│ │ │ ├── min_cost_climbing_stairs_dp.rb
│ │ │ ├── min_path_sum.rb
│ │ │ └── unbounded_knapsack.rb
│ │ ├── chapter_graph/
│ │ │ ├── graph_adjacency_list.rb
│ │ │ ├── graph_adjacency_matrix.rb
│ │ │ ├── graph_bfs.rb
│ │ │ └── graph_dfs.rb
│ │ ├── chapter_greedy/
│ │ │ ├── coin_change_greedy.rb
│ │ │ ├── fractional_knapsack.rb
│ │ │ ├── max_capacity.rb
│ │ │ └── max_product_cutting.rb
│ │ ├── chapter_hashing/
│ │ │ ├── array_hash_map.rb
│ │ │ ├── built_in_hash.rb
│ │ │ ├── hash_map.rb
│ │ │ ├── hash_map_chaining.rb
│ │ │ ├── hash_map_open_addressing.rb
│ │ │ └── simple_hash.rb
│ │ ├── chapter_heap/
│ │ │ ├── my_heap.rb
│ │ │ └── top_k.rb
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.rb
│ │ │ ├── binary_search_edge.rb
│ │ │ ├── binary_search_insertion.rb
│ │ │ ├── hashing_search.rb
│ │ │ ├── linear_search.rb
│ │ │ └── two_sum.rb
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.rb
│ │ │ ├── bucket_sort.rb
│ │ │ ├── counting_sort.rb
│ │ │ ├── heap_sort.rb
│ │ │ ├── insertion_sort.rb
│ │ │ ├── merge_sort.rb
│ │ │ ├── quick_sort.rb
│ │ │ ├── radix_sort.rb
│ │ │ └── selection_sort.rb
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── array_deque.rb
│ │ │ ├── array_queue.rb
│ │ │ ├── array_stack.rb
│ │ │ ├── deque.rb
│ │ │ ├── linkedlist_deque.rb
│ │ │ ├── linkedlist_queue.rb
│ │ │ ├── linkedlist_stack.rb
│ │ │ ├── queue.rb
│ │ │ └── stack.rb
│ │ ├── chapter_tree/
│ │ │ ├── array_binary_tree.rb
│ │ │ ├── avl_tree.rb
│ │ │ ├── binary_search_tree.rb
│ │ │ ├── binary_tree.rb
│ │ │ ├── binary_tree_bfs.rb
│ │ │ └── binary_tree_dfs.rb
│ │ ├── test_all.rb
│ │ └── utils/
│ │ ├── list_node.rb
│ │ ├── print_util.rb
│ │ ├── tree_node.rb
│ │ └── vertex.rb
│ ├── rust/
│ │ ├── .gitignore
│ │ ├── Cargo.toml
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.rs
│ │ │ ├── linked_list.rs
│ │ │ ├── list.rs
│ │ │ └── my_list.rs
│ │ ├── chapter_backtracking/
│ │ │ ├── n_queens.rs
│ │ │ ├── permutations_i.rs
│ │ │ ├── permutations_ii.rs
│ │ │ ├── preorder_traversal_i_compact.rs
│ │ │ ├── preorder_traversal_ii_compact.rs
│ │ │ ├── preorder_traversal_iii_compact.rs
│ │ │ ├── preorder_traversal_iii_template.rs
│ │ │ ├── subset_sum_i.rs
│ │ │ ├── subset_sum_i_naive.rs
│ │ │ └── subset_sum_ii.rs
│ │ ├── chapter_computational_complexity/
│ │ │ ├── iteration.rs
│ │ │ ├── recursion.rs
│ │ │ ├── space_complexity.rs
│ │ │ ├── time_complexity.rs
│ │ │ └── worst_best_time_complexity.rs
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── binary_search_recur.rs
│ │ │ ├── build_tree.rs
│ │ │ └── hanota.rs
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── climbing_stairs_backtrack.rs
│ │ │ ├── climbing_stairs_constraint_dp.rs
│ │ │ ├── climbing_stairs_dfs.rs
│ │ │ ├── climbing_stairs_dfs_mem.rs
│ │ │ ├── climbing_stairs_dp.rs
│ │ │ ├── coin_change.rs
│ │ │ ├── coin_change_ii.rs
│ │ │ ├── edit_distance.rs
│ │ │ ├── knapsack.rs
│ │ │ ├── min_cost_climbing_stairs_dp.rs
│ │ │ ├── min_path_sum.rs
│ │ │ └── unbounded_knapsack.rs
│ │ ├── chapter_graph/
│ │ │ ├── graph_adjacency_list.rs
│ │ │ ├── graph_adjacency_matrix.rs
│ │ │ ├── graph_bfs.rs
│ │ │ └── graph_dfs.rs
│ │ ├── chapter_greedy/
│ │ │ ├── coin_change_greedy.rs
│ │ │ ├── fractional_knapsack.rs
│ │ │ ├── max_capacity.rs
│ │ │ └── max_product_cutting.rs
│ │ ├── chapter_hashing/
│ │ │ ├── array_hash_map.rs
│ │ │ ├── build_in_hash.rs
│ │ │ ├── hash_map.rs
│ │ │ ├── hash_map_chaining.rs
│ │ │ ├── hash_map_open_addressing.rs
│ │ │ └── simple_hash.rs
│ │ ├── chapter_heap/
│ │ │ ├── heap.rs
│ │ │ ├── my_heap.rs
│ │ │ └── top_k.rs
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.rs
│ │ │ ├── binary_search_edge.rs
│ │ │ ├── binary_search_insertion.rs
│ │ │ ├── hashing_search.rs
│ │ │ ├── linear_search.rs
│ │ │ └── two_sum.rs
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.rs
│ │ │ ├── bucket_sort.rs
│ │ │ ├── counting_sort.rs
│ │ │ ├── heap_sort.rs
│ │ │ ├── insertion_sort.rs
│ │ │ ├── merge_sort.rs
│ │ │ ├── quick_sort.rs
│ │ │ ├── radix_sort.rs
│ │ │ └── selection_sort.rs
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── array_deque.rs
│ │ │ ├── array_queue.rs
│ │ │ ├── array_stack.rs
│ │ │ ├── deque.rs
│ │ │ ├── linkedlist_deque.rs
│ │ │ ├── linkedlist_queue.rs
│ │ │ ├── linkedlist_stack.rs
│ │ │ ├── queue.rs
│ │ │ └── stack.rs
│ │ ├── chapter_tree/
│ │ │ ├── array_binary_tree.rs
│ │ │ ├── avl_tree.rs
│ │ │ ├── binary_search_tree.rs
│ │ │ ├── binary_tree.rs
│ │ │ ├── binary_tree_bfs.rs
│ │ │ └── binary_tree_dfs.rs
│ │ └── src/
│ │ ├── include/
│ │ │ ├── list_node.rs
│ │ │ ├── mod.rs
│ │ │ ├── print_util.rs
│ │ │ ├── tree_node.rs
│ │ │ └── vertex.rs
│ │ └── lib.rs
│ ├── swift/
│ │ ├── .gitignore
│ │ ├── Package.resolved
│ │ ├── Package.swift
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.swift
│ │ │ ├── linked_list.swift
│ │ │ ├── list.swift
│ │ │ └── my_list.swift
│ │ ├── chapter_backtracking/
│ │ │ ├── n_queens.swift
│ │ │ ├── permutations_i.swift
│ │ │ ├── permutations_ii.swift
│ │ │ ├── preorder_traversal_i_compact.swift
│ │ │ ├── preorder_traversal_ii_compact.swift
│ │ │ ├── preorder_traversal_iii_compact.swift
│ │ │ ├── preorder_traversal_iii_template.swift
│ │ │ ├── subset_sum_i.swift
│ │ │ ├── subset_sum_i_naive.swift
│ │ │ └── subset_sum_ii.swift
│ │ ├── chapter_computational_complexity/
│ │ │ ├── iteration.swift
│ │ │ ├── recursion.swift
│ │ │ ├── space_complexity.swift
│ │ │ ├── time_complexity.swift
│ │ │ └── worst_best_time_complexity.swift
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── binary_search_recur.swift
│ │ │ ├── build_tree.swift
│ │ │ └── hanota.swift
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── climbing_stairs_backtrack.swift
│ │ │ ├── climbing_stairs_constraint_dp.swift
│ │ │ ├── climbing_stairs_dfs.swift
│ │ │ ├── climbing_stairs_dfs_mem.swift
│ │ │ ├── climbing_stairs_dp.swift
│ │ │ ├── coin_change.swift
│ │ │ ├── coin_change_ii.swift
│ │ │ ├── edit_distance.swift
│ │ │ ├── knapsack.swift
│ │ │ ├── min_cost_climbing_stairs_dp.swift
│ │ │ ├── min_path_sum.swift
│ │ │ └── unbounded_knapsack.swift
│ │ ├── chapter_graph/
│ │ │ ├── graph_adjacency_list.swift
│ │ │ ├── graph_adjacency_matrix.swift
│ │ │ ├── graph_bfs.swift
│ │ │ └── graph_dfs.swift
│ │ ├── chapter_greedy/
│ │ │ ├── coin_change_greedy.swift
│ │ │ ├── fractional_knapsack.swift
│ │ │ ├── max_capacity.swift
│ │ │ └── max_product_cutting.swift
│ │ ├── chapter_hashing/
│ │ │ ├── array_hash_map.swift
│ │ │ ├── built_in_hash.swift
│ │ │ ├── hash_map.swift
│ │ │ ├── hash_map_chaining.swift
│ │ │ ├── hash_map_open_addressing.swift
│ │ │ └── simple_hash.swift
│ │ ├── chapter_heap/
│ │ │ ├── heap.swift
│ │ │ ├── my_heap.swift
│ │ │ └── top_k.swift
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.swift
│ │ │ ├── binary_search_edge.swift
│ │ │ ├── binary_search_insertion.swift
│ │ │ ├── hashing_search.swift
│ │ │ ├── linear_search.swift
│ │ │ └── two_sum.swift
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.swift
│ │ │ ├── bucket_sort.swift
│ │ │ ├── counting_sort.swift
│ │ │ ├── heap_sort.swift
│ │ │ ├── insertion_sort.swift
│ │ │ ├── merge_sort.swift
│ │ │ ├── quick_sort.swift
│ │ │ ├── radix_sort.swift
│ │ │ └── selection_sort.swift
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── array_deque.swift
│ │ │ ├── array_queue.swift
│ │ │ ├── array_stack.swift
│ │ │ ├── deque.swift
│ │ │ ├── linkedlist_deque.swift
│ │ │ ├── linkedlist_queue.swift
│ │ │ ├── linkedlist_stack.swift
│ │ │ ├── queue.swift
│ │ │ └── stack.swift
│ │ ├── chapter_tree/
│ │ │ ├── array_binary_tree.swift
│ │ │ ├── avl_tree.swift
│ │ │ ├── binary_search_tree.swift
│ │ │ ├── binary_tree.swift
│ │ │ ├── binary_tree_bfs.swift
│ │ │ └── binary_tree_dfs.swift
│ │ └── utils/
│ │ ├── ListNode.swift
│ │ ├── Pair.swift
│ │ ├── PrintUtil.swift
│ │ ├── TreeNode.swift
│ │ └── Vertex.swift
│ ├── typescript/
│ │ ├── .gitignore
│ │ ├── .prettierrc
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.ts
│ │ │ ├── linked_list.ts
│ │ │ ├── list.ts
│ │ │ └── my_list.ts
│ │ ├── chapter_backtracking/
│ │ │ ├── n_queens.ts
│ │ │ ├── permutations_i.ts
│ │ │ ├── permutations_ii.ts
│ │ │ ├── preorder_traversal_i_compact.ts
│ │ │ ├── preorder_traversal_ii_compact.ts
│ │ │ ├── preorder_traversal_iii_compact.ts
│ │ │ ├── preorder_traversal_iii_template.ts
│ │ │ ├── subset_sum_i.ts
│ │ │ ├── subset_sum_i_naive.ts
│ │ │ └── subset_sum_ii.ts
│ │ ├── chapter_computational_complexity/
│ │ │ ├── iteration.ts
│ │ │ ├── recursion.ts
│ │ │ ├── space_complexity.ts
│ │ │ ├── time_complexity.ts
│ │ │ └── worst_best_time_complexity.ts
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── binary_search_recur.ts
│ │ │ ├── build_tree.ts
│ │ │ └── hanota.ts
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── climbing_stairs_backtrack.ts
│ │ │ ├── climbing_stairs_constraint_dp.ts
│ │ │ ├── climbing_stairs_dfs.ts
│ │ │ ├── climbing_stairs_dfs_mem.ts
│ │ │ ├── climbing_stairs_dp.ts
│ │ │ ├── coin_change.ts
│ │ │ ├── coin_change_ii.ts
│ │ │ ├── edit_distance.ts
│ │ │ ├── knapsack.ts
│ │ │ ├── min_cost_climbing_stairs_dp.ts
│ │ │ ├── min_path_sum.ts
│ │ │ └── unbounded_knapsack.ts
│ │ ├── chapter_graph/
│ │ │ ├── graph_adjacency_list.ts
│ │ │ ├── graph_adjacency_matrix.ts
│ │ │ ├── graph_bfs.ts
│ │ │ └── graph_dfs.ts
│ │ ├── chapter_greedy/
│ │ │ ├── coin_change_greedy.ts
│ │ │ ├── fractional_knapsack.ts
│ │ │ ├── max_capacity.ts
│ │ │ └── max_product_cutting.ts
│ │ ├── chapter_hashing/
│ │ │ ├── array_hash_map.ts
│ │ │ ├── hash_map.ts
│ │ │ ├── hash_map_chaining.ts
│ │ │ ├── hash_map_open_addressing.ts
│ │ │ └── simple_hash.ts
│ │ ├── chapter_heap/
│ │ │ ├── my_heap.ts
│ │ │ └── top_k.ts
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.ts
│ │ │ ├── binary_search_edge.ts
│ │ │ ├── binary_search_insertion.ts
│ │ │ ├── hashing_search.ts
│ │ │ ├── linear_search.ts
│ │ │ └── two_sum.ts
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.ts
│ │ │ ├── bucket_sort.ts
│ │ │ ├── counting_sort.ts
│ │ │ ├── heap_sort.ts
│ │ │ ├── insertion_sort.ts
│ │ │ ├── merge_sort.ts
│ │ │ ├── quick_sort.ts
│ │ │ ├── radix_sort.ts
│ │ │ └── selection_sort.ts
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── array_deque.ts
│ │ │ ├── array_queue.ts
│ │ │ ├── array_stack.ts
│ │ │ ├── deque.ts
│ │ │ ├── linkedlist_deque.ts
│ │ │ ├── linkedlist_queue.ts
│ │ │ ├── linkedlist_stack.ts
│ │ │ ├── queue.ts
│ │ │ └── stack.ts
│ │ ├── chapter_tree/
│ │ │ ├── array_binary_tree.ts
│ │ │ ├── avl_tree.ts
│ │ │ ├── binary_search_tree.ts
│ │ │ ├── binary_tree.ts
│ │ │ ├── binary_tree_bfs.ts
│ │ │ └── binary_tree_dfs.ts
│ │ ├── modules/
│ │ │ ├── ListNode.ts
│ │ │ ├── PrintUtil.ts
│ │ │ ├── TreeNode.ts
│ │ │ └── Vertex.ts
│ │ ├── package.json
│ │ └── tsconfig.json
│ └── zig/
│ ├── .gitignore
│ ├── build.zig
│ ├── chapter_array_and_linkedlist/
│ │ ├── array.zig
│ │ ├── linked_list.zig
│ │ ├── list.zig
│ │ └── my_list.zig
│ ├── chapter_computational_complexity/
│ │ ├── iteration.zig
│ │ ├── recursion.zig
│ │ ├── space_complexity.zig
│ │ ├── time_complexity.zig
│ │ └── worst_best_time_complexity.zig
│ ├── chapter_dynamic_programming/
│ │ ├── climbing_stairs_backtrack.zig
│ │ ├── climbing_stairs_constraint_dp.zig
│ │ ├── climbing_stairs_dfs.zig
│ │ ├── climbing_stairs_dfs_mem.zig
│ │ ├── climbing_stairs_dp.zig
│ │ ├── coin_change.zig
│ │ ├── coin_change_ii.zig
│ │ ├── edit_distance.zig
│ │ ├── knapsack.zig
│ │ ├── min_cost_climbing_stairs_dp.zig
│ │ ├── min_path_sum.zig
│ │ └── unbounded_knapsack.zig
│ ├── chapter_hashing/
│ │ ├── array_hash_map.zig
│ │ └── hash_map.zig
│ ├── chapter_heap/
│ │ ├── heap.zig
│ │ └── my_heap.zig
│ ├── chapter_searching/
│ │ ├── binary_search.zig
│ │ ├── hashing_search.zig
│ │ ├── linear_search.zig
│ │ └── two_sum.zig
│ ├── chapter_sorting/
│ │ ├── bubble_sort.zig
│ │ ├── insertion_sort.zig
│ │ ├── merge_sort.zig
│ │ ├── quick_sort.zig
│ │ └── radix_sort.zig
│ ├── chapter_stack_and_queue/
│ │ ├── array_queue.zig
│ │ ├── array_stack.zig
│ │ ├── deque.zig
│ │ ├── linkedlist_deque.zig
│ │ ├── linkedlist_queue.zig
│ │ ├── linkedlist_stack.zig
│ │ ├── queue.zig
│ │ └── stack.zig
│ ├── chapter_tree/
│ │ ├── avl_tree.zig
│ │ ├── binary_search_tree.zig
│ │ ├── binary_tree.zig
│ │ ├── binary_tree_bfs.zig
│ │ └── binary_tree_dfs.zig
│ ├── include/
│ │ ├── PrintUtil.zig
│ │ └── include.zig
│ ├── main.zig
│ └── utils/
│ ├── ListNode.zig
│ ├── TreeNode.zig
│ ├── format.zig
│ └── utils.zig
├── docker-compose.yml
├── docs/
│ ├── chapter_appendix/
│ │ ├── contribution.md
│ │ ├── index.md
│ │ ├── installation.md
│ │ └── terminology.md
│ ├── chapter_array_and_linkedlist/
│ │ ├── array.md
│ │ ├── index.md
│ │ ├── linked_list.md
│ │ ├── list.md
│ │ ├── ram_and_cache.md
│ │ └── summary.md
│ ├── chapter_backtracking/
│ │ ├── backtracking_algorithm.md
│ │ ├── index.md
│ │ ├── n_queens_problem.md
│ │ ├── permutations_problem.md
│ │ ├── subset_sum_problem.md
│ │ └── summary.md
│ ├── chapter_computational_complexity/
│ │ ├── index.md
│ │ ├── iteration_and_recursion.md
│ │ ├── performance_evaluation.md
│ │ ├── space_complexity.md
│ │ ├── summary.md
│ │ └── time_complexity.md
│ ├── chapter_data_structure/
│ │ ├── basic_data_types.md
│ │ ├── character_encoding.md
│ │ ├── classification_of_data_structure.md
│ │ ├── index.md
│ │ ├── number_encoding.md
│ │ └── summary.md
│ ├── chapter_divide_and_conquer/
│ │ ├── binary_search_recur.md
│ │ ├── build_binary_tree_problem.md
│ │ ├── divide_and_conquer.md
│ │ ├── hanota_problem.md
│ │ ├── index.md
│ │ └── summary.md
│ ├── chapter_dynamic_programming/
│ │ ├── dp_problem_features.md
│ │ ├── dp_solution_pipeline.md
│ │ ├── edit_distance_problem.md
│ │ ├── index.md
│ │ ├── intro_to_dynamic_programming.md
│ │ ├── knapsack_problem.md
│ │ ├── summary.md
│ │ └── unbounded_knapsack_problem.md
│ ├── chapter_graph/
│ │ ├── graph.md
│ │ ├── graph_operations.md
│ │ ├── graph_traversal.md
│ │ ├── index.md
│ │ └── summary.md
│ ├── chapter_greedy/
│ │ ├── fractional_knapsack_problem.md
│ │ ├── greedy_algorithm.md
│ │ ├── index.md
│ │ ├── max_capacity_problem.md
│ │ ├── max_product_cutting_problem.md
│ │ └── summary.md
│ ├── chapter_hashing/
│ │ ├── hash_algorithm.md
│ │ ├── hash_collision.md
│ │ ├── hash_map.md
│ │ ├── index.md
│ │ └── summary.md
│ ├── chapter_heap/
│ │ ├── build_heap.md
│ │ ├── heap.md
│ │ ├── index.md
│ │ ├── summary.md
│ │ └── top_k.md
│ ├── chapter_hello_algo/
│ │ └── index.md
│ ├── chapter_introduction/
│ │ ├── algorithms_are_everywhere.md
│ │ ├── index.md
│ │ ├── summary.md
│ │ └── what_is_dsa.md
│ ├── chapter_paperbook/
│ │ └── index.md
│ ├── chapter_preface/
│ │ ├── about_the_book.md
│ │ ├── index.md
│ │ ├── suggestions.md
│ │ └── summary.md
│ ├── chapter_reference/
│ │ └── index.md
│ ├── chapter_searching/
│ │ ├── binary_search.md
│ │ ├── binary_search_edge.md
│ │ ├── binary_search_insertion.md
│ │ ├── index.md
│ │ ├── replace_linear_by_hashing.md
│ │ ├── searching_algorithm_revisited.md
│ │ └── summary.md
│ ├── chapter_sorting/
│ │ ├── bubble_sort.md
│ │ ├── bucket_sort.md
│ │ ├── counting_sort.md
│ │ ├── heap_sort.md
│ │ ├── index.md
│ │ ├── insertion_sort.md
│ │ ├── merge_sort.md
│ │ ├── quick_sort.md
│ │ ├── radix_sort.md
│ │ ├── selection_sort.md
│ │ ├── sorting_algorithm.md
│ │ └── summary.md
│ ├── chapter_stack_and_queue/
│ │ ├── deque.md
│ │ ├── index.md
│ │ ├── queue.md
│ │ ├── stack.md
│ │ └── summary.md
│ ├── chapter_tree/
│ │ ├── array_representation_of_tree.md
│ │ ├── avl_tree.md
│ │ ├── binary_search_tree.md
│ │ ├── binary_tree.md
│ │ ├── binary_tree_traversal.md
│ │ ├── index.md
│ │ └── summary.md
│ ├── index.html
│ └── index.md
├── en/
│ ├── CONTRIBUTING.md
│ ├── README.md
│ ├── codes/
│ │ ├── c/
│ │ │ ├── .gitignore
│ │ │ ├── CMakeLists.txt
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array.c
│ │ │ │ ├── linked_list.c
│ │ │ │ └── my_list.c
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── n_queens.c
│ │ │ │ ├── permutations_i.c
│ │ │ │ ├── permutations_ii.c
│ │ │ │ ├── preorder_traversal_i_compact.c
│ │ │ │ ├── preorder_traversal_ii_compact.c
│ │ │ │ ├── preorder_traversal_iii_compact.c
│ │ │ │ ├── preorder_traversal_iii_template.c
│ │ │ │ ├── subset_sum_i.c
│ │ │ │ ├── subset_sum_i_naive.c
│ │ │ │ └── subset_sum_ii.c
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── iteration.c
│ │ │ │ ├── recursion.c
│ │ │ │ ├── space_complexity.c
│ │ │ │ ├── time_complexity.c
│ │ │ │ └── worst_best_time_complexity.c
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── binary_search_recur.c
│ │ │ │ ├── build_tree.c
│ │ │ │ └── hanota.c
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── climbing_stairs_backtrack.c
│ │ │ │ ├── climbing_stairs_constraint_dp.c
│ │ │ │ ├── climbing_stairs_dfs.c
│ │ │ │ ├── climbing_stairs_dfs_mem.c
│ │ │ │ ├── climbing_stairs_dp.c
│ │ │ │ ├── coin_change.c
│ │ │ │ ├── coin_change_ii.c
│ │ │ │ ├── edit_distance.c
│ │ │ │ ├── knapsack.c
│ │ │ │ ├── min_cost_climbing_stairs_dp.c
│ │ │ │ ├── min_path_sum.c
│ │ │ │ └── unbounded_knapsack.c
│ │ │ ├── chapter_graph/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── graph_adjacency_list.c
│ │ │ │ ├── graph_adjacency_list_test.c
│ │ │ │ ├── graph_adjacency_matrix.c
│ │ │ │ ├── graph_bfs.c
│ │ │ │ └── graph_dfs.c
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── coin_change_greedy.c
│ │ │ │ ├── fractional_knapsack.c
│ │ │ │ ├── max_capacity.c
│ │ │ │ └── max_product_cutting.c
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_hash_map.c
│ │ │ │ ├── hash_map_chaining.c
│ │ │ │ ├── hash_map_open_addressing.c
│ │ │ │ └── simple_hash.c
│ │ │ ├── chapter_heap/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── my_heap.c
│ │ │ │ ├── my_heap_test.c
│ │ │ │ └── top_k.c
│ │ │ ├── chapter_searching/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── binary_search.c
│ │ │ │ ├── binary_search_edge.c
│ │ │ │ ├── binary_search_insertion.c
│ │ │ │ └── two_sum.c
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── bubble_sort.c
│ │ │ │ ├── bucket_sort.c
│ │ │ │ ├── counting_sort.c
│ │ │ │ ├── heap_sort.c
│ │ │ │ ├── insertion_sort.c
│ │ │ │ ├── merge_sort.c
│ │ │ │ ├── quick_sort.c
│ │ │ │ ├── radix_sort.c
│ │ │ │ └── selection_sort.c
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_deque.c
│ │ │ │ ├── array_queue.c
│ │ │ │ ├── array_stack.c
│ │ │ │ ├── linkedlist_deque.c
│ │ │ │ ├── linkedlist_queue.c
│ │ │ │ └── linkedlist_stack.c
│ │ │ ├── chapter_tree/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_binary_tree.c
│ │ │ │ ├── avl_tree.c
│ │ │ │ ├── binary_search_tree.c
│ │ │ │ ├── binary_tree.c
│ │ │ │ ├── binary_tree_bfs.c
│ │ │ │ └── binary_tree_dfs.c
│ │ │ └── utils/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── common.h
│ │ │ ├── common_test.c
│ │ │ ├── list_node.h
│ │ │ ├── print_util.h
│ │ │ ├── tree_node.h
│ │ │ ├── uthash.h
│ │ │ ├── vector.h
│ │ │ └── vertex.h
│ │ ├── cpp/
│ │ │ ├── .gitignore
│ │ │ ├── CMakeLists.txt
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array.cpp
│ │ │ │ ├── linked_list.cpp
│ │ │ │ ├── list.cpp
│ │ │ │ └── my_list.cpp
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── n_queens.cpp
│ │ │ │ ├── permutations_i.cpp
│ │ │ │ ├── permutations_ii.cpp
│ │ │ │ ├── preorder_traversal_i_compact.cpp
│ │ │ │ ├── preorder_traversal_ii_compact.cpp
│ │ │ │ ├── preorder_traversal_iii_compact.cpp
│ │ │ │ ├── preorder_traversal_iii_template.cpp
│ │ │ │ ├── subset_sum_i.cpp
│ │ │ │ ├── subset_sum_i_naive.cpp
│ │ │ │ └── subset_sum_ii.cpp
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── iteration.cpp
│ │ │ │ ├── recursion.cpp
│ │ │ │ ├── space_complexity.cpp
│ │ │ │ ├── time_complexity.cpp
│ │ │ │ └── worst_best_time_complexity.cpp
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── binary_search_recur.cpp
│ │ │ │ ├── build_tree.cpp
│ │ │ │ └── hanota.cpp
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── climbing_stairs_backtrack.cpp
│ │ │ │ ├── climbing_stairs_constraint_dp.cpp
│ │ │ │ ├── climbing_stairs_dfs.cpp
│ │ │ │ ├── climbing_stairs_dfs_mem.cpp
│ │ │ │ ├── climbing_stairs_dp.cpp
│ │ │ │ ├── coin_change.cpp
│ │ │ │ ├── coin_change_ii.cpp
│ │ │ │ ├── edit_distance.cpp
│ │ │ │ ├── knapsack.cpp
│ │ │ │ ├── min_cost_climbing_stairs_dp.cpp
│ │ │ │ ├── min_path_sum.cpp
│ │ │ │ └── unbounded_knapsack.cpp
│ │ │ ├── chapter_graph/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── graph_adjacency_list.cpp
│ │ │ │ ├── graph_adjacency_list_test.cpp
│ │ │ │ ├── graph_adjacency_matrix.cpp
│ │ │ │ ├── graph_bfs.cpp
│ │ │ │ └── graph_dfs.cpp
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── coin_change_greedy.cpp
│ │ │ │ ├── fractional_knapsack.cpp
│ │ │ │ ├── max_capacity.cpp
│ │ │ │ └── max_product_cutting.cpp
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_hash_map.cpp
│ │ │ │ ├── array_hash_map_test.cpp
│ │ │ │ ├── built_in_hash.cpp
│ │ │ │ ├── hash_map.cpp
│ │ │ │ ├── hash_map_chaining.cpp
│ │ │ │ ├── hash_map_open_addressing.cpp
│ │ │ │ └── simple_hash.cpp
│ │ │ ├── chapter_heap/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── heap.cpp
│ │ │ │ ├── my_heap.cpp
│ │ │ │ └── top_k.cpp
│ │ │ ├── chapter_searching/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── binary_search.cpp
│ │ │ │ ├── binary_search_edge.cpp
│ │ │ │ ├── binary_search_insertion.cpp
│ │ │ │ ├── hashing_search.cpp
│ │ │ │ ├── linear_search.cpp
│ │ │ │ └── two_sum.cpp
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── bubble_sort.cpp
│ │ │ │ ├── bucket_sort.cpp
│ │ │ │ ├── counting_sort.cpp
│ │ │ │ ├── heap_sort.cpp
│ │ │ │ ├── insertion_sort.cpp
│ │ │ │ ├── merge_sort.cpp
│ │ │ │ ├── quick_sort.cpp
│ │ │ │ ├── radix_sort.cpp
│ │ │ │ └── selection_sort.cpp
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_deque.cpp
│ │ │ │ ├── array_queue.cpp
│ │ │ │ ├── array_stack.cpp
│ │ │ │ ├── deque.cpp
│ │ │ │ ├── linkedlist_deque.cpp
│ │ │ │ ├── linkedlist_queue.cpp
│ │ │ │ ├── linkedlist_stack.cpp
│ │ │ │ ├── queue.cpp
│ │ │ │ └── stack.cpp
│ │ │ ├── chapter_tree/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_binary_tree.cpp
│ │ │ │ ├── avl_tree.cpp
│ │ │ │ ├── binary_search_tree.cpp
│ │ │ │ ├── binary_tree.cpp
│ │ │ │ ├── binary_tree_bfs.cpp
│ │ │ │ └── binary_tree_dfs.cpp
│ │ │ └── utils/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── common.hpp
│ │ │ ├── list_node.hpp
│ │ │ ├── print_utils.hpp
│ │ │ ├── tree_node.hpp
│ │ │ └── vertex.hpp
│ │ ├── csharp/
│ │ │ ├── .editorconfig
│ │ │ ├── .gitignore
│ │ │ ├── GlobalUsing.cs
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.cs
│ │ │ │ ├── linked_list.cs
│ │ │ │ ├── list.cs
│ │ │ │ └── my_list.cs
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.cs
│ │ │ │ ├── permutations_i.cs
│ │ │ │ ├── permutations_ii.cs
│ │ │ │ ├── preorder_traversal_i_compact.cs
│ │ │ │ ├── preorder_traversal_ii_compact.cs
│ │ │ │ ├── preorder_traversal_iii_compact.cs
│ │ │ │ ├── preorder_traversal_iii_template.cs
│ │ │ │ ├── subset_sum_i.cs
│ │ │ │ ├── subset_sum_i_naive.cs
│ │ │ │ └── subset_sum_ii.cs
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.cs
│ │ │ │ ├── recursion.cs
│ │ │ │ ├── space_complexity.cs
│ │ │ │ ├── time_complexity.cs
│ │ │ │ └── worst_best_time_complexity.cs
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.cs
│ │ │ │ ├── build_tree.cs
│ │ │ │ └── hanota.cs
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.cs
│ │ │ │ ├── climbing_stairs_constraint_dp.cs
│ │ │ │ ├── climbing_stairs_dfs.cs
│ │ │ │ ├── climbing_stairs_dfs_mem.cs
│ │ │ │ ├── climbing_stairs_dp.cs
│ │ │ │ ├── coin_change.cs
│ │ │ │ ├── coin_change_ii.cs
│ │ │ │ ├── edit_distance.cs
│ │ │ │ ├── knapsack.cs
│ │ │ │ ├── min_cost_climbing_stairs_dp.cs
│ │ │ │ ├── min_path_sum.cs
│ │ │ │ └── unbounded_knapsack.cs
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.cs
│ │ │ │ ├── graph_adjacency_matrix.cs
│ │ │ │ ├── graph_bfs.cs
│ │ │ │ └── graph_dfs.cs
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.cs
│ │ │ │ ├── fractional_knapsack.cs
│ │ │ │ ├── max_capacity.cs
│ │ │ │ └── max_product_cutting.cs
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.cs
│ │ │ │ ├── built_in_hash.cs
│ │ │ │ ├── hash_map.cs
│ │ │ │ ├── hash_map_chaining.cs
│ │ │ │ ├── hash_map_open_addressing.cs
│ │ │ │ └── simple_hash.cs
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.cs
│ │ │ │ ├── my_heap.cs
│ │ │ │ └── top_k.cs
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.cs
│ │ │ │ ├── binary_search_edge.cs
│ │ │ │ ├── binary_search_insertion.cs
│ │ │ │ ├── hashing_search.cs
│ │ │ │ ├── linear_search.cs
│ │ │ │ └── two_sum.cs
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.cs
│ │ │ │ ├── bucket_sort.cs
│ │ │ │ ├── counting_sort.cs
│ │ │ │ ├── heap_sort.cs
│ │ │ │ ├── insertion_sort.cs
│ │ │ │ ├── merge_sort.cs
│ │ │ │ ├── quick_sort.cs
│ │ │ │ ├── radix_sort.cs
│ │ │ │ └── selection_sort.cs
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.cs
│ │ │ │ ├── array_queue.cs
│ │ │ │ ├── array_stack.cs
│ │ │ │ ├── deque.cs
│ │ │ │ ├── linkedlist_deque.cs
│ │ │ │ ├── linkedlist_queue.cs
│ │ │ │ ├── linkedlist_stack.cs
│ │ │ │ ├── queue.cs
│ │ │ │ └── stack.cs
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.cs
│ │ │ │ ├── avl_tree.cs
│ │ │ │ ├── binary_search_tree.cs
│ │ │ │ ├── binary_tree.cs
│ │ │ │ ├── binary_tree_bfs.cs
│ │ │ │ └── binary_tree_dfs.cs
│ │ │ ├── csharp.sln
│ │ │ ├── hello-algo.csproj
│ │ │ └── utils/
│ │ │ ├── ListNode.cs
│ │ │ ├── PrintUtil.cs
│ │ │ ├── TreeNode.cs
│ │ │ └── Vertex.cs
│ │ ├── dart/
│ │ │ ├── build.dart
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.dart
│ │ │ │ ├── linked_list.dart
│ │ │ │ ├── list.dart
│ │ │ │ └── my_list.dart
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.dart
│ │ │ │ ├── permutations_i.dart
│ │ │ │ ├── permutations_ii.dart
│ │ │ │ ├── preorder_traversal_i_compact.dart
│ │ │ │ ├── preorder_traversal_ii_compact.dart
│ │ │ │ ├── preorder_traversal_iii_compact.dart
│ │ │ │ ├── preorder_traversal_iii_template.dart
│ │ │ │ ├── subset_sum_i.dart
│ │ │ │ ├── subset_sum_i_naive.dart
│ │ │ │ └── subset_sum_ii.dart
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.dart
│ │ │ │ ├── recursion.dart
│ │ │ │ ├── space_complexity.dart
│ │ │ │ ├── time_complexity.dart
│ │ │ │ └── worst_best_time_complexity.dart
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.dart
│ │ │ │ ├── build_tree.dart
│ │ │ │ └── hanota.dart
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.dart
│ │ │ │ ├── climbing_stairs_constraint_dp.dart
│ │ │ │ ├── climbing_stairs_dfs.dart
│ │ │ │ ├── climbing_stairs_dfs_mem.dart
│ │ │ │ ├── climbing_stairs_dp.dart
│ │ │ │ ├── coin_change.dart
│ │ │ │ ├── coin_change_ii.dart
│ │ │ │ ├── edit_distance.dart
│ │ │ │ ├── knapsack.dart
│ │ │ │ ├── min_cost_climbing_stairs_dp.dart
│ │ │ │ ├── min_path_sum.dart
│ │ │ │ └── unbounded_knapsack.dart
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.dart
│ │ │ │ ├── graph_adjacency_matrix.dart
│ │ │ │ ├── graph_bfs.dart
│ │ │ │ └── graph_dfs.dart
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.dart
│ │ │ │ ├── fractional_knapsack.dart
│ │ │ │ ├── max_capacity.dart
│ │ │ │ └── max_product_cutting.dart
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.dart
│ │ │ │ ├── built_in_hash.dart
│ │ │ │ ├── hash_map.dart
│ │ │ │ ├── hash_map_chaining.dart
│ │ │ │ ├── hash_map_open_addressing.dart
│ │ │ │ └── simple_hash.dart
│ │ │ ├── chapter_heap/
│ │ │ │ ├── my_heap.dart
│ │ │ │ └── top_k.dart
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.dart
│ │ │ │ ├── binary_search_edge.dart
│ │ │ │ ├── binary_search_insertion.dart
│ │ │ │ ├── hashing_search.dart
│ │ │ │ ├── linear_search.dart
│ │ │ │ └── two_sum.dart
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.dart
│ │ │ │ ├── bucket_sort.dart
│ │ │ │ ├── counting_sort.dart
│ │ │ │ ├── heap_sort.dart
│ │ │ │ ├── insertion_sort.dart
│ │ │ │ ├── merge_sort.dart
│ │ │ │ ├── quick_sort.dart
│ │ │ │ ├── radix_sort.dart
│ │ │ │ └── selection_sort.dart
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.dart
│ │ │ │ ├── array_queue.dart
│ │ │ │ ├── array_stack.dart
│ │ │ │ ├── deque.dart
│ │ │ │ ├── linkedlist_deque.dart
│ │ │ │ ├── linkedlist_queue.dart
│ │ │ │ ├── linkedlist_stack.dart
│ │ │ │ ├── queue.dart
│ │ │ │ └── stack.dart
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.dart
│ │ │ │ ├── avl_tree.dart
│ │ │ │ ├── binary_search_tree.dart
│ │ │ │ ├── binary_tree.dart
│ │ │ │ ├── binary_tree_bfs.dart
│ │ │ │ └── binary_tree_dfs.dart
│ │ │ └── utils/
│ │ │ ├── list_node.dart
│ │ │ ├── print_util.dart
│ │ │ ├── tree_node.dart
│ │ │ └── vertex.dart
│ │ ├── go/
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.go
│ │ │ │ ├── array_test.go
│ │ │ │ ├── linked_list.go
│ │ │ │ ├── linked_list_test.go
│ │ │ │ ├── list_test.go
│ │ │ │ ├── my_list.go
│ │ │ │ └── my_list_test.go
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.go
│ │ │ │ ├── n_queens_test.go
│ │ │ │ ├── permutation_test.go
│ │ │ │ ├── permutations_i.go
│ │ │ │ ├── permutations_ii.go
│ │ │ │ ├── preorder_traversal_i_compact.go
│ │ │ │ ├── preorder_traversal_ii_compact.go
│ │ │ │ ├── preorder_traversal_iii_compact.go
│ │ │ │ ├── preorder_traversal_iii_template.go
│ │ │ │ ├── preorder_traversal_test.go
│ │ │ │ ├── subset_sum_i.go
│ │ │ │ ├── subset_sum_i_naive.go
│ │ │ │ ├── subset_sum_ii.go
│ │ │ │ └── subset_sum_test.go
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.go
│ │ │ │ ├── iteration_test.go
│ │ │ │ ├── recursion.go
│ │ │ │ ├── recursion_test.go
│ │ │ │ ├── space_complexity.go
│ │ │ │ ├── space_complexity_test.go
│ │ │ │ ├── time_complexity.go
│ │ │ │ ├── time_complexity_test.go
│ │ │ │ ├── worst_best_time_complexity.go
│ │ │ │ └── worst_best_time_complexity_test.go
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.go
│ │ │ │ ├── binary_search_recur_test.go
│ │ │ │ ├── build_tree.go
│ │ │ │ ├── build_tree_test.go
│ │ │ │ ├── hanota.go
│ │ │ │ └── hanota_test.go
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.go
│ │ │ │ ├── climbing_stairs_constraint_dp.go
│ │ │ │ ├── climbing_stairs_dfs.go
│ │ │ │ ├── climbing_stairs_dfs_mem.go
│ │ │ │ ├── climbing_stairs_dp.go
│ │ │ │ ├── climbing_stairs_test.go
│ │ │ │ ├── coin_change.go
│ │ │ │ ├── coin_change_ii.go
│ │ │ │ ├── coin_change_test.go
│ │ │ │ ├── edit_distance.go
│ │ │ │ ├── edit_distance_test.go
│ │ │ │ ├── knapsack.go
│ │ │ │ ├── knapsack_test.go
│ │ │ │ ├── min_cost_climbing_stairs_dp.go
│ │ │ │ ├── min_path_sum.go
│ │ │ │ ├── min_path_sum_test.go
│ │ │ │ └── unbounded_knapsack.go
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.go
│ │ │ │ ├── graph_adjacency_list_test.go
│ │ │ │ ├── graph_adjacency_matrix.go
│ │ │ │ ├── graph_adjacency_matrix_test.go
│ │ │ │ ├── graph_bfs.go
│ │ │ │ ├── graph_bfs_test.go
│ │ │ │ ├── graph_dfs.go
│ │ │ │ └── graph_dfs_test.go
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.go
│ │ │ │ ├── coin_change_greedy_test.go
│ │ │ │ ├── fractional_knapsack.go
│ │ │ │ ├── fractional_knapsack_test.go
│ │ │ │ ├── max_capacity.go
│ │ │ │ ├── max_capacity_test.go
│ │ │ │ ├── max_product_cutting.go
│ │ │ │ └── max_product_cutting_test.go
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.go
│ │ │ │ ├── array_hash_map_test.go
│ │ │ │ ├── hash_collision_test.go
│ │ │ │ ├── hash_map_chaining.go
│ │ │ │ ├── hash_map_open_addressing.go
│ │ │ │ ├── hash_map_test.go
│ │ │ │ └── simple_hash.go
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.go
│ │ │ │ ├── heap_test.go
│ │ │ │ ├── my_heap.go
│ │ │ │ └── top_k.go
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.go
│ │ │ │ ├── binary_search_edge.go
│ │ │ │ ├── binary_search_insertion.go
│ │ │ │ ├── binary_search_test.go
│ │ │ │ ├── hashing_search.go
│ │ │ │ ├── hashing_search_test.go
│ │ │ │ ├── linear_search.go
│ │ │ │ ├── linear_search_test.go
│ │ │ │ ├── two_sum.go
│ │ │ │ └── two_sum_test.go
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.go
│ │ │ │ ├── bubble_sort_test.go
│ │ │ │ ├── bucket_sort.go
│ │ │ │ ├── bucket_sort_test.go
│ │ │ │ ├── counting_sort.go
│ │ │ │ ├── counting_sort_test.go
│ │ │ │ ├── heap_sort.go
│ │ │ │ ├── heap_sort_test.go
│ │ │ │ ├── insertion_sort.go
│ │ │ │ ├── insertion_sort_test.go
│ │ │ │ ├── merge_sort.go
│ │ │ │ ├── merge_sort_test.go
│ │ │ │ ├── quick_sort.go
│ │ │ │ ├── quick_sort_test.go
│ │ │ │ ├── radix_sort.go
│ │ │ │ ├── radix_sort_test.go
│ │ │ │ ├── selection_sort.go
│ │ │ │ └── selection_sort_test.go
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.go
│ │ │ │ ├── array_queue.go
│ │ │ │ ├── array_stack.go
│ │ │ │ ├── deque_test.go
│ │ │ │ ├── linkedlist_deque.go
│ │ │ │ ├── linkedlist_queue.go
│ │ │ │ ├── linkedlist_stack.go
│ │ │ │ ├── queue_test.go
│ │ │ │ └── stack_test.go
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.go
│ │ │ │ ├── array_binary_tree_test.go
│ │ │ │ ├── avl_tree.go
│ │ │ │ ├── avl_tree_test.go
│ │ │ │ ├── binary_search_tree.go
│ │ │ │ ├── binary_search_tree_test.go
│ │ │ │ ├── binary_tree_bfs.go
│ │ │ │ ├── binary_tree_bfs_test.go
│ │ │ │ ├── binary_tree_dfs.go
│ │ │ │ ├── binary_tree_dfs_test.go
│ │ │ │ └── binary_tree_test.go
│ │ │ ├── go.mod
│ │ │ └── pkg/
│ │ │ ├── list_node.go
│ │ │ ├── list_node_test.go
│ │ │ ├── print_utils.go
│ │ │ ├── tree_node.go
│ │ │ ├── tree_node_test.go
│ │ │ └── vertex.go
│ │ ├── java/
│ │ │ ├── .gitignore
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.java
│ │ │ │ ├── linked_list.java
│ │ │ │ ├── list.java
│ │ │ │ └── my_list.java
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.java
│ │ │ │ ├── permutations_i.java
│ │ │ │ ├── permutations_ii.java
│ │ │ │ ├── preorder_traversal_i_compact.java
│ │ │ │ ├── preorder_traversal_ii_compact.java
│ │ │ │ ├── preorder_traversal_iii_compact.java
│ │ │ │ ├── preorder_traversal_iii_template.java
│ │ │ │ ├── subset_sum_i.java
│ │ │ │ ├── subset_sum_i_naive.java
│ │ │ │ └── subset_sum_ii.java
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.java
│ │ │ │ ├── recursion.java
│ │ │ │ ├── space_complexity.java
│ │ │ │ ├── time_complexity.java
│ │ │ │ └── worst_best_time_complexity.java
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.java
│ │ │ │ ├── build_tree.java
│ │ │ │ └── hanota.java
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.java
│ │ │ │ ├── climbing_stairs_constraint_dp.java
│ │ │ │ ├── climbing_stairs_dfs.java
│ │ │ │ ├── climbing_stairs_dfs_mem.java
│ │ │ │ ├── climbing_stairs_dp.java
│ │ │ │ ├── coin_change.java
│ │ │ │ ├── coin_change_ii.java
│ │ │ │ ├── edit_distance.java
│ │ │ │ ├── knapsack.java
│ │ │ │ ├── min_cost_climbing_stairs_dp.java
│ │ │ │ ├── min_path_sum.java
│ │ │ │ └── unbounded_knapsack.java
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.java
│ │ │ │ ├── graph_adjacency_matrix.java
│ │ │ │ ├── graph_bfs.java
│ │ │ │ └── graph_dfs.java
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.java
│ │ │ │ ├── fractional_knapsack.java
│ │ │ │ ├── max_capacity.java
│ │ │ │ └── max_product_cutting.java
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.java
│ │ │ │ ├── built_in_hash.java
│ │ │ │ ├── hash_map.java
│ │ │ │ ├── hash_map_chaining.java
│ │ │ │ ├── hash_map_open_addressing.java
│ │ │ │ └── simple_hash.java
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.java
│ │ │ │ ├── my_heap.java
│ │ │ │ └── top_k.java
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.java
│ │ │ │ ├── binary_search_edge.java
│ │ │ │ ├── binary_search_insertion.java
│ │ │ │ ├── hashing_search.java
│ │ │ │ ├── linear_search.java
│ │ │ │ └── two_sum.java
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.java
│ │ │ │ ├── bucket_sort.java
│ │ │ │ ├── counting_sort.java
│ │ │ │ ├── heap_sort.java
│ │ │ │ ├── insertion_sort.java
│ │ │ │ ├── merge_sort.java
│ │ │ │ ├── quick_sort.java
│ │ │ │ ├── radix_sort.java
│ │ │ │ └── selection_sort.java
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.java
│ │ │ │ ├── array_queue.java
│ │ │ │ ├── array_stack.java
│ │ │ │ ├── deque.java
│ │ │ │ ├── linkedlist_deque.java
│ │ │ │ ├── linkedlist_queue.java
│ │ │ │ ├── linkedlist_stack.java
│ │ │ │ ├── queue.java
│ │ │ │ └── stack.java
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.java
│ │ │ │ ├── avl_tree.java
│ │ │ │ ├── binary_search_tree.java
│ │ │ │ ├── binary_tree.java
│ │ │ │ ├── binary_tree_bfs.java
│ │ │ │ └── binary_tree_dfs.java
│ │ │ └── utils/
│ │ │ ├── ListNode.java
│ │ │ ├── PrintUtil.java
│ │ │ ├── TreeNode.java
│ │ │ └── Vertex.java
│ │ ├── javascript/
│ │ │ ├── .prettierrc
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.js
│ │ │ │ ├── linked_list.js
│ │ │ │ ├── list.js
│ │ │ │ └── my_list.js
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.js
│ │ │ │ ├── permutations_i.js
│ │ │ │ ├── permutations_ii.js
│ │ │ │ ├── preorder_traversal_i_compact.js
│ │ │ │ ├── preorder_traversal_ii_compact.js
│ │ │ │ ├── preorder_traversal_iii_compact.js
│ │ │ │ ├── preorder_traversal_iii_template.js
│ │ │ │ ├── subset_sum_i.js
│ │ │ │ ├── subset_sum_i_naive.js
│ │ │ │ └── subset_sum_ii.js
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.js
│ │ │ │ ├── recursion.js
│ │ │ │ ├── space_complexity.js
│ │ │ │ ├── time_complexity.js
│ │ │ │ └── worst_best_time_complexity.js
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.js
│ │ │ │ ├── build_tree.js
│ │ │ │ └── hanota.js
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.js
│ │ │ │ ├── climbing_stairs_constraint_dp.js
│ │ │ │ ├── climbing_stairs_dfs.js
│ │ │ │ ├── climbing_stairs_dfs_mem.js
│ │ │ │ ├── climbing_stairs_dp.js
│ │ │ │ ├── coin_change.js
│ │ │ │ ├── coin_change_ii.js
│ │ │ │ ├── edit_distance.js
│ │ │ │ ├── knapsack.js
│ │ │ │ ├── min_cost_climbing_stairs_dp.js
│ │ │ │ ├── min_path_sum.js
│ │ │ │ └── unbounded_knapsack.js
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.js
│ │ │ │ ├── graph_adjacency_matrix.js
│ │ │ │ ├── graph_bfs.js
│ │ │ │ └── graph_dfs.js
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.js
│ │ │ │ ├── fractional_knapsack.js
│ │ │ │ ├── max_capacity.js
│ │ │ │ └── max_product_cutting.js
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.js
│ │ │ │ ├── hash_map.js
│ │ │ │ ├── hash_map_chaining.js
│ │ │ │ ├── hash_map_open_addressing.js
│ │ │ │ └── simple_hash.js
│ │ │ ├── chapter_heap/
│ │ │ │ ├── my_heap.js
│ │ │ │ └── top_k.js
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.js
│ │ │ │ ├── binary_search_edge.js
│ │ │ │ ├── binary_search_insertion.js
│ │ │ │ ├── hashing_search.js
│ │ │ │ ├── linear_search.js
│ │ │ │ └── two_sum.js
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.js
│ │ │ │ ├── bucket_sort.js
│ │ │ │ ├── counting_sort.js
│ │ │ │ ├── heap_sort.js
│ │ │ │ ├── insertion_sort.js
│ │ │ │ ├── merge_sort.js
│ │ │ │ ├── quick_sort.js
│ │ │ │ ├── radix_sort.js
│ │ │ │ └── selection_sort.js
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.js
│ │ │ │ ├── array_queue.js
│ │ │ │ ├── array_stack.js
│ │ │ │ ├── deque.js
│ │ │ │ ├── linkedlist_deque.js
│ │ │ │ ├── linkedlist_queue.js
│ │ │ │ ├── linkedlist_stack.js
│ │ │ │ ├── queue.js
│ │ │ │ └── stack.js
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.js
│ │ │ │ ├── avl_tree.js
│ │ │ │ ├── binary_search_tree.js
│ │ │ │ ├── binary_tree.js
│ │ │ │ ├── binary_tree_bfs.js
│ │ │ │ └── binary_tree_dfs.js
│ │ │ ├── modules/
│ │ │ │ ├── ListNode.js
│ │ │ │ ├── PrintUtil.js
│ │ │ │ ├── TreeNode.js
│ │ │ │ └── Vertex.js
│ │ │ └── test_all.js
│ │ ├── kotlin/
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.kt
│ │ │ │ ├── linked_list.kt
│ │ │ │ ├── list.kt
│ │ │ │ └── my_list.kt
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.kt
│ │ │ │ ├── permutations_i.kt
│ │ │ │ ├── permutations_ii.kt
│ │ │ │ ├── preorder_traversal_i_compact.kt
│ │ │ │ ├── preorder_traversal_ii_compact.kt
│ │ │ │ ├── preorder_traversal_iii_compact.kt
│ │ │ │ ├── preorder_traversal_iii_template.kt
│ │ │ │ ├── subset_sum_i.kt
│ │ │ │ ├── subset_sum_i_naive.kt
│ │ │ │ └── subset_sum_ii.kt
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.kt
│ │ │ │ ├── recursion.kt
│ │ │ │ ├── space_complexity.kt
│ │ │ │ ├── time_complexity.kt
│ │ │ │ └── worst_best_time_complexity.kt
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.kt
│ │ │ │ ├── build_tree.kt
│ │ │ │ └── hanota.kt
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.kt
│ │ │ │ ├── climbing_stairs_constraint_dp.kt
│ │ │ │ ├── climbing_stairs_dfs.kt
│ │ │ │ ├── climbing_stairs_dfs_mem.kt
│ │ │ │ ├── climbing_stairs_dp.kt
│ │ │ │ ├── coin_change.kt
│ │ │ │ ├── coin_change_ii.kt
│ │ │ │ ├── edit_distance.kt
│ │ │ │ ├── knapsack.kt
│ │ │ │ ├── min_cost_climbing_stairs_dp.kt
│ │ │ │ ├── min_path_sum.kt
│ │ │ │ └── unbounded_knapsack.kt
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.kt
│ │ │ │ ├── graph_adjacency_matrix.kt
│ │ │ │ ├── graph_bfs.kt
│ │ │ │ └── graph_dfs.kt
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.kt
│ │ │ │ ├── fractional_knapsack.kt
│ │ │ │ ├── max_capacity.kt
│ │ │ │ └── max_product_cutting.kt
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.kt
│ │ │ │ ├── built_in_hash.kt
│ │ │ │ ├── hash_map.kt
│ │ │ │ ├── hash_map_chaining.kt
│ │ │ │ ├── hash_map_open_addressing.kt
│ │ │ │ └── simple_hash.kt
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.kt
│ │ │ │ ├── my_heap.kt
│ │ │ │ └── top_k.kt
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.kt
│ │ │ │ ├── binary_search_edge.kt
│ │ │ │ ├── binary_search_insertion.kt
│ │ │ │ ├── hashing_search.kt
│ │ │ │ ├── linear_search.kt
│ │ │ │ └── two_sum.kt
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.kt
│ │ │ │ ├── bucket_sort.kt
│ │ │ │ ├── counting_sort.kt
│ │ │ │ ├── heap_sort.kt
│ │ │ │ ├── insertion_sort.kt
│ │ │ │ ├── merge_sort.kt
│ │ │ │ ├── quick_sort.kt
│ │ │ │ ├── radix_sort.kt
│ │ │ │ └── selection_sort.kt
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.kt
│ │ │ │ ├── array_queue.kt
│ │ │ │ ├── array_stack.kt
│ │ │ │ ├── deque.kt
│ │ │ │ ├── linkedlist_deque.kt
│ │ │ │ ├── linkedlist_queue.kt
│ │ │ │ ├── linkedlist_stack.kt
│ │ │ │ ├── queue.kt
│ │ │ │ └── stack.kt
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.kt
│ │ │ │ ├── avl_tree.kt
│ │ │ │ ├── binary_search_tree.kt
│ │ │ │ ├── binary_tree.kt
│ │ │ │ ├── binary_tree_bfs.kt
│ │ │ │ └── binary_tree_dfs.kt
│ │ │ └── utils/
│ │ │ ├── ListNode.kt
│ │ │ ├── PrintUtil.kt
│ │ │ ├── TreeNode.kt
│ │ │ └── Vertex.kt
│ │ ├── python/
│ │ │ ├── .gitignore
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.py
│ │ │ │ ├── linked_list.py
│ │ │ │ ├── list.py
│ │ │ │ └── my_list.py
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.py
│ │ │ │ ├── permutations_i.py
│ │ │ │ ├── permutations_ii.py
│ │ │ │ ├── preorder_traversal_i_compact.py
│ │ │ │ ├── preorder_traversal_ii_compact.py
│ │ │ │ ├── preorder_traversal_iii_compact.py
│ │ │ │ ├── preorder_traversal_iii_template.py
│ │ │ │ ├── subset_sum_i.py
│ │ │ │ ├── subset_sum_i_naive.py
│ │ │ │ └── subset_sum_ii.py
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.py
│ │ │ │ ├── recursion.py
│ │ │ │ ├── space_complexity.py
│ │ │ │ ├── time_complexity.py
│ │ │ │ └── worst_best_time_complexity.py
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.py
│ │ │ │ ├── build_tree.py
│ │ │ │ └── hanota.py
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.py
│ │ │ │ ├── climbing_stairs_constraint_dp.py
│ │ │ │ ├── climbing_stairs_dfs.py
│ │ │ │ ├── climbing_stairs_dfs_mem.py
│ │ │ │ ├── climbing_stairs_dp.py
│ │ │ │ ├── coin_change.py
│ │ │ │ ├── coin_change_ii.py
│ │ │ │ ├── edit_distance.py
│ │ │ │ ├── knapsack.py
│ │ │ │ ├── min_cost_climbing_stairs_dp.py
│ │ │ │ ├── min_path_sum.py
│ │ │ │ └── unbounded_knapsack.py
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.py
│ │ │ │ ├── graph_adjacency_matrix.py
│ │ │ │ ├── graph_bfs.py
│ │ │ │ └── graph_dfs.py
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.py
│ │ │ │ ├── fractional_knapsack.py
│ │ │ │ ├── max_capacity.py
│ │ │ │ └── max_product_cutting.py
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.py
│ │ │ │ ├── built_in_hash.py
│ │ │ │ ├── hash_map.py
│ │ │ │ ├── hash_map_chaining.py
│ │ │ │ ├── hash_map_open_addressing.py
│ │ │ │ └── simple_hash.py
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.py
│ │ │ │ ├── my_heap.py
│ │ │ │ └── top_k.py
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.py
│ │ │ │ ├── binary_search_edge.py
│ │ │ │ ├── binary_search_insertion.py
│ │ │ │ ├── hashing_search.py
│ │ │ │ ├── linear_search.py
│ │ │ │ └── two_sum.py
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.py
│ │ │ │ ├── bucket_sort.py
│ │ │ │ ├── counting_sort.py
│ │ │ │ ├── heap_sort.py
│ │ │ │ ├── insertion_sort.py
│ │ │ │ ├── merge_sort.py
│ │ │ │ ├── quick_sort.py
│ │ │ │ ├── radix_sort.py
│ │ │ │ └── selection_sort.py
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.py
│ │ │ │ ├── array_queue.py
│ │ │ │ ├── array_stack.py
│ │ │ │ ├── deque.py
│ │ │ │ ├── linkedlist_deque.py
│ │ │ │ ├── linkedlist_queue.py
│ │ │ │ ├── linkedlist_stack.py
│ │ │ │ ├── queue.py
│ │ │ │ └── stack.py
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.py
│ │ │ │ ├── avl_tree.py
│ │ │ │ ├── binary_search_tree.py
│ │ │ │ ├── binary_tree.py
│ │ │ │ ├── binary_tree_bfs.py
│ │ │ │ └── binary_tree_dfs.py
│ │ │ ├── modules/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── list_node.py
│ │ │ │ ├── print_util.py
│ │ │ │ ├── tree_node.py
│ │ │ │ └── vertex.py
│ │ │ └── test_all.py
│ │ ├── ruby/
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.rb
│ │ │ │ ├── linked_list.rb
│ │ │ │ ├── list.rb
│ │ │ │ └── my_list.rb
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.rb
│ │ │ │ ├── permutations_i.rb
│ │ │ │ ├── permutations_ii.rb
│ │ │ │ ├── preorder_traversal_i_compact.rb
│ │ │ │ ├── preorder_traversal_ii_compact.rb
│ │ │ │ ├── preorder_traversal_iii_compact.rb
│ │ │ │ ├── preorder_traversal_iii_template.rb
│ │ │ │ ├── subset_sum_i.rb
│ │ │ │ ├── subset_sum_i_naive.rb
│ │ │ │ └── subset_sum_ii.rb
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.rb
│ │ │ │ ├── recursion.rb
│ │ │ │ ├── space_complexity.rb
│ │ │ │ ├── time_complexity.rb
│ │ │ │ └── worst_best_time_complexity.rb
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.rb
│ │ │ │ ├── build_tree.rb
│ │ │ │ └── hanota.rb
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.rb
│ │ │ │ ├── climbing_stairs_constraint_dp.rb
│ │ │ │ ├── climbing_stairs_dfs.rb
│ │ │ │ ├── climbing_stairs_dfs_mem.rb
│ │ │ │ ├── climbing_stairs_dp.rb
│ │ │ │ ├── coin_change.rb
│ │ │ │ ├── coin_change_ii.rb
│ │ │ │ ├── edit_distance.rb
│ │ │ │ ├── knapsack.rb
│ │ │ │ ├── min_cost_climbing_stairs_dp.rb
│ │ │ │ ├── min_path_sum.rb
│ │ │ │ └── unbounded_knapsack.rb
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.rb
│ │ │ │ ├── graph_adjacency_matrix.rb
│ │ │ │ ├── graph_bfs.rb
│ │ │ │ └── graph_dfs.rb
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.rb
│ │ │ │ ├── fractional_knapsack.rb
│ │ │ │ ├── max_capacity.rb
│ │ │ │ └── max_product_cutting.rb
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.rb
│ │ │ │ ├── built_in_hash.rb
│ │ │ │ ├── hash_map.rb
│ │ │ │ ├── hash_map_chaining.rb
│ │ │ │ ├── hash_map_open_addressing.rb
│ │ │ │ └── simple_hash.rb
│ │ │ ├── chapter_heap/
│ │ │ │ ├── my_heap.rb
│ │ │ │ └── top_k.rb
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.rb
│ │ │ │ ├── binary_search_edge.rb
│ │ │ │ ├── binary_search_insertion.rb
│ │ │ │ ├── hashing_search.rb
│ │ │ │ ├── linear_search.rb
│ │ │ │ └── two_sum.rb
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.rb
│ │ │ │ ├── bucket_sort.rb
│ │ │ │ ├── counting_sort.rb
│ │ │ │ ├── heap_sort.rb
│ │ │ │ ├── insertion_sort.rb
│ │ │ │ ├── merge_sort.rb
│ │ │ │ ├── quick_sort.rb
│ │ │ │ ├── radix_sort.rb
│ │ │ │ └── selection_sort.rb
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.rb
│ │ │ │ ├── array_queue.rb
│ │ │ │ ├── array_stack.rb
│ │ │ │ ├── deque.rb
│ │ │ │ ├── linkedlist_deque.rb
│ │ │ │ ├── linkedlist_queue.rb
│ │ │ │ ├── linkedlist_stack.rb
│ │ │ │ ├── queue.rb
│ │ │ │ └── stack.rb
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.rb
│ │ │ │ ├── avl_tree.rb
│ │ │ │ ├── binary_search_tree.rb
│ │ │ │ ├── binary_tree.rb
│ │ │ │ ├── binary_tree_bfs.rb
│ │ │ │ └── binary_tree_dfs.rb
│ │ │ ├── test_all.rb
│ │ │ └── utils/
│ │ │ ├── list_node.rb
│ │ │ ├── print_util.rb
│ │ │ ├── tree_node.rb
│ │ │ └── vertex.rb
│ │ ├── rust/
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.rs
│ │ │ │ ├── linked_list.rs
│ │ │ │ ├── list.rs
│ │ │ │ └── my_list.rs
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.rs
│ │ │ │ ├── permutations_i.rs
│ │ │ │ ├── permutations_ii.rs
│ │ │ │ ├── preorder_traversal_i_compact.rs
│ │ │ │ ├── preorder_traversal_ii_compact.rs
│ │ │ │ ├── preorder_traversal_iii_compact.rs
│ │ │ │ ├── preorder_traversal_iii_template.rs
│ │ │ │ ├── subset_sum_i.rs
│ │ │ │ ├── subset_sum_i_naive.rs
│ │ │ │ └── subset_sum_ii.rs
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.rs
│ │ │ │ ├── recursion.rs
│ │ │ │ ├── space_complexity.rs
│ │ │ │ ├── time_complexity.rs
│ │ │ │ └── worst_best_time_complexity.rs
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.rs
│ │ │ │ ├── build_tree.rs
│ │ │ │ └── hanota.rs
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.rs
│ │ │ │ ├── climbing_stairs_constraint_dp.rs
│ │ │ │ ├── climbing_stairs_dfs.rs
│ │ │ │ ├── climbing_stairs_dfs_mem.rs
│ │ │ │ ├── climbing_stairs_dp.rs
│ │ │ │ ├── coin_change.rs
│ │ │ │ ├── coin_change_ii.rs
│ │ │ │ ├── edit_distance.rs
│ │ │ │ ├── knapsack.rs
│ │ │ │ ├── min_cost_climbing_stairs_dp.rs
│ │ │ │ ├── min_path_sum.rs
│ │ │ │ └── unbounded_knapsack.rs
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.rs
│ │ │ │ ├── graph_adjacency_matrix.rs
│ │ │ │ ├── graph_bfs.rs
│ │ │ │ └── graph_dfs.rs
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.rs
│ │ │ │ ├── fractional_knapsack.rs
│ │ │ │ ├── max_capacity.rs
│ │ │ │ └── max_product_cutting.rs
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.rs
│ │ │ │ ├── build_in_hash.rs
│ │ │ │ ├── hash_map.rs
│ │ │ │ ├── hash_map_chaining.rs
│ │ │ │ ├── hash_map_open_addressing.rs
│ │ │ │ └── simple_hash.rs
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.rs
│ │ │ │ ├── my_heap.rs
│ │ │ │ └── top_k.rs
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.rs
│ │ │ │ ├── binary_search_edge.rs
│ │ │ │ ├── binary_search_insertion.rs
│ │ │ │ ├── hashing_search.rs
│ │ │ │ ├── linear_search.rs
│ │ │ │ └── two_sum.rs
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.rs
│ │ │ │ ├── bucket_sort.rs
│ │ │ │ ├── counting_sort.rs
│ │ │ │ ├── heap_sort.rs
│ │ │ │ ├── insertion_sort.rs
│ │ │ │ ├── merge_sort.rs
│ │ │ │ ├── quick_sort.rs
│ │ │ │ ├── radix_sort.rs
│ │ │ │ └── selection_sort.rs
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.rs
│ │ │ │ ├── array_queue.rs
│ │ │ │ ├── array_stack.rs
│ │ │ │ ├── deque.rs
│ │ │ │ ├── linkedlist_deque.rs
│ │ │ │ ├── linkedlist_queue.rs
│ │ │ │ ├── linkedlist_stack.rs
│ │ │ │ ├── queue.rs
│ │ │ │ └── stack.rs
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.rs
│ │ │ │ ├── avl_tree.rs
│ │ │ │ ├── binary_search_tree.rs
│ │ │ │ ├── binary_tree.rs
│ │ │ │ ├── binary_tree_bfs.rs
│ │ │ │ └── binary_tree_dfs.rs
│ │ │ └── src/
│ │ │ ├── include/
│ │ │ │ ├── list_node.rs
│ │ │ │ ├── mod.rs
│ │ │ │ ├── print_util.rs
│ │ │ │ ├── tree_node.rs
│ │ │ │ └── vertex.rs
│ │ │ └── lib.rs
│ │ ├── swift/
│ │ │ ├── .gitignore
│ │ │ ├── Package.resolved
│ │ │ ├── Package.swift
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.swift
│ │ │ │ ├── linked_list.swift
│ │ │ │ ├── list.swift
│ │ │ │ └── my_list.swift
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.swift
│ │ │ │ ├── permutations_i.swift
│ │ │ │ ├── permutations_ii.swift
│ │ │ │ ├── preorder_traversal_i_compact.swift
│ │ │ │ ├── preorder_traversal_ii_compact.swift
│ │ │ │ ├── preorder_traversal_iii_compact.swift
│ │ │ │ ├── preorder_traversal_iii_template.swift
│ │ │ │ ├── subset_sum_i.swift
│ │ │ │ ├── subset_sum_i_naive.swift
│ │ │ │ └── subset_sum_ii.swift
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.swift
│ │ │ │ ├── recursion.swift
│ │ │ │ ├── space_complexity.swift
│ │ │ │ ├── time_complexity.swift
│ │ │ │ └── worst_best_time_complexity.swift
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.swift
│ │ │ │ ├── build_tree.swift
│ │ │ │ └── hanota.swift
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.swift
│ │ │ │ ├── climbing_stairs_constraint_dp.swift
│ │ │ │ ├── climbing_stairs_dfs.swift
│ │ │ │ ├── climbing_stairs_dfs_mem.swift
│ │ │ │ ├── climbing_stairs_dp.swift
│ │ │ │ ├── coin_change.swift
│ │ │ │ ├── coin_change_ii.swift
│ │ │ │ ├── edit_distance.swift
│ │ │ │ ├── knapsack.swift
│ │ │ │ ├── min_cost_climbing_stairs_dp.swift
│ │ │ │ ├── min_path_sum.swift
│ │ │ │ └── unbounded_knapsack.swift
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.swift
│ │ │ │ ├── graph_adjacency_list_target.swift
│ │ │ │ ├── graph_adjacency_matrix.swift
│ │ │ │ ├── graph_bfs.swift
│ │ │ │ └── graph_dfs.swift
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.swift
│ │ │ │ ├── fractional_knapsack.swift
│ │ │ │ ├── max_capacity.swift
│ │ │ │ └── max_product_cutting.swift
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.swift
│ │ │ │ ├── built_in_hash.swift
│ │ │ │ ├── hash_map.swift
│ │ │ │ ├── hash_map_chaining.swift
│ │ │ │ ├── hash_map_open_addressing.swift
│ │ │ │ └── simple_hash.swift
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.swift
│ │ │ │ ├── my_heap.swift
│ │ │ │ └── top_k.swift
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.swift
│ │ │ │ ├── binary_search_edge.swift
│ │ │ │ ├── binary_search_insertion.swift
│ │ │ │ ├── binary_search_insertion_target.swift
│ │ │ │ ├── hashing_search.swift
│ │ │ │ ├── linear_search.swift
│ │ │ │ └── two_sum.swift
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.swift
│ │ │ │ ├── bucket_sort.swift
│ │ │ │ ├── counting_sort.swift
│ │ │ │ ├── heap_sort.swift
│ │ │ │ ├── insertion_sort.swift
│ │ │ │ ├── merge_sort.swift
│ │ │ │ ├── quick_sort.swift
│ │ │ │ ├── radix_sort.swift
│ │ │ │ └── selection_sort.swift
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.swift
│ │ │ │ ├── array_queue.swift
│ │ │ │ ├── array_stack.swift
│ │ │ │ ├── deque.swift
│ │ │ │ ├── linkedlist_deque.swift
│ │ │ │ ├── linkedlist_queue.swift
│ │ │ │ ├── linkedlist_stack.swift
│ │ │ │ ├── queue.swift
│ │ │ │ └── stack.swift
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.swift
│ │ │ │ ├── avl_tree.swift
│ │ │ │ ├── binary_search_tree.swift
│ │ │ │ ├── binary_tree.swift
│ │ │ │ ├── binary_tree_bfs.swift
│ │ │ │ └── binary_tree_dfs.swift
│ │ │ └── utils/
│ │ │ ├── ListNode.swift
│ │ │ ├── Pair.swift
│ │ │ ├── PrintUtil.swift
│ │ │ ├── TreeNode.swift
│ │ │ └── Vertex.swift
│ │ └── typescript/
│ │ ├── .gitignore
│ │ ├── .prettierrc
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.ts
│ │ │ ├── linked_list.ts
│ │ │ ├── list.ts
│ │ │ └── my_list.ts
│ │ ├── chapter_backtracking/
│ │ │ ├── n_queens.ts
│ │ │ ├── permutations_i.ts
│ │ │ ├── permutations_ii.ts
│ │ │ ├── preorder_traversal_i_compact.ts
│ │ │ ├── preorder_traversal_ii_compact.ts
│ │ │ ├── preorder_traversal_iii_compact.ts
│ │ │ ├── preorder_traversal_iii_template.ts
│ │ │ ├── subset_sum_i.ts
│ │ │ ├── subset_sum_i_naive.ts
│ │ │ └── subset_sum_ii.ts
│ │ ├── chapter_computational_complexity/
│ │ │ ├── iteration.ts
│ │ │ ├── recursion.ts
│ │ │ ├── space_complexity.ts
│ │ │ ├── time_complexity.ts
│ │ │ └── worst_best_time_complexity.ts
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── binary_search_recur.ts
│ │ │ ├── build_tree.ts
│ │ │ └── hanota.ts
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── climbing_stairs_backtrack.ts
│ │ │ ├── climbing_stairs_constraint_dp.ts
│ │ │ ├── climbing_stairs_dfs.ts
│ │ │ ├── climbing_stairs_dfs_mem.ts
│ │ │ ├── climbing_stairs_dp.ts
│ │ │ ├── coin_change.ts
│ │ │ ├── coin_change_ii.ts
│ │ │ ├── edit_distance.ts
│ │ │ ├── knapsack.ts
│ │ │ ├── min_cost_climbing_stairs_dp.ts
│ │ │ ├── min_path_sum.ts
│ │ │ └── unbounded_knapsack.ts
│ │ ├── chapter_graph/
│ │ │ ├── graph_adjacency_list.ts
│ │ │ ├── graph_adjacency_matrix.ts
│ │ │ ├── graph_bfs.ts
│ │ │ └── graph_dfs.ts
│ │ ├── chapter_greedy/
│ │ │ ├── coin_change_greedy.ts
│ │ │ ├── fractional_knapsack.ts
│ │ │ ├── max_capacity.ts
│ │ │ └── max_product_cutting.ts
│ │ ├── chapter_hashing/
│ │ │ ├── array_hash_map.ts
│ │ │ ├── hash_map.ts
│ │ │ ├── hash_map_chaining.ts
│ │ │ ├── hash_map_open_addressing.ts
│ │ │ └── simple_hash.ts
│ │ ├── chapter_heap/
│ │ │ ├── my_heap.ts
│ │ │ └── top_k.ts
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.ts
│ │ │ ├── binary_search_edge.ts
│ │ │ ├── binary_search_insertion.ts
│ │ │ ├── hashing_search.ts
│ │ │ ├── linear_search.ts
│ │ │ └── two_sum.ts
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.ts
│ │ │ ├── bucket_sort.ts
│ │ │ ├── counting_sort.ts
│ │ │ ├── heap_sort.ts
│ │ │ ├── insertion_sort.ts
│ │ │ ├── merge_sort.ts
│ │ │ ├── quick_sort.ts
│ │ │ ├── radix_sort.ts
│ │ │ └── selection_sort.ts
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── array_deque.ts
│ │ │ ├── array_queue.ts
│ │ │ ├── array_stack.ts
│ │ │ ├── deque.ts
│ │ │ ├── linkedlist_deque.ts
│ │ │ ├── linkedlist_queue.ts
│ │ │ ├── linkedlist_stack.ts
│ │ │ ├── queue.ts
│ │ │ └── stack.ts
│ │ ├── chapter_tree/
│ │ │ ├── array_binary_tree.ts
│ │ │ ├── avl_tree.ts
│ │ │ ├── binary_search_tree.ts
│ │ │ ├── binary_tree.ts
│ │ │ ├── binary_tree_bfs.ts
│ │ │ └── binary_tree_dfs.ts
│ │ ├── modules/
│ │ │ ├── ListNode.ts
│ │ │ ├── PrintUtil.ts
│ │ │ ├── TreeNode.ts
│ │ │ └── Vertex.ts
│ │ ├── package.json
│ │ └── tsconfig.json
│ ├── docs/
│ │ ├── chapter_appendix/
│ │ │ ├── contribution.md
│ │ │ ├── index.md
│ │ │ ├── installation.md
│ │ │ └── terminology.md
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.md
│ │ │ ├── index.md
│ │ │ ├── linked_list.md
│ │ │ ├── list.md
│ │ │ ├── ram_and_cache.md
│ │ │ └── summary.md
│ │ ├── chapter_backtracking/
│ │ │ ├── backtracking_algorithm.md
│ │ │ ├── index.md
│ │ │ ├── n_queens_problem.md
│ │ │ ├── permutations_problem.md
│ │ │ ├── subset_sum_problem.md
│ │ │ └── summary.md
│ │ ├── chapter_computational_complexity/
│ │ │ ├── index.md
│ │ │ ├── iteration_and_recursion.md
│ │ │ ├── performance_evaluation.md
│ │ │ ├── space_complexity.md
│ │ │ ├── summary.md
│ │ │ └── time_complexity.md
│ │ ├── chapter_data_structure/
│ │ │ ├── basic_data_types.md
│ │ │ ├── character_encoding.md
│ │ │ ├── classification_of_data_structure.md
│ │ │ ├── index.md
│ │ │ ├── number_encoding.md
│ │ │ └── summary.md
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── binary_search_recur.md
│ │ │ ├── build_binary_tree_problem.md
│ │ │ ├── divide_and_conquer.md
│ │ │ ├── hanota_problem.md
│ │ │ ├── index.md
│ │ │ └── summary.md
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── dp_problem_features.md
│ │ │ ├── dp_solution_pipeline.md
│ │ │ ├── edit_distance_problem.md
│ │ │ ├── index.md
│ │ │ ├── intro_to_dynamic_programming.md
│ │ │ ├── knapsack_problem.md
│ │ │ ├── summary.md
│ │ │ └── unbounded_knapsack_problem.md
│ │ ├── chapter_graph/
│ │ │ ├── graph.md
│ │ │ ├── graph_operations.md
│ │ │ ├── graph_traversal.md
│ │ │ ├── index.md
│ │ │ └── summary.md
│ │ ├── chapter_greedy/
│ │ │ ├── fractional_knapsack_problem.md
│ │ │ ├── greedy_algorithm.md
│ │ │ ├── index.md
│ │ │ ├── max_capacity_problem.md
│ │ │ ├── max_product_cutting_problem.md
│ │ │ └── summary.md
│ │ ├── chapter_hashing/
│ │ │ ├── hash_algorithm.md
│ │ │ ├── hash_collision.md
│ │ │ ├── hash_map.md
│ │ │ ├── index.md
│ │ │ └── summary.md
│ │ ├── chapter_heap/
│ │ │ ├── build_heap.md
│ │ │ ├── heap.md
│ │ │ ├── index.md
│ │ │ ├── summary.md
│ │ │ └── top_k.md
│ │ ├── chapter_hello_algo/
│ │ │ └── index.md
│ │ ├── chapter_introduction/
│ │ │ ├── algorithms_are_everywhere.md
│ │ │ ├── index.md
│ │ │ ├── summary.md
│ │ │ └── what_is_dsa.md
│ │ ├── chapter_preface/
│ │ │ ├── about_the_book.md
│ │ │ ├── index.md
│ │ │ ├── suggestions.md
│ │ │ └── summary.md
│ │ ├── chapter_reference/
│ │ │ └── index.md
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.md
│ │ │ ├── binary_search_edge.md
│ │ │ ├── binary_search_insertion.md
│ │ │ ├── index.md
│ │ │ ├── replace_linear_by_hashing.md
│ │ │ ├── searching_algorithm_revisited.md
│ │ │ └── summary.md
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.md
│ │ │ ├── bucket_sort.md
│ │ │ ├── counting_sort.md
│ │ │ ├── heap_sort.md
│ │ │ ├── index.md
│ │ │ ├── insertion_sort.md
│ │ │ ├── merge_sort.md
│ │ │ ├── quick_sort.md
│ │ │ ├── radix_sort.md
│ │ │ ├── selection_sort.md
│ │ │ ├── sorting_algorithm.md
│ │ │ └── summary.md
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── deque.md
│ │ │ ├── index.md
│ │ │ ├── queue.md
│ │ │ ├── stack.md
│ │ │ └── summary.md
│ │ ├── chapter_tree/
│ │ │ ├── array_representation_of_tree.md
│ │ │ ├── avl_tree.md
│ │ │ ├── binary_search_tree.md
│ │ │ ├── binary_tree.md
│ │ │ ├── binary_tree_traversal.md
│ │ │ ├── index.md
│ │ │ └── summary.md
│ │ ├── index.html
│ │ └── index.md
│ └── mkdocs.yml
├── giscus.json
├── ja/
│ ├── README.md
│ ├── codes/
│ │ ├── c/
│ │ │ ├── .gitignore
│ │ │ ├── CMakeLists.txt
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array.c
│ │ │ │ ├── linked_list.c
│ │ │ │ └── my_list.c
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── n_queens.c
│ │ │ │ ├── permutations_i.c
│ │ │ │ ├── permutations_ii.c
│ │ │ │ ├── preorder_traversal_i_compact.c
│ │ │ │ ├── preorder_traversal_ii_compact.c
│ │ │ │ ├── preorder_traversal_iii_compact.c
│ │ │ │ ├── preorder_traversal_iii_template.c
│ │ │ │ ├── subset_sum_i.c
│ │ │ │ ├── subset_sum_i_naive.c
│ │ │ │ └── subset_sum_ii.c
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── iteration.c
│ │ │ │ ├── recursion.c
│ │ │ │ ├── space_complexity.c
│ │ │ │ ├── time_complexity.c
│ │ │ │ └── worst_best_time_complexity.c
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── binary_search_recur.c
│ │ │ │ ├── build_tree.c
│ │ │ │ └── hanota.c
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── climbing_stairs_backtrack.c
│ │ │ │ ├── climbing_stairs_constraint_dp.c
│ │ │ │ ├── climbing_stairs_dfs.c
│ │ │ │ ├── climbing_stairs_dfs_mem.c
│ │ │ │ ├── climbing_stairs_dp.c
│ │ │ │ ├── coin_change.c
│ │ │ │ ├── coin_change_ii.c
│ │ │ │ ├── edit_distance.c
│ │ │ │ ├── knapsack.c
│ │ │ │ ├── min_cost_climbing_stairs_dp.c
│ │ │ │ ├── min_path_sum.c
│ │ │ │ └── unbounded_knapsack.c
│ │ │ ├── chapter_graph/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── graph_adjacency_list.c
│ │ │ │ ├── graph_adjacency_list_test.c
│ │ │ │ ├── graph_adjacency_matrix.c
│ │ │ │ ├── graph_bfs.c
│ │ │ │ └── graph_dfs.c
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── coin_change_greedy.c
│ │ │ │ ├── fractional_knapsack.c
│ │ │ │ ├── max_capacity.c
│ │ │ │ └── max_product_cutting.c
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_hash_map.c
│ │ │ │ ├── hash_map_chaining.c
│ │ │ │ ├── hash_map_open_addressing.c
│ │ │ │ └── simple_hash.c
│ │ │ ├── chapter_heap/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── my_heap.c
│ │ │ │ ├── my_heap_test.c
│ │ │ │ └── top_k.c
│ │ │ ├── chapter_searching/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── binary_search.c
│ │ │ │ ├── binary_search_edge.c
│ │ │ │ ├── binary_search_insertion.c
│ │ │ │ └── two_sum.c
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── bubble_sort.c
│ │ │ │ ├── bucket_sort.c
│ │ │ │ ├── counting_sort.c
│ │ │ │ ├── heap_sort.c
│ │ │ │ ├── insertion_sort.c
│ │ │ │ ├── merge_sort.c
│ │ │ │ ├── quick_sort.c
│ │ │ │ ├── radix_sort.c
│ │ │ │ └── selection_sort.c
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_deque.c
│ │ │ │ ├── array_queue.c
│ │ │ │ ├── array_stack.c
│ │ │ │ ├── linkedlist_deque.c
│ │ │ │ ├── linkedlist_queue.c
│ │ │ │ └── linkedlist_stack.c
│ │ │ ├── chapter_tree/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_binary_tree.c
│ │ │ │ ├── avl_tree.c
│ │ │ │ ├── binary_search_tree.c
│ │ │ │ ├── binary_tree.c
│ │ │ │ ├── binary_tree_bfs.c
│ │ │ │ └── binary_tree_dfs.c
│ │ │ └── utils/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── common.h
│ │ │ ├── common_test.c
│ │ │ ├── list_node.h
│ │ │ ├── print_util.h
│ │ │ ├── tree_node.h
│ │ │ ├── uthash.h
│ │ │ ├── vector.h
│ │ │ └── vertex.h
│ │ ├── cpp/
│ │ │ ├── .gitignore
│ │ │ ├── CMakeLists.txt
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array.cpp
│ │ │ │ ├── linked_list.cpp
│ │ │ │ ├── list.cpp
│ │ │ │ └── my_list.cpp
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── n_queens.cpp
│ │ │ │ ├── permutations_i.cpp
│ │ │ │ ├── permutations_ii.cpp
│ │ │ │ ├── preorder_traversal_i_compact.cpp
│ │ │ │ ├── preorder_traversal_ii_compact.cpp
│ │ │ │ ├── preorder_traversal_iii_compact.cpp
│ │ │ │ ├── preorder_traversal_iii_template.cpp
│ │ │ │ ├── subset_sum_i.cpp
│ │ │ │ ├── subset_sum_i_naive.cpp
│ │ │ │ └── subset_sum_ii.cpp
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── iteration.cpp
│ │ │ │ ├── recursion.cpp
│ │ │ │ ├── space_complexity.cpp
│ │ │ │ ├── time_complexity.cpp
│ │ │ │ └── worst_best_time_complexity.cpp
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── binary_search_recur.cpp
│ │ │ │ ├── build_tree.cpp
│ │ │ │ └── hanota.cpp
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── climbing_stairs_backtrack.cpp
│ │ │ │ ├── climbing_stairs_constraint_dp.cpp
│ │ │ │ ├── climbing_stairs_dfs.cpp
│ │ │ │ ├── climbing_stairs_dfs_mem.cpp
│ │ │ │ ├── climbing_stairs_dp.cpp
│ │ │ │ ├── coin_change.cpp
│ │ │ │ ├── coin_change_ii.cpp
│ │ │ │ ├── edit_distance.cpp
│ │ │ │ ├── knapsack.cpp
│ │ │ │ ├── min_cost_climbing_stairs_dp.cpp
│ │ │ │ ├── min_path_sum.cpp
│ │ │ │ └── unbounded_knapsack.cpp
│ │ │ ├── chapter_graph/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── graph_adjacency_list.cpp
│ │ │ │ ├── graph_adjacency_list_test.cpp
│ │ │ │ ├── graph_adjacency_matrix.cpp
│ │ │ │ ├── graph_bfs.cpp
│ │ │ │ └── graph_dfs.cpp
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── coin_change_greedy.cpp
│ │ │ │ ├── fractional_knapsack.cpp
│ │ │ │ ├── max_capacity.cpp
│ │ │ │ └── max_product_cutting.cpp
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_hash_map.cpp
│ │ │ │ ├── array_hash_map_test.cpp
│ │ │ │ ├── built_in_hash.cpp
│ │ │ │ ├── hash_map.cpp
│ │ │ │ ├── hash_map_chaining.cpp
│ │ │ │ ├── hash_map_open_addressing.cpp
│ │ │ │ └── simple_hash.cpp
│ │ │ ├── chapter_heap/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── heap.cpp
│ │ │ │ ├── my_heap.cpp
│ │ │ │ └── top_k.cpp
│ │ │ ├── chapter_searching/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── binary_search.cpp
│ │ │ │ ├── binary_search_edge.cpp
│ │ │ │ ├── binary_search_insertion.cpp
│ │ │ │ ├── hashing_search.cpp
│ │ │ │ ├── linear_search.cpp
│ │ │ │ └── two_sum.cpp
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── bubble_sort.cpp
│ │ │ │ ├── bucket_sort.cpp
│ │ │ │ ├── counting_sort.cpp
│ │ │ │ ├── heap_sort.cpp
│ │ │ │ ├── insertion_sort.cpp
│ │ │ │ ├── merge_sort.cpp
│ │ │ │ ├── quick_sort.cpp
│ │ │ │ ├── radix_sort.cpp
│ │ │ │ └── selection_sort.cpp
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_deque.cpp
│ │ │ │ ├── array_queue.cpp
│ │ │ │ ├── array_stack.cpp
│ │ │ │ ├── deque.cpp
│ │ │ │ ├── linkedlist_deque.cpp
│ │ │ │ ├── linkedlist_queue.cpp
│ │ │ │ ├── linkedlist_stack.cpp
│ │ │ │ ├── queue.cpp
│ │ │ │ └── stack.cpp
│ │ │ ├── chapter_tree/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_binary_tree.cpp
│ │ │ │ ├── avl_tree.cpp
│ │ │ │ ├── binary_search_tree.cpp
│ │ │ │ ├── binary_tree.cpp
│ │ │ │ ├── binary_tree_bfs.cpp
│ │ │ │ └── binary_tree_dfs.cpp
│ │ │ └── utils/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── common.hpp
│ │ │ ├── list_node.hpp
│ │ │ ├── print_utils.hpp
│ │ │ ├── tree_node.hpp
│ │ │ └── vertex.hpp
│ │ ├── csharp/
│ │ │ ├── .editorconfig
│ │ │ ├── .gitignore
│ │ │ ├── GlobalUsing.cs
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.cs
│ │ │ │ ├── linked_list.cs
│ │ │ │ ├── list.cs
│ │ │ │ └── my_list.cs
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.cs
│ │ │ │ ├── permutations_i.cs
│ │ │ │ ├── permutations_ii.cs
│ │ │ │ ├── preorder_traversal_i_compact.cs
│ │ │ │ ├── preorder_traversal_ii_compact.cs
│ │ │ │ ├── preorder_traversal_iii_compact.cs
│ │ │ │ ├── preorder_traversal_iii_template.cs
│ │ │ │ ├── subset_sum_i.cs
│ │ │ │ ├── subset_sum_i_naive.cs
│ │ │ │ └── subset_sum_ii.cs
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.cs
│ │ │ │ ├── recursion.cs
│ │ │ │ ├── space_complexity.cs
│ │ │ │ ├── time_complexity.cs
│ │ │ │ └── worst_best_time_complexity.cs
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.cs
│ │ │ │ ├── build_tree.cs
│ │ │ │ └── hanota.cs
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.cs
│ │ │ │ ├── climbing_stairs_constraint_dp.cs
│ │ │ │ ├── climbing_stairs_dfs.cs
│ │ │ │ ├── climbing_stairs_dfs_mem.cs
│ │ │ │ ├── climbing_stairs_dp.cs
│ │ │ │ ├── coin_change.cs
│ │ │ │ ├── coin_change_ii.cs
│ │ │ │ ├── edit_distance.cs
│ │ │ │ ├── knapsack.cs
│ │ │ │ ├── min_cost_climbing_stairs_dp.cs
│ │ │ │ ├── min_path_sum.cs
│ │ │ │ └── unbounded_knapsack.cs
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.cs
│ │ │ │ ├── graph_adjacency_matrix.cs
│ │ │ │ ├── graph_bfs.cs
│ │ │ │ └── graph_dfs.cs
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.cs
│ │ │ │ ├── fractional_knapsack.cs
│ │ │ │ ├── max_capacity.cs
│ │ │ │ └── max_product_cutting.cs
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.cs
│ │ │ │ ├── built_in_hash.cs
│ │ │ │ ├── hash_map.cs
│ │ │ │ ├── hash_map_chaining.cs
│ │ │ │ ├── hash_map_open_addressing.cs
│ │ │ │ └── simple_hash.cs
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.cs
│ │ │ │ ├── my_heap.cs
│ │ │ │ └── top_k.cs
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.cs
│ │ │ │ ├── binary_search_edge.cs
│ │ │ │ ├── binary_search_insertion.cs
│ │ │ │ ├── hashing_search.cs
│ │ │ │ ├── linear_search.cs
│ │ │ │ └── two_sum.cs
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.cs
│ │ │ │ ├── bucket_sort.cs
│ │ │ │ ├── counting_sort.cs
│ │ │ │ ├── heap_sort.cs
│ │ │ │ ├── insertion_sort.cs
│ │ │ │ ├── merge_sort.cs
│ │ │ │ ├── quick_sort.cs
│ │ │ │ ├── radix_sort.cs
│ │ │ │ └── selection_sort.cs
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.cs
│ │ │ │ ├── array_queue.cs
│ │ │ │ ├── array_stack.cs
│ │ │ │ ├── deque.cs
│ │ │ │ ├── linkedlist_deque.cs
│ │ │ │ ├── linkedlist_queue.cs
│ │ │ │ ├── linkedlist_stack.cs
│ │ │ │ ├── queue.cs
│ │ │ │ └── stack.cs
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.cs
│ │ │ │ ├── avl_tree.cs
│ │ │ │ ├── binary_search_tree.cs
│ │ │ │ ├── binary_tree.cs
│ │ │ │ ├── binary_tree_bfs.cs
│ │ │ │ └── binary_tree_dfs.cs
│ │ │ ├── csharp.sln
│ │ │ ├── hello-algo.csproj
│ │ │ └── utils/
│ │ │ ├── ListNode.cs
│ │ │ ├── PrintUtil.cs
│ │ │ ├── TreeNode.cs
│ │ │ └── Vertex.cs
│ │ ├── dart/
│ │ │ ├── build.dart
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.dart
│ │ │ │ ├── linked_list.dart
│ │ │ │ ├── list.dart
│ │ │ │ └── my_list.dart
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.dart
│ │ │ │ ├── permutations_i.dart
│ │ │ │ ├── permutations_ii.dart
│ │ │ │ ├── preorder_traversal_i_compact.dart
│ │ │ │ ├── preorder_traversal_ii_compact.dart
│ │ │ │ ├── preorder_traversal_iii_compact.dart
│ │ │ │ ├── preorder_traversal_iii_template.dart
│ │ │ │ ├── subset_sum_i.dart
│ │ │ │ ├── subset_sum_i_naive.dart
│ │ │ │ └── subset_sum_ii.dart
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.dart
│ │ │ │ ├── recursion.dart
│ │ │ │ ├── space_complexity.dart
│ │ │ │ ├── time_complexity.dart
│ │ │ │ └── worst_best_time_complexity.dart
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.dart
│ │ │ │ ├── build_tree.dart
│ │ │ │ └── hanota.dart
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.dart
│ │ │ │ ├── climbing_stairs_constraint_dp.dart
│ │ │ │ ├── climbing_stairs_dfs.dart
│ │ │ │ ├── climbing_stairs_dfs_mem.dart
│ │ │ │ ├── climbing_stairs_dp.dart
│ │ │ │ ├── coin_change.dart
│ │ │ │ ├── coin_change_ii.dart
│ │ │ │ ├── edit_distance.dart
│ │ │ │ ├── knapsack.dart
│ │ │ │ ├── min_cost_climbing_stairs_dp.dart
│ │ │ │ ├── min_path_sum.dart
│ │ │ │ └── unbounded_knapsack.dart
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.dart
│ │ │ │ ├── graph_adjacency_matrix.dart
│ │ │ │ ├── graph_bfs.dart
│ │ │ │ └── graph_dfs.dart
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.dart
│ │ │ │ ├── fractional_knapsack.dart
│ │ │ │ ├── max_capacity.dart
│ │ │ │ └── max_product_cutting.dart
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.dart
│ │ │ │ ├── built_in_hash.dart
│ │ │ │ ├── hash_map.dart
│ │ │ │ ├── hash_map_chaining.dart
│ │ │ │ ├── hash_map_open_addressing.dart
│ │ │ │ └── simple_hash.dart
│ │ │ ├── chapter_heap/
│ │ │ │ ├── my_heap.dart
│ │ │ │ └── top_k.dart
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.dart
│ │ │ │ ├── binary_search_edge.dart
│ │ │ │ ├── binary_search_insertion.dart
│ │ │ │ ├── hashing_search.dart
│ │ │ │ ├── linear_search.dart
│ │ │ │ └── two_sum.dart
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.dart
│ │ │ │ ├── bucket_sort.dart
│ │ │ │ ├── counting_sort.dart
│ │ │ │ ├── heap_sort.dart
│ │ │ │ ├── insertion_sort.dart
│ │ │ │ ├── merge_sort.dart
│ │ │ │ ├── quick_sort.dart
│ │ │ │ ├── radix_sort.dart
│ │ │ │ └── selection_sort.dart
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.dart
│ │ │ │ ├── array_queue.dart
│ │ │ │ ├── array_stack.dart
│ │ │ │ ├── deque.dart
│ │ │ │ ├── linkedlist_deque.dart
│ │ │ │ ├── linkedlist_queue.dart
│ │ │ │ ├── linkedlist_stack.dart
│ │ │ │ ├── queue.dart
│ │ │ │ └── stack.dart
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.dart
│ │ │ │ ├── avl_tree.dart
│ │ │ │ ├── binary_search_tree.dart
│ │ │ │ ├── binary_tree.dart
│ │ │ │ ├── binary_tree_bfs.dart
│ │ │ │ └── binary_tree_dfs.dart
│ │ │ └── utils/
│ │ │ ├── list_node.dart
│ │ │ ├── print_util.dart
│ │ │ ├── tree_node.dart
│ │ │ └── vertex.dart
│ │ ├── go/
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.go
│ │ │ │ ├── array_test.go
│ │ │ │ ├── linked_list.go
│ │ │ │ ├── linked_list_test.go
│ │ │ │ ├── list_test.go
│ │ │ │ ├── my_list.go
│ │ │ │ └── my_list_test.go
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.go
│ │ │ │ ├── n_queens_test.go
│ │ │ │ ├── permutation_test.go
│ │ │ │ ├── permutations_i.go
│ │ │ │ ├── permutations_ii.go
│ │ │ │ ├── preorder_traversal_i_compact.go
│ │ │ │ ├── preorder_traversal_ii_compact.go
│ │ │ │ ├── preorder_traversal_iii_compact.go
│ │ │ │ ├── preorder_traversal_iii_template.go
│ │ │ │ ├── preorder_traversal_test.go
│ │ │ │ ├── subset_sum_i.go
│ │ │ │ ├── subset_sum_i_naive.go
│ │ │ │ ├── subset_sum_ii.go
│ │ │ │ └── subset_sum_test.go
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.go
│ │ │ │ ├── iteration_test.go
│ │ │ │ ├── recursion.go
│ │ │ │ ├── recursion_test.go
│ │ │ │ ├── space_complexity.go
│ │ │ │ ├── space_complexity_test.go
│ │ │ │ ├── time_complexity.go
│ │ │ │ ├── time_complexity_test.go
│ │ │ │ ├── worst_best_time_complexity.go
│ │ │ │ └── worst_best_time_complexity_test.go
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.go
│ │ │ │ ├── binary_search_recur_test.go
│ │ │ │ ├── build_tree.go
│ │ │ │ ├── build_tree_test.go
│ │ │ │ ├── hanota.go
│ │ │ │ └── hanota_test.go
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.go
│ │ │ │ ├── climbing_stairs_constraint_dp.go
│ │ │ │ ├── climbing_stairs_dfs.go
│ │ │ │ ├── climbing_stairs_dfs_mem.go
│ │ │ │ ├── climbing_stairs_dp.go
│ │ │ │ ├── climbing_stairs_test.go
│ │ │ │ ├── coin_change.go
│ │ │ │ ├── coin_change_ii.go
│ │ │ │ ├── coin_change_test.go
│ │ │ │ ├── edit_distance.go
│ │ │ │ ├── edit_distance_test.go
│ │ │ │ ├── knapsack.go
│ │ │ │ ├── knapsack_test.go
│ │ │ │ ├── min_cost_climbing_stairs_dp.go
│ │ │ │ ├── min_path_sum.go
│ │ │ │ ├── min_path_sum_test.go
│ │ │ │ └── unbounded_knapsack.go
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.go
│ │ │ │ ├── graph_adjacency_list_test.go
│ │ │ │ ├── graph_adjacency_matrix.go
│ │ │ │ ├── graph_adjacency_matrix_test.go
│ │ │ │ ├── graph_bfs.go
│ │ │ │ ├── graph_bfs_test.go
│ │ │ │ ├── graph_dfs.go
│ │ │ │ └── graph_dfs_test.go
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.go
│ │ │ │ ├── coin_change_greedy_test.go
│ │ │ │ ├── fractional_knapsack.go
│ │ │ │ ├── fractional_knapsack_test.go
│ │ │ │ ├── max_capacity.go
│ │ │ │ ├── max_capacity_test.go
│ │ │ │ ├── max_product_cutting.go
│ │ │ │ └── max_product_cutting_test.go
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.go
│ │ │ │ ├── array_hash_map_test.go
│ │ │ │ ├── hash_collision_test.go
│ │ │ │ ├── hash_map_chaining.go
│ │ │ │ ├── hash_map_open_addressing.go
│ │ │ │ ├── hash_map_test.go
│ │ │ │ └── simple_hash.go
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.go
│ │ │ │ ├── heap_test.go
│ │ │ │ ├── my_heap.go
│ │ │ │ └── top_k.go
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.go
│ │ │ │ ├── binary_search_edge.go
│ │ │ │ ├── binary_search_insertion.go
│ │ │ │ ├── binary_search_test.go
│ │ │ │ ├── hashing_search.go
│ │ │ │ ├── hashing_search_test.go
│ │ │ │ ├── linear_search.go
│ │ │ │ ├── linear_search_test.go
│ │ │ │ ├── two_sum.go
│ │ │ │ └── two_sum_test.go
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.go
│ │ │ │ ├── bubble_sort_test.go
│ │ │ │ ├── bucket_sort.go
│ │ │ │ ├── bucket_sort_test.go
│ │ │ │ ├── counting_sort.go
│ │ │ │ ├── counting_sort_test.go
│ │ │ │ ├── heap_sort.go
│ │ │ │ ├── heap_sort_test.go
│ │ │ │ ├── insertion_sort.go
│ │ │ │ ├── insertion_sort_test.go
│ │ │ │ ├── merge_sort.go
│ │ │ │ ├── merge_sort_test.go
│ │ │ │ ├── quick_sort.go
│ │ │ │ ├── quick_sort_test.go
│ │ │ │ ├── radix_sort.go
│ │ │ │ ├── radix_sort_test.go
│ │ │ │ ├── selection_sort.go
│ │ │ │ └── selection_sort_test.go
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.go
│ │ │ │ ├── array_queue.go
│ │ │ │ ├── array_stack.go
│ │ │ │ ├── deque_test.go
│ │ │ │ ├── linkedlist_deque.go
│ │ │ │ ├── linkedlist_queue.go
│ │ │ │ ├── linkedlist_stack.go
│ │ │ │ ├── queue_test.go
│ │ │ │ └── stack_test.go
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.go
│ │ │ │ ├── array_binary_tree_test.go
│ │ │ │ ├── avl_tree.go
│ │ │ │ ├── avl_tree_test.go
│ │ │ │ ├── binary_search_tree.go
│ │ │ │ ├── binary_search_tree_test.go
│ │ │ │ ├── binary_tree_bfs.go
│ │ │ │ ├── binary_tree_bfs_test.go
│ │ │ │ ├── binary_tree_dfs.go
│ │ │ │ ├── binary_tree_dfs_test.go
│ │ │ │ └── binary_tree_test.go
│ │ │ ├── go.mod
│ │ │ └── pkg/
│ │ │ ├── list_node.go
│ │ │ ├── list_node_test.go
│ │ │ ├── print_utils.go
│ │ │ ├── tree_node.go
│ │ │ ├── tree_node_test.go
│ │ │ └── vertex.go
│ │ ├── java/
│ │ │ ├── .gitignore
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.java
│ │ │ │ ├── linked_list.java
│ │ │ │ ├── list.java
│ │ │ │ └── my_list.java
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.java
│ │ │ │ ├── permutations_i.java
│ │ │ │ ├── permutations_ii.java
│ │ │ │ ├── preorder_traversal_i_compact.java
│ │ │ │ ├── preorder_traversal_ii_compact.java
│ │ │ │ ├── preorder_traversal_iii_compact.java
│ │ │ │ ├── preorder_traversal_iii_template.java
│ │ │ │ ├── subset_sum_i.java
│ │ │ │ ├── subset_sum_i_naive.java
│ │ │ │ └── subset_sum_ii.java
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.java
│ │ │ │ ├── recursion.java
│ │ │ │ ├── space_complexity.java
│ │ │ │ ├── time_complexity.java
│ │ │ │ └── worst_best_time_complexity.java
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.java
│ │ │ │ ├── build_tree.java
│ │ │ │ └── hanota.java
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.java
│ │ │ │ ├── climbing_stairs_constraint_dp.java
│ │ │ │ ├── climbing_stairs_dfs.java
│ │ │ │ ├── climbing_stairs_dfs_mem.java
│ │ │ │ ├── climbing_stairs_dp.java
│ │ │ │ ├── coin_change.java
│ │ │ │ ├── coin_change_ii.java
│ │ │ │ ├── edit_distance.java
│ │ │ │ ├── knapsack.java
│ │ │ │ ├── min_cost_climbing_stairs_dp.java
│ │ │ │ ├── min_path_sum.java
│ │ │ │ └── unbounded_knapsack.java
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.java
│ │ │ │ ├── graph_adjacency_matrix.java
│ │ │ │ ├── graph_bfs.java
│ │ │ │ └── graph_dfs.java
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.java
│ │ │ │ ├── fractional_knapsack.java
│ │ │ │ ├── max_capacity.java
│ │ │ │ └── max_product_cutting.java
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.java
│ │ │ │ ├── built_in_hash.java
│ │ │ │ ├── hash_map.java
│ │ │ │ ├── hash_map_chaining.java
│ │ │ │ ├── hash_map_open_addressing.java
│ │ │ │ └── simple_hash.java
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.java
│ │ │ │ ├── my_heap.java
│ │ │ │ └── top_k.java
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.java
│ │ │ │ ├── binary_search_edge.java
│ │ │ │ ├── binary_search_insertion.java
│ │ │ │ ├── hashing_search.java
│ │ │ │ ├── linear_search.java
│ │ │ │ └── two_sum.java
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.java
│ │ │ │ ├── bucket_sort.java
│ │ │ │ ├── counting_sort.java
│ │ │ │ ├── heap_sort.java
│ │ │ │ ├── insertion_sort.java
│ │ │ │ ├── merge_sort.java
│ │ │ │ ├── quick_sort.java
│ │ │ │ ├── radix_sort.java
│ │ │ │ └── selection_sort.java
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.java
│ │ │ │ ├── array_queue.java
│ │ │ │ ├── array_stack.java
│ │ │ │ ├── deque.java
│ │ │ │ ├── linkedlist_deque.java
│ │ │ │ ├── linkedlist_queue.java
│ │ │ │ ├── linkedlist_stack.java
│ │ │ │ ├── queue.java
│ │ │ │ └── stack.java
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.java
│ │ │ │ ├── avl_tree.java
│ │ │ │ ├── binary_search_tree.java
│ │ │ │ ├── binary_tree.java
│ │ │ │ ├── binary_tree_bfs.java
│ │ │ │ └── binary_tree_dfs.java
│ │ │ └── utils/
│ │ │ ├── ListNode.java
│ │ │ ├── PrintUtil.java
│ │ │ ├── TreeNode.java
│ │ │ └── Vertex.java
│ │ ├── javascript/
│ │ │ ├── .prettierrc
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.js
│ │ │ │ ├── linked_list.js
│ │ │ │ ├── list.js
│ │ │ │ └── my_list.js
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.js
│ │ │ │ ├── permutations_i.js
│ │ │ │ ├── permutations_ii.js
│ │ │ │ ├── preorder_traversal_i_compact.js
│ │ │ │ ├── preorder_traversal_ii_compact.js
│ │ │ │ ├── preorder_traversal_iii_compact.js
│ │ │ │ ├── preorder_traversal_iii_template.js
│ │ │ │ ├── subset_sum_i.js
│ │ │ │ ├── subset_sum_i_naive.js
│ │ │ │ └── subset_sum_ii.js
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.js
│ │ │ │ ├── recursion.js
│ │ │ │ ├── space_complexity.js
│ │ │ │ ├── time_complexity.js
│ │ │ │ └── worst_best_time_complexity.js
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.js
│ │ │ │ ├── build_tree.js
│ │ │ │ └── hanota.js
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.js
│ │ │ │ ├── climbing_stairs_constraint_dp.js
│ │ │ │ ├── climbing_stairs_dfs.js
│ │ │ │ ├── climbing_stairs_dfs_mem.js
│ │ │ │ ├── climbing_stairs_dp.js
│ │ │ │ ├── coin_change.js
│ │ │ │ ├── coin_change_ii.js
│ │ │ │ ├── edit_distance.js
│ │ │ │ ├── knapsack.js
│ │ │ │ ├── min_cost_climbing_stairs_dp.js
│ │ │ │ ├── min_path_sum.js
│ │ │ │ └── unbounded_knapsack.js
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.js
│ │ │ │ ├── graph_adjacency_matrix.js
│ │ │ │ ├── graph_bfs.js
│ │ │ │ └── graph_dfs.js
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.js
│ │ │ │ ├── fractional_knapsack.js
│ │ │ │ ├── max_capacity.js
│ │ │ │ └── max_product_cutting.js
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.js
│ │ │ │ ├── hash_map.js
│ │ │ │ ├── hash_map_chaining.js
│ │ │ │ ├── hash_map_open_addressing.js
│ │ │ │ └── simple_hash.js
│ │ │ ├── chapter_heap/
│ │ │ │ ├── my_heap.js
│ │ │ │ └── top_k.js
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.js
│ │ │ │ ├── binary_search_edge.js
│ │ │ │ ├── binary_search_insertion.js
│ │ │ │ ├── hashing_search.js
│ │ │ │ ├── linear_search.js
│ │ │ │ └── two_sum.js
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.js
│ │ │ │ ├── bucket_sort.js
│ │ │ │ ├── counting_sort.js
│ │ │ │ ├── heap_sort.js
│ │ │ │ ├── insertion_sort.js
│ │ │ │ ├── merge_sort.js
│ │ │ │ ├── quick_sort.js
│ │ │ │ ├── radix_sort.js
│ │ │ │ └── selection_sort.js
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.js
│ │ │ │ ├── array_queue.js
│ │ │ │ ├── array_stack.js
│ │ │ │ ├── deque.js
│ │ │ │ ├── linkedlist_deque.js
│ │ │ │ ├── linkedlist_queue.js
│ │ │ │ ├── linkedlist_stack.js
│ │ │ │ ├── queue.js
│ │ │ │ └── stack.js
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.js
│ │ │ │ ├── avl_tree.js
│ │ │ │ ├── binary_search_tree.js
│ │ │ │ ├── binary_tree.js
│ │ │ │ ├── binary_tree_bfs.js
│ │ │ │ └── binary_tree_dfs.js
│ │ │ ├── modules/
│ │ │ │ ├── ListNode.js
│ │ │ │ ├── PrintUtil.js
│ │ │ │ ├── TreeNode.js
│ │ │ │ └── Vertex.js
│ │ │ └── test_all.js
│ │ ├── kotlin/
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.kt
│ │ │ │ ├── linked_list.kt
│ │ │ │ ├── list.kt
│ │ │ │ └── my_list.kt
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.kt
│ │ │ │ ├── permutations_i.kt
│ │ │ │ ├── permutations_ii.kt
│ │ │ │ ├── preorder_traversal_i_compact.kt
│ │ │ │ ├── preorder_traversal_ii_compact.kt
│ │ │ │ ├── preorder_traversal_iii_compact.kt
│ │ │ │ ├── preorder_traversal_iii_template.kt
│ │ │ │ ├── subset_sum_i.kt
│ │ │ │ ├── subset_sum_i_naive.kt
│ │ │ │ └── subset_sum_ii.kt
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.kt
│ │ │ │ ├── recursion.kt
│ │ │ │ ├── space_complexity.kt
│ │ │ │ ├── time_complexity.kt
│ │ │ │ └── worst_best_time_complexity.kt
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.kt
│ │ │ │ ├── build_tree.kt
│ │ │ │ └── hanota.kt
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.kt
│ │ │ │ ├── climbing_stairs_constraint_dp.kt
│ │ │ │ ├── climbing_stairs_dfs.kt
│ │ │ │ ├── climbing_stairs_dfs_mem.kt
│ │ │ │ ├── climbing_stairs_dp.kt
│ │ │ │ ├── coin_change.kt
│ │ │ │ ├── coin_change_ii.kt
│ │ │ │ ├── edit_distance.kt
│ │ │ │ ├── knapsack.kt
│ │ │ │ ├── min_cost_climbing_stairs_dp.kt
│ │ │ │ ├── min_path_sum.kt
│ │ │ │ └── unbounded_knapsack.kt
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.kt
│ │ │ │ ├── graph_adjacency_matrix.kt
│ │ │ │ ├── graph_bfs.kt
│ │ │ │ └── graph_dfs.kt
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.kt
│ │ │ │ ├── fractional_knapsack.kt
│ │ │ │ ├── max_capacity.kt
│ │ │ │ └── max_product_cutting.kt
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.kt
│ │ │ │ ├── built_in_hash.kt
│ │ │ │ ├── hash_map.kt
│ │ │ │ ├── hash_map_chaining.kt
│ │ │ │ ├── hash_map_open_addressing.kt
│ │ │ │ └── simple_hash.kt
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.kt
│ │ │ │ ├── my_heap.kt
│ │ │ │ └── top_k.kt
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.kt
│ │ │ │ ├── binary_search_edge.kt
│ │ │ │ ├── binary_search_insertion.kt
│ │ │ │ ├── hashing_search.kt
│ │ │ │ ├── linear_search.kt
│ │ │ │ └── two_sum.kt
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.kt
│ │ │ │ ├── bucket_sort.kt
│ │ │ │ ├── counting_sort.kt
│ │ │ │ ├── heap_sort.kt
│ │ │ │ ├── insertion_sort.kt
│ │ │ │ ├── merge_sort.kt
│ │ │ │ ├── quick_sort.kt
│ │ │ │ ├── radix_sort.kt
│ │ │ │ └── selection_sort.kt
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.kt
│ │ │ │ ├── array_queue.kt
│ │ │ │ ├── array_stack.kt
│ │ │ │ ├── deque.kt
│ │ │ │ ├── linkedlist_deque.kt
│ │ │ │ ├── linkedlist_queue.kt
│ │ │ │ ├── linkedlist_stack.kt
│ │ │ │ ├── queue.kt
│ │ │ │ └── stack.kt
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.kt
│ │ │ │ ├── avl_tree.kt
│ │ │ │ ├── binary_search_tree.kt
│ │ │ │ ├── binary_tree.kt
│ │ │ │ ├── binary_tree_bfs.kt
│ │ │ │ └── binary_tree_dfs.kt
│ │ │ └── utils/
│ │ │ ├── ListNode.kt
│ │ │ ├── PrintUtil.kt
│ │ │ ├── TreeNode.kt
│ │ │ └── Vertex.kt
│ │ ├── python/
│ │ │ ├── .gitignore
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.py
│ │ │ │ ├── linked_list.py
│ │ │ │ ├── list.py
│ │ │ │ └── my_list.py
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.py
│ │ │ │ ├── permutations_i.py
│ │ │ │ ├── permutations_ii.py
│ │ │ │ ├── preorder_traversal_i_compact.py
│ │ │ │ ├── preorder_traversal_ii_compact.py
│ │ │ │ ├── preorder_traversal_iii_compact.py
│ │ │ │ ├── preorder_traversal_iii_template.py
│ │ │ │ ├── subset_sum_i.py
│ │ │ │ ├── subset_sum_i_naive.py
│ │ │ │ └── subset_sum_ii.py
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.py
│ │ │ │ ├── recursion.py
│ │ │ │ ├── space_complexity.py
│ │ │ │ ├── time_complexity.py
│ │ │ │ └── worst_best_time_complexity.py
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.py
│ │ │ │ ├── build_tree.py
│ │ │ │ └── hanota.py
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.py
│ │ │ │ ├── climbing_stairs_constraint_dp.py
│ │ │ │ ├── climbing_stairs_dfs.py
│ │ │ │ ├── climbing_stairs_dfs_mem.py
│ │ │ │ ├── climbing_stairs_dp.py
│ │ │ │ ├── coin_change.py
│ │ │ │ ├── coin_change_ii.py
│ │ │ │ ├── edit_distance.py
│ │ │ │ ├── knapsack.py
│ │ │ │ ├── min_cost_climbing_stairs_dp.py
│ │ │ │ ├── min_path_sum.py
│ │ │ │ └── unbounded_knapsack.py
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.py
│ │ │ │ ├── graph_adjacency_matrix.py
│ │ │ │ ├── graph_bfs.py
│ │ │ │ └── graph_dfs.py
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.py
│ │ │ │ ├── fractional_knapsack.py
│ │ │ │ ├── max_capacity.py
│ │ │ │ └── max_product_cutting.py
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.py
│ │ │ │ ├── built_in_hash.py
│ │ │ │ ├── hash_map.py
│ │ │ │ ├── hash_map_chaining.py
│ │ │ │ ├── hash_map_open_addressing.py
│ │ │ │ └── simple_hash.py
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.py
│ │ │ │ ├── my_heap.py
│ │ │ │ └── top_k.py
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.py
│ │ │ │ ├── binary_search_edge.py
│ │ │ │ ├── binary_search_insertion.py
│ │ │ │ ├── hashing_search.py
│ │ │ │ ├── linear_search.py
│ │ │ │ └── two_sum.py
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.py
│ │ │ │ ├── bucket_sort.py
│ │ │ │ ├── counting_sort.py
│ │ │ │ ├── heap_sort.py
│ │ │ │ ├── insertion_sort.py
│ │ │ │ ├── merge_sort.py
│ │ │ │ ├── quick_sort.py
│ │ │ │ ├── radix_sort.py
│ │ │ │ └── selection_sort.py
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.py
│ │ │ │ ├── array_queue.py
│ │ │ │ ├── array_stack.py
│ │ │ │ ├── deque.py
│ │ │ │ ├── linkedlist_deque.py
│ │ │ │ ├── linkedlist_queue.py
│ │ │ │ ├── linkedlist_stack.py
│ │ │ │ ├── queue.py
│ │ │ │ └── stack.py
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.py
│ │ │ │ ├── avl_tree.py
│ │ │ │ ├── binary_search_tree.py
│ │ │ │ ├── binary_tree.py
│ │ │ │ ├── binary_tree_bfs.py
│ │ │ │ └── binary_tree_dfs.py
│ │ │ ├── modules/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── list_node.py
│ │ │ │ ├── print_util.py
│ │ │ │ ├── tree_node.py
│ │ │ │ └── vertex.py
│ │ │ └── test_all.py
│ │ ├── pythontutor/
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.md
│ │ │ │ ├── linked_list.md
│ │ │ │ └── my_list.md
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.md
│ │ │ │ ├── permutations_i.md
│ │ │ │ ├── permutations_ii.md
│ │ │ │ ├── preorder_traversal_i_compact.md
│ │ │ │ ├── preorder_traversal_ii_compact.md
│ │ │ │ ├── preorder_traversal_iii_compact.md
│ │ │ │ ├── preorder_traversal_iii_template.md
│ │ │ │ ├── subset_sum_i.md
│ │ │ │ ├── subset_sum_i_naive.md
│ │ │ │ └── subset_sum_ii.md
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.md
│ │ │ │ ├── recursion.md
│ │ │ │ ├── space_complexity.md
│ │ │ │ ├── time_complexity.md
│ │ │ │ └── worst_best_time_complexity.md
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.md
│ │ │ │ ├── build_tree.md
│ │ │ │ └── hanota.md
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.md
│ │ │ │ ├── climbing_stairs_constraint_dp.md
│ │ │ │ ├── climbing_stairs_dfs.md
│ │ │ │ ├── climbing_stairs_dfs_mem.md
│ │ │ │ ├── climbing_stairs_dp.md
│ │ │ │ ├── coin_change.md
│ │ │ │ ├── coin_change_ii.md
│ │ │ │ ├── edit_distance.md
│ │ │ │ ├── knapsack.md
│ │ │ │ ├── min_cost_climbing_stairs_dp.md
│ │ │ │ ├── min_path_sum.md
│ │ │ │ └── unbounded_knapsack.md
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.md
│ │ │ │ ├── graph_adjacency_matrix.md
│ │ │ │ ├── graph_bfs.md
│ │ │ │ └── graph_dfs.md
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.md
│ │ │ │ ├── fractional_knapsack.md
│ │ │ │ ├── max_capacity.md
│ │ │ │ └── max_product_cutting.md
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.md
│ │ │ │ ├── hash_map_chaining.md
│ │ │ │ └── simple_hash.md
│ │ │ ├── chapter_heap/
│ │ │ │ ├── my_heap.md
│ │ │ │ └── top_k.md
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.md
│ │ │ │ ├── binary_search_edge.md
│ │ │ │ ├── binary_search_insertion.md
│ │ │ │ └── two_sum.md
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.md
│ │ │ │ ├── bucket_sort.md
│ │ │ │ ├── counting_sort.md
│ │ │ │ ├── heap_sort.md
│ │ │ │ ├── insertion_sort.md
│ │ │ │ ├── merge_sort.md
│ │ │ │ ├── quick_sort.md
│ │ │ │ ├── radix_sort.md
│ │ │ │ └── selection_sort.md
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_queue.md
│ │ │ │ ├── array_stack.md
│ │ │ │ ├── linkedlist_queue.md
│ │ │ │ └── linkedlist_stack.md
│ │ │ └── chapter_tree/
│ │ │ ├── array_binary_tree.md
│ │ │ ├── binary_search_tree.md
│ │ │ ├── binary_tree_bfs.md
│ │ │ └── binary_tree_dfs.md
│ │ ├── ruby/
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.rb
│ │ │ │ ├── linked_list.rb
│ │ │ │ ├── list.rb
│ │ │ │ └── my_list.rb
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.rb
│ │ │ │ ├── permutations_i.rb
│ │ │ │ ├── permutations_ii.rb
│ │ │ │ ├── preorder_traversal_i_compact.rb
│ │ │ │ ├── preorder_traversal_ii_compact.rb
│ │ │ │ ├── preorder_traversal_iii_compact.rb
│ │ │ │ ├── preorder_traversal_iii_template.rb
│ │ │ │ ├── subset_sum_i.rb
│ │ │ │ ├── subset_sum_i_naive.rb
│ │ │ │ └── subset_sum_ii.rb
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.rb
│ │ │ │ ├── recursion.rb
│ │ │ │ ├── space_complexity.rb
│ │ │ │ ├── time_complexity.rb
│ │ │ │ └── worst_best_time_complexity.rb
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.rb
│ │ │ │ ├── build_tree.rb
│ │ │ │ └── hanota.rb
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.rb
│ │ │ │ ├── climbing_stairs_constraint_dp.rb
│ │ │ │ ├── climbing_stairs_dfs.rb
│ │ │ │ ├── climbing_stairs_dfs_mem.rb
│ │ │ │ ├── climbing_stairs_dp.rb
│ │ │ │ ├── coin_change.rb
│ │ │ │ ├── coin_change_ii.rb
│ │ │ │ ├── edit_distance.rb
│ │ │ │ ├── knapsack.rb
│ │ │ │ ├── min_cost_climbing_stairs_dp.rb
│ │ │ │ ├── min_path_sum.rb
│ │ │ │ └── unbounded_knapsack.rb
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.rb
│ │ │ │ ├── graph_adjacency_matrix.rb
│ │ │ │ ├── graph_bfs.rb
│ │ │ │ └── graph_dfs.rb
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.rb
│ │ │ │ ├── fractional_knapsack.rb
│ │ │ │ ├── max_capacity.rb
│ │ │ │ └── max_product_cutting.rb
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.rb
│ │ │ │ ├── built_in_hash.rb
│ │ │ │ ├── hash_map.rb
│ │ │ │ ├── hash_map_chaining.rb
│ │ │ │ ├── hash_map_open_addressing.rb
│ │ │ │ └── simple_hash.rb
│ │ │ ├── chapter_heap/
│ │ │ │ ├── my_heap.rb
│ │ │ │ └── top_k.rb
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.rb
│ │ │ │ ├── binary_search_edge.rb
│ │ │ │ ├── binary_search_insertion.rb
│ │ │ │ ├── hashing_search.rb
│ │ │ │ ├── linear_search.rb
│ │ │ │ └── two_sum.rb
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.rb
│ │ │ │ ├── bucket_sort.rb
│ │ │ │ ├── counting_sort.rb
│ │ │ │ ├── heap_sort.rb
│ │ │ │ ├── insertion_sort.rb
│ │ │ │ ├── merge_sort.rb
│ │ │ │ ├── quick_sort.rb
│ │ │ │ ├── radix_sort.rb
│ │ │ │ └── selection_sort.rb
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.rb
│ │ │ │ ├── array_queue.rb
│ │ │ │ ├── array_stack.rb
│ │ │ │ ├── deque.rb
│ │ │ │ ├── linkedlist_deque.rb
│ │ │ │ ├── linkedlist_queue.rb
│ │ │ │ ├── linkedlist_stack.rb
│ │ │ │ ├── queue.rb
│ │ │ │ └── stack.rb
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.rb
│ │ │ │ ├── avl_tree.rb
│ │ │ │ ├── binary_search_tree.rb
│ │ │ │ ├── binary_tree.rb
│ │ │ │ ├── binary_tree_bfs.rb
│ │ │ │ └── binary_tree_dfs.rb
│ │ │ ├── test_all.rb
│ │ │ └── utils/
│ │ │ ├── list_node.rb
│ │ │ ├── print_util.rb
│ │ │ ├── tree_node.rb
│ │ │ └── vertex.rb
│ │ ├── rust/
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.rs
│ │ │ │ ├── linked_list.rs
│ │ │ │ ├── list.rs
│ │ │ │ └── my_list.rs
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.rs
│ │ │ │ ├── permutations_i.rs
│ │ │ │ ├── permutations_ii.rs
│ │ │ │ ├── preorder_traversal_i_compact.rs
│ │ │ │ ├── preorder_traversal_ii_compact.rs
│ │ │ │ ├── preorder_traversal_iii_compact.rs
│ │ │ │ ├── preorder_traversal_iii_template.rs
│ │ │ │ ├── subset_sum_i.rs
│ │ │ │ ├── subset_sum_i_naive.rs
│ │ │ │ └── subset_sum_ii.rs
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.rs
│ │ │ │ ├── recursion.rs
│ │ │ │ ├── space_complexity.rs
│ │ │ │ ├── time_complexity.rs
│ │ │ │ └── worst_best_time_complexity.rs
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.rs
│ │ │ │ ├── build_tree.rs
│ │ │ │ └── hanota.rs
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.rs
│ │ │ │ ├── climbing_stairs_constraint_dp.rs
│ │ │ │ ├── climbing_stairs_dfs.rs
│ │ │ │ ├── climbing_stairs_dfs_mem.rs
│ │ │ │ ├── climbing_stairs_dp.rs
│ │ │ │ ├── coin_change.rs
│ │ │ │ ├── coin_change_ii.rs
│ │ │ │ ├── edit_distance.rs
│ │ │ │ ├── knapsack.rs
│ │ │ │ ├── min_cost_climbing_stairs_dp.rs
│ │ │ │ ├── min_path_sum.rs
│ │ │ │ └── unbounded_knapsack.rs
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.rs
│ │ │ │ ├── graph_adjacency_matrix.rs
│ │ │ │ ├── graph_bfs.rs
│ │ │ │ └── graph_dfs.rs
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.rs
│ │ │ │ ├── fractional_knapsack.rs
│ │ │ │ ├── max_capacity.rs
│ │ │ │ └── max_product_cutting.rs
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.rs
│ │ │ │ ├── build_in_hash.rs
│ │ │ │ ├── hash_map.rs
│ │ │ │ ├── hash_map_chaining.rs
│ │ │ │ ├── hash_map_open_addressing.rs
│ │ │ │ └── simple_hash.rs
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.rs
│ │ │ │ ├── my_heap.rs
│ │ │ │ └── top_k.rs
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.rs
│ │ │ │ ├── binary_search_edge.rs
│ │ │ │ ├── binary_search_insertion.rs
│ │ │ │ ├── hashing_search.rs
│ │ │ │ ├── linear_search.rs
│ │ │ │ └── two_sum.rs
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.rs
│ │ │ │ ├── bucket_sort.rs
│ │ │ │ ├── counting_sort.rs
│ │ │ │ ├── heap_sort.rs
│ │ │ │ ├── insertion_sort.rs
│ │ │ │ ├── merge_sort.rs
│ │ │ │ ├── quick_sort.rs
│ │ │ │ ├── radix_sort.rs
│ │ │ │ └── selection_sort.rs
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.rs
│ │ │ │ ├── array_queue.rs
│ │ │ │ ├── array_stack.rs
│ │ │ │ ├── deque.rs
│ │ │ │ ├── linkedlist_deque.rs
│ │ │ │ ├── linkedlist_queue.rs
│ │ │ │ ├── linkedlist_stack.rs
│ │ │ │ ├── queue.rs
│ │ │ │ └── stack.rs
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.rs
│ │ │ │ ├── avl_tree.rs
│ │ │ │ ├── binary_search_tree.rs
│ │ │ │ ├── binary_tree.rs
│ │ │ │ ├── binary_tree_bfs.rs
│ │ │ │ └── binary_tree_dfs.rs
│ │ │ └── src/
│ │ │ ├── include/
│ │ │ │ ├── list_node.rs
│ │ │ │ ├── mod.rs
│ │ │ │ ├── print_util.rs
│ │ │ │ ├── tree_node.rs
│ │ │ │ └── vertex.rs
│ │ │ └── lib.rs
│ │ ├── swift/
│ │ │ ├── .gitignore
│ │ │ ├── Package.resolved
│ │ │ ├── Package.swift
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.swift
│ │ │ │ ├── linked_list.swift
│ │ │ │ ├── list.swift
│ │ │ │ └── my_list.swift
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.swift
│ │ │ │ ├── permutations_i.swift
│ │ │ │ ├── permutations_ii.swift
│ │ │ │ ├── preorder_traversal_i_compact.swift
│ │ │ │ ├── preorder_traversal_ii_compact.swift
│ │ │ │ ├── preorder_traversal_iii_compact.swift
│ │ │ │ ├── preorder_traversal_iii_template.swift
│ │ │ │ ├── subset_sum_i.swift
│ │ │ │ ├── subset_sum_i_naive.swift
│ │ │ │ └── subset_sum_ii.swift
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.swift
│ │ │ │ ├── recursion.swift
│ │ │ │ ├── space_complexity.swift
│ │ │ │ ├── time_complexity.swift
│ │ │ │ └── worst_best_time_complexity.swift
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.swift
│ │ │ │ ├── build_tree.swift
│ │ │ │ └── hanota.swift
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.swift
│ │ │ │ ├── climbing_stairs_constraint_dp.swift
│ │ │ │ ├── climbing_stairs_dfs.swift
│ │ │ │ ├── climbing_stairs_dfs_mem.swift
│ │ │ │ ├── climbing_stairs_dp.swift
│ │ │ │ ├── coin_change.swift
│ │ │ │ ├── coin_change_ii.swift
│ │ │ │ ├── edit_distance.swift
│ │ │ │ ├── knapsack.swift
│ │ │ │ ├── min_cost_climbing_stairs_dp.swift
│ │ │ │ ├── min_path_sum.swift
│ │ │ │ └── unbounded_knapsack.swift
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.swift
│ │ │ │ ├── graph_adjacency_list_target.swift
│ │ │ │ ├── graph_adjacency_matrix.swift
│ │ │ │ ├── graph_bfs.swift
│ │ │ │ └── graph_dfs.swift
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.swift
│ │ │ │ ├── fractional_knapsack.swift
│ │ │ │ ├── max_capacity.swift
│ │ │ │ └── max_product_cutting.swift
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.swift
│ │ │ │ ├── built_in_hash.swift
│ │ │ │ ├── hash_map.swift
│ │ │ │ ├── hash_map_chaining.swift
│ │ │ │ ├── hash_map_open_addressing.swift
│ │ │ │ └── simple_hash.swift
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.swift
│ │ │ │ ├── my_heap.swift
│ │ │ │ └── top_k.swift
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.swift
│ │ │ │ ├── binary_search_edge.swift
│ │ │ │ ├── binary_search_insertion.swift
│ │ │ │ ├── binary_search_insertion_target.swift
│ │ │ │ ├── hashing_search.swift
│ │ │ │ ├── linear_search.swift
│ │ │ │ └── two_sum.swift
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.swift
│ │ │ │ ├── bucket_sort.swift
│ │ │ │ ├── counting_sort.swift
│ │ │ │ ├── heap_sort.swift
│ │ │ │ ├── insertion_sort.swift
│ │ │ │ ├── merge_sort.swift
│ │ │ │ ├── quick_sort.swift
│ │ │ │ ├── radix_sort.swift
│ │ │ │ └── selection_sort.swift
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.swift
│ │ │ │ ├── array_queue.swift
│ │ │ │ ├── array_stack.swift
│ │ │ │ ├── deque.swift
│ │ │ │ ├── linkedlist_deque.swift
│ │ │ │ ├── linkedlist_queue.swift
│ │ │ │ ├── linkedlist_stack.swift
│ │ │ │ ├── queue.swift
│ │ │ │ └── stack.swift
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.swift
│ │ │ │ ├── avl_tree.swift
│ │ │ │ ├── binary_search_tree.swift
│ │ │ │ ├── binary_tree.swift
│ │ │ │ ├── binary_tree_bfs.swift
│ │ │ │ └── binary_tree_dfs.swift
│ │ │ └── utils/
│ │ │ ├── ListNode.swift
│ │ │ ├── Pair.swift
│ │ │ ├── PrintUtil.swift
│ │ │ ├── TreeNode.swift
│ │ │ └── Vertex.swift
│ │ ├── typescript/
│ │ │ ├── .gitignore
│ │ │ ├── .prettierrc
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.ts
│ │ │ │ ├── linked_list.ts
│ │ │ │ ├── list.ts
│ │ │ │ └── my_list.ts
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.ts
│ │ │ │ ├── permutations_i.ts
│ │ │ │ ├── permutations_ii.ts
│ │ │ │ ├── preorder_traversal_i_compact.ts
│ │ │ │ ├── preorder_traversal_ii_compact.ts
│ │ │ │ ├── preorder_traversal_iii_compact.ts
│ │ │ │ ├── preorder_traversal_iii_template.ts
│ │ │ │ ├── subset_sum_i.ts
│ │ │ │ ├── subset_sum_i_naive.ts
│ │ │ │ └── subset_sum_ii.ts
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.ts
│ │ │ │ ├── recursion.ts
│ │ │ │ ├── space_complexity.ts
│ │ │ │ ├── time_complexity.ts
│ │ │ │ └── worst_best_time_complexity.ts
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.ts
│ │ │ │ ├── build_tree.ts
│ │ │ │ └── hanota.ts
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.ts
│ │ │ │ ├── climbing_stairs_constraint_dp.ts
│ │ │ │ ├── climbing_stairs_dfs.ts
│ │ │ │ ├── climbing_stairs_dfs_mem.ts
│ │ │ │ ├── climbing_stairs_dp.ts
│ │ │ │ ├── coin_change.ts
│ │ │ │ ├── coin_change_ii.ts
│ │ │ │ ├── edit_distance.ts
│ │ │ │ ├── knapsack.ts
│ │ │ │ ├── min_cost_climbing_stairs_dp.ts
│ │ │ │ ├── min_path_sum.ts
│ │ │ │ └── unbounded_knapsack.ts
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.ts
│ │ │ │ ├── graph_adjacency_matrix.ts
│ │ │ │ ├── graph_bfs.ts
│ │ │ │ └── graph_dfs.ts
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.ts
│ │ │ │ ├── fractional_knapsack.ts
│ │ │ │ ├── max_capacity.ts
│ │ │ │ └── max_product_cutting.ts
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.ts
│ │ │ │ ├── hash_map.ts
│ │ │ │ ├── hash_map_chaining.ts
│ │ │ │ ├── hash_map_open_addressing.ts
│ │ │ │ └── simple_hash.ts
│ │ │ ├── chapter_heap/
│ │ │ │ ├── my_heap.ts
│ │ │ │ └── top_k.ts
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.ts
│ │ │ │ ├── binary_search_edge.ts
│ │ │ │ ├── binary_search_insertion.ts
│ │ │ │ ├── hashing_search.ts
│ │ │ │ ├── linear_search.ts
│ │ │ │ └── two_sum.ts
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.ts
│ │ │ │ ├── bucket_sort.ts
│ │ │ │ ├── counting_sort.ts
│ │ │ │ ├── heap_sort.ts
│ │ │ │ ├── insertion_sort.ts
│ │ │ │ ├── merge_sort.ts
│ │ │ │ ├── quick_sort.ts
│ │ │ │ ├── radix_sort.ts
│ │ │ │ └── selection_sort.ts
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.ts
│ │ │ │ ├── array_queue.ts
│ │ │ │ ├── array_stack.ts
│ │ │ │ ├── deque.ts
│ │ │ │ ├── linkedlist_deque.ts
│ │ │ │ ├── linkedlist_queue.ts
│ │ │ │ ├── linkedlist_stack.ts
│ │ │ │ ├── queue.ts
│ │ │ │ └── stack.ts
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.ts
│ │ │ │ ├── avl_tree.ts
│ │ │ │ ├── binary_search_tree.ts
│ │ │ │ ├── binary_tree.ts
│ │ │ │ ├── binary_tree_bfs.ts
│ │ │ │ └── binary_tree_dfs.ts
│ │ │ ├── modules/
│ │ │ │ ├── ListNode.ts
│ │ │ │ ├── PrintUtil.ts
│ │ │ │ ├── TreeNode.ts
│ │ │ │ └── Vertex.ts
│ │ │ ├── package.json
│ │ │ └── tsconfig.json
│ │ └── zig/
│ │ ├── .gitignore
│ │ ├── build.zig
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.zig
│ │ │ ├── linked_list.zig
│ │ │ ├── list.zig
│ │ │ └── my_list.zig
│ │ ├── chapter_computational_complexity/
│ │ │ ├── iteration.zig
│ │ │ ├── recursion.zig
│ │ │ ├── space_complexity.zig
│ │ │ ├── time_complexity.zig
│ │ │ └── worst_best_time_complexity.zig
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── climbing_stairs_backtrack.zig
│ │ │ ├── climbing_stairs_constraint_dp.zig
│ │ │ ├── climbing_stairs_dfs.zig
│ │ │ ├── climbing_stairs_dfs_mem.zig
│ │ │ ├── climbing_stairs_dp.zig
│ │ │ ├── coin_change.zig
│ │ │ ├── coin_change_ii.zig
│ │ │ ├── edit_distance.zig
│ │ │ ├── knapsack.zig
│ │ │ ├── min_cost_climbing_stairs_dp.zig
│ │ │ ├── min_path_sum.zig
│ │ │ └── unbounded_knapsack.zig
│ │ ├── chapter_hashing/
│ │ │ ├── array_hash_map.zig
│ │ │ └── hash_map.zig
│ │ ├── chapter_heap/
│ │ │ ├── heap.zig
│ │ │ └── my_heap.zig
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.zig
│ │ │ ├── hashing_search.zig
│ │ │ ├── linear_search.zig
│ │ │ └── two_sum.zig
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.zig
│ │ │ ├── insertion_sort.zig
│ │ │ ├── merge_sort.zig
│ │ │ ├── quick_sort.zig
│ │ │ └── radix_sort.zig
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── array_queue.zig
│ │ │ ├── array_stack.zig
│ │ │ ├── deque.zig
│ │ │ ├── linkedlist_deque.zig
│ │ │ ├── linkedlist_queue.zig
│ │ │ ├── linkedlist_stack.zig
│ │ │ ├── queue.zig
│ │ │ └── stack.zig
│ │ ├── chapter_tree/
│ │ │ ├── avl_tree.zig
│ │ │ ├── binary_search_tree.zig
│ │ │ ├── binary_tree.zig
│ │ │ ├── binary_tree_bfs.zig
│ │ │ └── binary_tree_dfs.zig
│ │ ├── include/
│ │ │ ├── PrintUtil.zig
│ │ │ └── include.zig
│ │ ├── main.zig
│ │ └── utils/
│ │ ├── ListNode.zig
│ │ ├── TreeNode.zig
│ │ ├── format.zig
│ │ └── utils.zig
│ ├── docs/
│ │ ├── chapter_appendix/
│ │ │ ├── contribution.md
│ │ │ ├── index.md
│ │ │ ├── installation.md
│ │ │ └── terminology.md
│ │ ├── chapter_array_and_linkedlist/
│ │ │ ├── array.md
│ │ │ ├── index.md
│ │ │ ├── linked_list.md
│ │ │ ├── list.md
│ │ │ ├── ram_and_cache.md
│ │ │ └── summary.md
│ │ ├── chapter_backtracking/
│ │ │ ├── backtracking_algorithm.md
│ │ │ ├── index.md
│ │ │ ├── n_queens_problem.md
│ │ │ ├── permutations_problem.md
│ │ │ ├── subset_sum_problem.md
│ │ │ └── summary.md
│ │ ├── chapter_computational_complexity/
│ │ │ ├── index.md
│ │ │ ├── iteration_and_recursion.md
│ │ │ ├── performance_evaluation.md
│ │ │ ├── space_complexity.md
│ │ │ ├── summary.md
│ │ │ └── time_complexity.md
│ │ ├── chapter_data_structure/
│ │ │ ├── basic_data_types.md
│ │ │ ├── character_encoding.md
│ │ │ ├── classification_of_data_structure.md
│ │ │ ├── index.md
│ │ │ ├── number_encoding.md
│ │ │ └── summary.md
│ │ ├── chapter_divide_and_conquer/
│ │ │ ├── binary_search_recur.md
│ │ │ ├── build_binary_tree_problem.md
│ │ │ ├── divide_and_conquer.md
│ │ │ ├── hanota_problem.md
│ │ │ ├── index.md
│ │ │ └── summary.md
│ │ ├── chapter_dynamic_programming/
│ │ │ ├── dp_problem_features.md
│ │ │ ├── dp_solution_pipeline.md
│ │ │ ├── edit_distance_problem.md
│ │ │ ├── index.md
│ │ │ ├── intro_to_dynamic_programming.md
│ │ │ ├── knapsack_problem.md
│ │ │ ├── summary.md
│ │ │ └── unbounded_knapsack_problem.md
│ │ ├── chapter_graph/
│ │ │ ├── graph.md
│ │ │ ├── graph_operations.md
│ │ │ ├── graph_traversal.md
│ │ │ ├── index.md
│ │ │ └── summary.md
│ │ ├── chapter_greedy/
│ │ │ ├── fractional_knapsack_problem.md
│ │ │ ├── greedy_algorithm.md
│ │ │ ├── index.md
│ │ │ ├── max_capacity_problem.md
│ │ │ ├── max_product_cutting_problem.md
│ │ │ └── summary.md
│ │ ├── chapter_hashing/
│ │ │ ├── hash_algorithm.md
│ │ │ ├── hash_collision.md
│ │ │ ├── hash_map.md
│ │ │ ├── index.md
│ │ │ └── summary.md
│ │ ├── chapter_heap/
│ │ │ ├── build_heap.md
│ │ │ ├── heap.md
│ │ │ ├── index.md
│ │ │ ├── summary.md
│ │ │ └── top_k.md
│ │ ├── chapter_hello_algo/
│ │ │ └── index.md
│ │ ├── chapter_introduction/
│ │ │ ├── algorithms_are_everywhere.md
│ │ │ ├── index.md
│ │ │ ├── summary.md
│ │ │ └── what_is_dsa.md
│ │ ├── chapter_paperbook/
│ │ │ └── index.md
│ │ ├── chapter_preface/
│ │ │ ├── about_the_book.md
│ │ │ ├── index.md
│ │ │ ├── suggestions.md
│ │ │ └── summary.md
│ │ ├── chapter_reference/
│ │ │ └── index.md
│ │ ├── chapter_searching/
│ │ │ ├── binary_search.md
│ │ │ ├── binary_search_edge.md
│ │ │ ├── binary_search_insertion.md
│ │ │ ├── index.md
│ │ │ ├── replace_linear_by_hashing.md
│ │ │ ├── searching_algorithm_revisited.md
│ │ │ └── summary.md
│ │ ├── chapter_sorting/
│ │ │ ├── bubble_sort.md
│ │ │ ├── bucket_sort.md
│ │ │ ├── counting_sort.md
│ │ │ ├── heap_sort.md
│ │ │ ├── index.md
│ │ │ ├── insertion_sort.md
│ │ │ ├── merge_sort.md
│ │ │ ├── quick_sort.md
│ │ │ ├── radix_sort.md
│ │ │ ├── selection_sort.md
│ │ │ ├── sorting_algorithm.md
│ │ │ └── summary.md
│ │ ├── chapter_stack_and_queue/
│ │ │ ├── deque.md
│ │ │ ├── index.md
│ │ │ ├── queue.md
│ │ │ ├── stack.md
│ │ │ └── summary.md
│ │ ├── chapter_tree/
│ │ │ ├── array_representation_of_tree.md
│ │ │ ├── avl_tree.md
│ │ │ ├── binary_search_tree.md
│ │ │ ├── binary_tree.md
│ │ │ ├── binary_tree_traversal.md
│ │ │ ├── index.md
│ │ │ └── summary.md
│ │ ├── index.html
│ │ └── index.md
│ └── mkdocs.yml
├── mkdocs.yml
├── overrides/
│ ├── javascripts/
│ │ ├── katex.js
│ │ ├── mathjax.js
│ │ └── starfield.js
│ ├── main.html
│ ├── partials/
│ │ ├── LICENSE
│ │ ├── actions.html
│ │ ├── comments.html
│ │ └── content.html
│ ├── stylesheets/
│ │ ├── extra.css
│ │ ├── giscus-dark.css
│ │ └── giscus-light.css
│ └── zensical/
│ ├── javascripts/
│ │ └── animation_player.js
│ ├── stylesheets/
│ │ ├── animation_player.css
│ │ └── extra.css
│ └── zensical.toml
├── ru/
│ ├── README.md
│ ├── codes/
│ │ ├── Dockerfile
│ │ ├── c/
│ │ │ ├── .gitignore
│ │ │ ├── CMakeLists.txt
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array.c
│ │ │ │ ├── linked_list.c
│ │ │ │ └── my_list.c
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── n_queens.c
│ │ │ │ ├── permutations_i.c
│ │ │ │ ├── permutations_ii.c
│ │ │ │ ├── preorder_traversal_i_compact.c
│ │ │ │ ├── preorder_traversal_ii_compact.c
│ │ │ │ ├── preorder_traversal_iii_compact.c
│ │ │ │ ├── preorder_traversal_iii_template.c
│ │ │ │ ├── subset_sum_i.c
│ │ │ │ ├── subset_sum_i_naive.c
│ │ │ │ └── subset_sum_ii.c
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── iteration.c
│ │ │ │ ├── recursion.c
│ │ │ │ ├── space_complexity.c
│ │ │ │ ├── time_complexity.c
│ │ │ │ └── worst_best_time_complexity.c
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── binary_search_recur.c
│ │ │ │ ├── build_tree.c
│ │ │ │ └── hanota.c
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── climbing_stairs_backtrack.c
│ │ │ │ ├── climbing_stairs_constraint_dp.c
│ │ │ │ ├── climbing_stairs_dfs.c
│ │ │ │ ├── climbing_stairs_dfs_mem.c
│ │ │ │ ├── climbing_stairs_dp.c
│ │ │ │ ├── coin_change.c
│ │ │ │ ├── coin_change_ii.c
│ │ │ │ ├── edit_distance.c
│ │ │ │ ├── knapsack.c
│ │ │ │ ├── min_cost_climbing_stairs_dp.c
│ │ │ │ ├── min_path_sum.c
│ │ │ │ └── unbounded_knapsack.c
│ │ │ ├── chapter_graph/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── graph_adjacency_list.c
│ │ │ │ ├── graph_adjacency_list_test.c
│ │ │ │ ├── graph_adjacency_matrix.c
│ │ │ │ ├── graph_bfs.c
│ │ │ │ └── graph_dfs.c
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── coin_change_greedy.c
│ │ │ │ ├── fractional_knapsack.c
│ │ │ │ ├── max_capacity.c
│ │ │ │ └── max_product_cutting.c
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_hash_map.c
│ │ │ │ ├── hash_map_chaining.c
│ │ │ │ ├── hash_map_open_addressing.c
│ │ │ │ └── simple_hash.c
│ │ │ ├── chapter_heap/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── my_heap.c
│ │ │ │ ├── my_heap_test.c
│ │ │ │ └── top_k.c
│ │ │ ├── chapter_searching/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── binary_search.c
│ │ │ │ ├── binary_search_edge.c
│ │ │ │ ├── binary_search_insertion.c
│ │ │ │ └── two_sum.c
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── bubble_sort.c
│ │ │ │ ├── bucket_sort.c
│ │ │ │ ├── counting_sort.c
│ │ │ │ ├── heap_sort.c
│ │ │ │ ├── insertion_sort.c
│ │ │ │ ├── merge_sort.c
│ │ │ │ ├── quick_sort.c
│ │ │ │ ├── radix_sort.c
│ │ │ │ └── selection_sort.c
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_deque.c
│ │ │ │ ├── array_queue.c
│ │ │ │ ├── array_stack.c
│ │ │ │ ├── linkedlist_deque.c
│ │ │ │ ├── linkedlist_queue.c
│ │ │ │ └── linkedlist_stack.c
│ │ │ ├── chapter_tree/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_binary_tree.c
│ │ │ │ ├── avl_tree.c
│ │ │ │ ├── binary_search_tree.c
│ │ │ │ ├── binary_tree.c
│ │ │ │ ├── binary_tree_bfs.c
│ │ │ │ └── binary_tree_dfs.c
│ │ │ └── utils/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── common.h
│ │ │ ├── common_test.c
│ │ │ ├── list_node.h
│ │ │ ├── print_util.h
│ │ │ ├── tree_node.h
│ │ │ ├── uthash.h
│ │ │ ├── vector.h
│ │ │ └── vertex.h
│ │ ├── cpp/
│ │ │ ├── .gitignore
│ │ │ ├── CMakeLists.txt
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array.cpp
│ │ │ │ ├── linked_list.cpp
│ │ │ │ ├── list.cpp
│ │ │ │ └── my_list.cpp
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── n_queens.cpp
│ │ │ │ ├── permutations_i.cpp
│ │ │ │ ├── permutations_ii.cpp
│ │ │ │ ├── preorder_traversal_i_compact.cpp
│ │ │ │ ├── preorder_traversal_ii_compact.cpp
│ │ │ │ ├── preorder_traversal_iii_compact.cpp
│ │ │ │ ├── preorder_traversal_iii_template.cpp
│ │ │ │ ├── subset_sum_i.cpp
│ │ │ │ ├── subset_sum_i_naive.cpp
│ │ │ │ └── subset_sum_ii.cpp
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── iteration.cpp
│ │ │ │ ├── recursion.cpp
│ │ │ │ ├── space_complexity.cpp
│ │ │ │ ├── time_complexity.cpp
│ │ │ │ └── worst_best_time_complexity.cpp
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── binary_search_recur.cpp
│ │ │ │ ├── build_tree.cpp
│ │ │ │ └── hanota.cpp
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── climbing_stairs_backtrack.cpp
│ │ │ │ ├── climbing_stairs_constraint_dp.cpp
│ │ │ │ ├── climbing_stairs_dfs.cpp
│ │ │ │ ├── climbing_stairs_dfs_mem.cpp
│ │ │ │ ├── climbing_stairs_dp.cpp
│ │ │ │ ├── coin_change.cpp
│ │ │ │ ├── coin_change_ii.cpp
│ │ │ │ ├── edit_distance.cpp
│ │ │ │ ├── knapsack.cpp
│ │ │ │ ├── min_cost_climbing_stairs_dp.cpp
│ │ │ │ ├── min_path_sum.cpp
│ │ │ │ └── unbounded_knapsack.cpp
│ │ │ ├── chapter_graph/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── graph_adjacency_list.cpp
│ │ │ │ ├── graph_adjacency_list_test.cpp
│ │ │ │ ├── graph_adjacency_matrix.cpp
│ │ │ │ ├── graph_bfs.cpp
│ │ │ │ └── graph_dfs.cpp
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── coin_change_greedy.cpp
│ │ │ │ ├── fractional_knapsack.cpp
│ │ │ │ ├── max_capacity.cpp
│ │ │ │ └── max_product_cutting.cpp
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_hash_map.cpp
│ │ │ │ ├── array_hash_map_test.cpp
│ │ │ │ ├── built_in_hash.cpp
│ │ │ │ ├── hash_map.cpp
│ │ │ │ ├── hash_map_chaining.cpp
│ │ │ │ ├── hash_map_open_addressing.cpp
│ │ │ │ └── simple_hash.cpp
│ │ │ ├── chapter_heap/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── heap.cpp
│ │ │ │ ├── my_heap.cpp
│ │ │ │ └── top_k.cpp
│ │ │ ├── chapter_searching/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── binary_search.cpp
│ │ │ │ ├── binary_search_edge.cpp
│ │ │ │ ├── binary_search_insertion.cpp
│ │ │ │ ├── hashing_search.cpp
│ │ │ │ ├── linear_search.cpp
│ │ │ │ └── two_sum.cpp
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── bubble_sort.cpp
│ │ │ │ ├── bucket_sort.cpp
│ │ │ │ ├── counting_sort.cpp
│ │ │ │ ├── heap_sort.cpp
│ │ │ │ ├── insertion_sort.cpp
│ │ │ │ ├── merge_sort.cpp
│ │ │ │ ├── quick_sort.cpp
│ │ │ │ ├── radix_sort.cpp
│ │ │ │ └── selection_sort.cpp
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_deque.cpp
│ │ │ │ ├── array_queue.cpp
│ │ │ │ ├── array_stack.cpp
│ │ │ │ ├── deque.cpp
│ │ │ │ ├── linkedlist_deque.cpp
│ │ │ │ ├── linkedlist_queue.cpp
│ │ │ │ ├── linkedlist_stack.cpp
│ │ │ │ ├── queue.cpp
│ │ │ │ └── stack.cpp
│ │ │ ├── chapter_tree/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── array_binary_tree.cpp
│ │ │ │ ├── avl_tree.cpp
│ │ │ │ ├── binary_search_tree.cpp
│ │ │ │ ├── binary_tree.cpp
│ │ │ │ ├── binary_tree_bfs.cpp
│ │ │ │ └── binary_tree_dfs.cpp
│ │ │ └── utils/
│ │ │ ├── CMakeLists.txt
│ │ │ ├── common.hpp
│ │ │ ├── list_node.hpp
│ │ │ ├── print_utils.hpp
│ │ │ ├── tree_node.hpp
│ │ │ └── vertex.hpp
│ │ ├── csharp/
│ │ │ ├── .editorconfig
│ │ │ ├── .gitignore
│ │ │ ├── GlobalUsing.cs
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.cs
│ │ │ │ ├── linked_list.cs
│ │ │ │ ├── list.cs
│ │ │ │ └── my_list.cs
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.cs
│ │ │ │ ├── permutations_i.cs
│ │ │ │ ├── permutations_ii.cs
│ │ │ │ ├── preorder_traversal_i_compact.cs
│ │ │ │ ├── preorder_traversal_ii_compact.cs
│ │ │ │ ├── preorder_traversal_iii_compact.cs
│ │ │ │ ├── preorder_traversal_iii_template.cs
│ │ │ │ ├── subset_sum_i.cs
│ │ │ │ ├── subset_sum_i_naive.cs
│ │ │ │ └── subset_sum_ii.cs
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.cs
│ │ │ │ ├── recursion.cs
│ │ │ │ ├── space_complexity.cs
│ │ │ │ ├── time_complexity.cs
│ │ │ │ └── worst_best_time_complexity.cs
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.cs
│ │ │ │ ├── build_tree.cs
│ │ │ │ └── hanota.cs
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.cs
│ │ │ │ ├── climbing_stairs_constraint_dp.cs
│ │ │ │ ├── climbing_stairs_dfs.cs
│ │ │ │ ├── climbing_stairs_dfs_mem.cs
│ │ │ │ ├── climbing_stairs_dp.cs
│ │ │ │ ├── coin_change.cs
│ │ │ │ ├── coin_change_ii.cs
│ │ │ │ ├── edit_distance.cs
│ │ │ │ ├── knapsack.cs
│ │ │ │ ├── min_cost_climbing_stairs_dp.cs
│ │ │ │ ├── min_path_sum.cs
│ │ │ │ └── unbounded_knapsack.cs
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.cs
│ │ │ │ ├── graph_adjacency_matrix.cs
│ │ │ │ ├── graph_bfs.cs
│ │ │ │ └── graph_dfs.cs
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.cs
│ │ │ │ ├── fractional_knapsack.cs
│ │ │ │ ├── max_capacity.cs
│ │ │ │ └── max_product_cutting.cs
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.cs
│ │ │ │ ├── built_in_hash.cs
│ │ │ │ ├── hash_map.cs
│ │ │ │ ├── hash_map_chaining.cs
│ │ │ │ ├── hash_map_open_addressing.cs
│ │ │ │ └── simple_hash.cs
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.cs
│ │ │ │ ├── my_heap.cs
│ │ │ │ └── top_k.cs
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.cs
│ │ │ │ ├── binary_search_edge.cs
│ │ │ │ ├── binary_search_insertion.cs
│ │ │ │ ├── hashing_search.cs
│ │ │ │ ├── linear_search.cs
│ │ │ │ └── two_sum.cs
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.cs
│ │ │ │ ├── bucket_sort.cs
│ │ │ │ ├── counting_sort.cs
│ │ │ │ ├── heap_sort.cs
│ │ │ │ ├── insertion_sort.cs
│ │ │ │ ├── merge_sort.cs
│ │ │ │ ├── quick_sort.cs
│ │ │ │ ├── radix_sort.cs
│ │ │ │ └── selection_sort.cs
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.cs
│ │ │ │ ├── array_queue.cs
│ │ │ │ ├── array_stack.cs
│ │ │ │ ├── deque.cs
│ │ │ │ ├── linkedlist_deque.cs
│ │ │ │ ├── linkedlist_queue.cs
│ │ │ │ ├── linkedlist_stack.cs
│ │ │ │ ├── queue.cs
│ │ │ │ └── stack.cs
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.cs
│ │ │ │ ├── avl_tree.cs
│ │ │ │ ├── binary_search_tree.cs
│ │ │ │ ├── binary_tree.cs
│ │ │ │ ├── binary_tree_bfs.cs
│ │ │ │ └── binary_tree_dfs.cs
│ │ │ ├── csharp.sln
│ │ │ ├── hello-algo.csproj
│ │ │ └── utils/
│ │ │ ├── ListNode.cs
│ │ │ ├── PrintUtil.cs
│ │ │ ├── TreeNode.cs
│ │ │ └── Vertex.cs
│ │ ├── dart/
│ │ │ ├── build.dart
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.dart
│ │ │ │ ├── linked_list.dart
│ │ │ │ ├── list.dart
│ │ │ │ └── my_list.dart
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.dart
│ │ │ │ ├── permutations_i.dart
│ │ │ │ ├── permutations_ii.dart
│ │ │ │ ├── preorder_traversal_i_compact.dart
│ │ │ │ ├── preorder_traversal_ii_compact.dart
│ │ │ │ ├── preorder_traversal_iii_compact.dart
│ │ │ │ ├── preorder_traversal_iii_template.dart
│ │ │ │ ├── subset_sum_i.dart
│ │ │ │ ├── subset_sum_i_naive.dart
│ │ │ │ └── subset_sum_ii.dart
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.dart
│ │ │ │ ├── recursion.dart
│ │ │ │ ├── space_complexity.dart
│ │ │ │ ├── time_complexity.dart
│ │ │ │ └── worst_best_time_complexity.dart
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.dart
│ │ │ │ ├── build_tree.dart
│ │ │ │ └── hanota.dart
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.dart
│ │ │ │ ├── climbing_stairs_constraint_dp.dart
│ │ │ │ ├── climbing_stairs_dfs.dart
│ │ │ │ ├── climbing_stairs_dfs_mem.dart
│ │ │ │ ├── climbing_stairs_dp.dart
│ │ │ │ ├── coin_change.dart
│ │ │ │ ├── coin_change_ii.dart
│ │ │ │ ├── edit_distance.dart
│ │ │ │ ├── knapsack.dart
│ │ │ │ ├── min_cost_climbing_stairs_dp.dart
│ │ │ │ ├── min_path_sum.dart
│ │ │ │ └── unbounded_knapsack.dart
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.dart
│ │ │ │ ├── graph_adjacency_matrix.dart
│ │ │ │ ├── graph_bfs.dart
│ │ │ │ └── graph_dfs.dart
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.dart
│ │ │ │ ├── fractional_knapsack.dart
│ │ │ │ ├── max_capacity.dart
│ │ │ │ └── max_product_cutting.dart
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.dart
│ │ │ │ ├── built_in_hash.dart
│ │ │ │ ├── hash_map.dart
│ │ │ │ ├── hash_map_chaining.dart
│ │ │ │ ├── hash_map_open_addressing.dart
│ │ │ │ └── simple_hash.dart
│ │ │ ├── chapter_heap/
│ │ │ │ ├── my_heap.dart
│ │ │ │ └── top_k.dart
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.dart
│ │ │ │ ├── binary_search_edge.dart
│ │ │ │ ├── binary_search_insertion.dart
│ │ │ │ ├── hashing_search.dart
│ │ │ │ ├── linear_search.dart
│ │ │ │ └── two_sum.dart
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.dart
│ │ │ │ ├── bucket_sort.dart
│ │ │ │ ├── counting_sort.dart
│ │ │ │ ├── heap_sort.dart
│ │ │ │ ├── insertion_sort.dart
│ │ │ │ ├── merge_sort.dart
│ │ │ │ ├── quick_sort.dart
│ │ │ │ ├── radix_sort.dart
│ │ │ │ └── selection_sort.dart
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.dart
│ │ │ │ ├── array_queue.dart
│ │ │ │ ├── array_stack.dart
│ │ │ │ ├── deque.dart
│ │ │ │ ├── linkedlist_deque.dart
│ │ │ │ ├── linkedlist_queue.dart
│ │ │ │ ├── linkedlist_stack.dart
│ │ │ │ ├── queue.dart
│ │ │ │ └── stack.dart
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.dart
│ │ │ │ ├── avl_tree.dart
│ │ │ │ ├── binary_search_tree.dart
│ │ │ │ ├── binary_tree.dart
│ │ │ │ ├── binary_tree_bfs.dart
│ │ │ │ └── binary_tree_dfs.dart
│ │ │ └── utils/
│ │ │ ├── list_node.dart
│ │ │ ├── print_util.dart
│ │ │ ├── tree_node.dart
│ │ │ └── vertex.dart
│ │ ├── docker-compose.yml
│ │ ├── go/
│ │ │ ├── chapter_array_and_linkedlist/
│ │ │ │ ├── array.go
│ │ │ │ ├── array_test.go
│ │ │ │ ├── linked_list.go
│ │ │ │ ├── linked_list_test.go
│ │ │ │ ├── list_test.go
│ │ │ │ ├── my_list.go
│ │ │ │ └── my_list_test.go
│ │ │ ├── chapter_backtracking/
│ │ │ │ ├── n_queens.go
│ │ │ │ ├── n_queens_test.go
│ │ │ │ ├── permutation_test.go
│ │ │ │ ├── permutations_i.go
│ │ │ │ ├── permutations_ii.go
│ │ │ │ ├── preorder_traversal_i_compact.go
│ │ │ │ ├── preorder_traversal_ii_compact.go
│ │ │ │ ├── preorder_traversal_iii_compact.go
│ │ │ │ ├── preorder_traversal_iii_template.go
│ │ │ │ ├── preorder_traversal_test.go
│ │ │ │ ├── subset_sum_i.go
│ │ │ │ ├── subset_sum_i_naive.go
│ │ │ │ ├── subset_sum_ii.go
│ │ │ │ └── subset_sum_test.go
│ │ │ ├── chapter_computational_complexity/
│ │ │ │ ├── iteration.go
│ │ │ │ ├── iteration_test.go
│ │ │ │ ├── recursion.go
│ │ │ │ ├── recursion_test.go
│ │ │ │ ├── space_complexity.go
│ │ │ │ ├── space_complexity_test.go
│ │ │ │ ├── time_complexity.go
│ │ │ │ ├── time_complexity_test.go
│ │ │ │ ├── worst_best_time_complexity.go
│ │ │ │ └── worst_best_time_complexity_test.go
│ │ │ ├── chapter_divide_and_conquer/
│ │ │ │ ├── binary_search_recur.go
│ │ │ │ ├── binary_search_recur_test.go
│ │ │ │ ├── build_tree.go
│ │ │ │ ├── build_tree_test.go
│ │ │ │ ├── hanota.go
│ │ │ │ └── hanota_test.go
│ │ │ ├── chapter_dynamic_programming/
│ │ │ │ ├── climbing_stairs_backtrack.go
│ │ │ │ ├── climbing_stairs_constraint_dp.go
│ │ │ │ ├── climbing_stairs_dfs.go
│ │ │ │ ├── climbing_stairs_dfs_mem.go
│ │ │ │ ├── climbing_stairs_dp.go
│ │ │ │ ├── climbing_stairs_test.go
│ │ │ │ ├── coin_change.go
│ │ │ │ ├── coin_change_ii.go
│ │ │ │ ├── coin_change_test.go
│ │ │ │ ├── edit_distance.go
│ │ │ │ ├── edit_distance_test.go
│ │ │ │ ├── knapsack.go
│ │ │ │ ├── knapsack_test.go
│ │ │ │ ├── min_cost_climbing_stairs_dp.go
│ │ │ │ ├── min_path_sum.go
│ │ │ │ ├── min_path_sum_test.go
│ │ │ │ └── unbounded_knapsack.go
│ │ │ ├── chapter_graph/
│ │ │ │ ├── graph_adjacency_list.go
│ │ │ │ ├── graph_adjacency_list_test.go
│ │ │ │ ├── graph_adjacency_matrix.go
│ │ │ │ ├── graph_adjacency_matrix_test.go
│ │ │ │ ├── graph_bfs.go
│ │ │ │ ├── graph_bfs_test.go
│ │ │ │ ├── graph_dfs.go
│ │ │ │ └── graph_dfs_test.go
│ │ │ ├── chapter_greedy/
│ │ │ │ ├── coin_change_greedy.go
│ │ │ │ ├── coin_change_greedy_test.go
│ │ │ │ ├── fractional_knapsack.go
│ │ │ │ ├── fractional_knapsack_test.go
│ │ │ │ ├── max_capacity.go
│ │ │ │ ├── max_capacity_test.go
│ │ │ │ ├── max_product_cutting.go
│ │ │ │ └── max_product_cutting_test.go
│ │ │ ├── chapter_hashing/
│ │ │ │ ├── array_hash_map.go
│ │ │ │ ├── array_hash_map_test.go
│ │ │ │ ├── hash_collision_test.go
│ │ │ │ ├── hash_map_chaining.go
│ │ │ │ ├── hash_map_open_addressing.go
│ │ │ │ ├── hash_map_test.go
│ │ │ │ └── simple_hash.go
│ │ │ ├── chapter_heap/
│ │ │ │ ├── heap.go
│ │ │ │ ├── heap_test.go
│ │ │ │ ├── my_heap.go
│ │ │ │ └── top_k.go
│ │ │ ├── chapter_searching/
│ │ │ │ ├── binary_search.go
│ │ │ │ ├── binary_search_edge.go
│ │ │ │ ├── binary_search_insertion.go
│ │ │ │ ├── binary_search_test.go
│ │ │ │ ├── hashing_search.go
│ │ │ │ ├── hashing_search_test.go
│ │ │ │ ├── linear_search.go
│ │ │ │ ├── linear_search_test.go
│ │ │ │ ├── two_sum.go
│ │ │ │ └── two_sum_test.go
│ │ │ ├── chapter_sorting/
│ │ │ │ ├── bubble_sort.go
│ │ │ │ ├── bubble_sort_test.go
│ │ │ │ ├── bucket_sort.go
│ │ │ │ ├── bucket_sort_test.go
│ │ │ │ ├── counting_sort.go
│ │ │ │ ├── counting_sort_test.go
│ │ │ │ ├── heap_sort.go
│ │ │ │ ├── heap_sort_test.go
│ │ │ │ ├── insertion_sort.go
│ │ │ │ ├── insertion_sort_test.go
│ │ │ │ ├── merge_sort.go
│ │ │ │ ├── merge_sort_test.go
│ │ │ │ ├── quick_sort.go
│ │ │ │ ├── quick_sort_test.go
│ │ │ │ ├── radix_sort.go
│ │ │ │ ├── radix_sort_test.go
│ │ │ │ ├── selection_sort.go
│ │ │ │ └── selection_sort_test.go
│ │ │ ├── chapter_stack_and_queue/
│ │ │ │ ├── array_deque.go
│ │ │ │ ├── array_queue.go
│ │ │ │ ├── array_stack.go
│ │ │ │ ├── deque_test.go
│ │ │ │ ├── linkedlist_deque.go
│ │ │ │ ├── linkedlist_queue.go
│ │ │ │ ├── linkedlist_stack.go
│ │ │ │ ├── queue_test.go
│ │ │ │ └── stack_test.go
│ │ │ ├── chapter_tree/
│ │ │ │ ├── array_binary_tree.go
│ │ │ │ ├── array_binary_tree_test.go
│ │
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
*.py linguist-language=Python
*.cpp linguist-language=C++
*.hpp linguist-language=C++
*.java linguist-language=Java
*.go linguist-language=Go
*.swift linguist-language=Swift
*.js linguist-language=JavaScript
*.c linguist-language=Other
*.h linguist-language=Other
*.cs linguist-language=Other
*.zig linguist-language=Other
*.rs linguist-language=Other
*.ts linguist-language=Other
*.dart linguist-language=Other
*.kt linguist-language=Other
*.html linguist-detectable=false
*.css linguist-detectable=false
================================================
FILE: .github/pull_request_template.md
================================================
If this pull request (PR) pertains to **Chinese-to-English translation**, please confirm that you have read the contribution guidelines and complete the checklist below:
- [ ] This PR represents the translation of a single, complete document, or contains only bug fixes.
- [ ] The translation accurately conveys the original meaning and intent of the Chinese version. If deviations exist, I have provided explanatory comments to clarify the reasons.
If this pull request (PR) is associated with **coding or code transpilation**, please attach the relevant console outputs to the PR and complete the following checklist:
- [ ] I have thoroughly reviewed the code, focusing on its formatting, comments, indentation, and file headers.
- [ ] I have confirmed that the code execution outputs are consistent with those produced by the reference code (Python or Java).
- [ ] The code is designed to be compatible on standard operating systems, including Windows, macOS, and Ubuntu.
================================================
FILE: .github/workflows/c.yml
================================================
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: C
on:
push:
branches: ["main"]
paths:
- "codes/c/**/*.c"
- "codes/c/**/*.h"
- "en/codes/c/**/*.c"
- "en/codes/c/**/*.h"
pull_request:
branches: ["main"]
paths:
- "codes/c/**/*.c"
- "codes/c/**/*.h"
- "en/codes/c/**/*.c"
- "en/codes/c/**/*.h"
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: true
# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
code-dir: ["codes/c", "en/codes/c"]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
steps:
- uses: actions/checkout@v4
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ github.workspace }}/${{ matrix.code-dir }}/build
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}/${{ matrix.code-dir }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ github.workspace }}/${{ matrix.code-dir }}/build --config ${{ matrix.build_type }}
- name: Test
working-directory: ${{ github.workspace }}/${{ matrix.code-dir }}/build
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
================================================
FILE: .github/workflows/cpp.yml
================================================
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: C++
on:
push:
branches: ["main"]
paths:
- "codes/cpp/**/*.cpp"
- "codes/cpp/**/*.hpp"
- "en/codes/cpp/**/*.cpp"
- "en/codes/cpp/**/*.hpp"
pull_request:
branches: ["main"]
paths:
- "codes/cpp/**/*.cpp"
- "codes/cpp/**/*.hpp"
- "en/codes/cpp/**/*.cpp"
- "en/codes/cpp/**/*.hpp"
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: true
# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
code-dir: ["codes/cpp", "en/codes/cpp"]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
steps:
- uses: actions/checkout@v4
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ github.workspace }}/${{ matrix.code-dir }}/build
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}/${{ matrix.code-dir }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ github.workspace }}/${{ matrix.code-dir }}/build --config ${{ matrix.build_type }}
- name: Test
working-directory: ${{ github.workspace }}/${{ matrix.code-dir }}/build
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
================================================
FILE: .github/workflows/dart.yml
================================================
# This workflow will install Dart SDK, run format, analyze and build with Dart
name: Dart
on:
push:
branches: ["main"]
paths:
- "codes/dart/**/*.dart"
- "en/codes/dart/**/*.dart"
pull_request:
branches: ["main"]
paths:
- "codes/dart/**/*.dart"
- "en/codes/dart/**/*.dart"
workflow_dispatch:
permissions:
contents: read
jobs:
build:
name: Dart ${{ matrix.dart-sdk }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
dart-sdk: [stable]
code-dir: ["codes/dart", "en/codes/dart"]
steps:
- uses: actions/checkout@v4
- name: Set up Dart ${{ matrix.dart-sdk }}
uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.dart-sdk}}
- name: Run format
run: dart format ${{ matrix.code-dir }}
- name: Run analyze
run: dart analyze ${{ matrix.code-dir }}
- name: Run build
run: dart ${{ matrix.code-dir }}/build.dart
================================================
FILE: .github/workflows/dotnet.yml
================================================
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: .NET
on:
push:
branches: ["main"]
paths:
- "codes/csharp/**/*.cs"
- "en/codes/csharp/**/*.cs"
pull_request:
branches: ["main"]
paths:
- "codes/csharp/**/*.cs"
- "en/codes/csharp/**/*.cs"
workflow_dispatch:
jobs:
build:
name: .NET ${{ matrix.dotnet-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ${{ matrix.code-dir }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
dotnet-version: ["8.0.x"]
code-dir: ["codes/csharp", "en/codes/csharp"]
steps:
- uses: actions/checkout@v4
- name: Setup .NET ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Restore dependencies
run: dotnet restore hello-algo.csproj
- name: Build
run: dotnet build --no-restore hello-algo.csproj
- name: Test with dotnet
run: dotnet test hello-algo.csproj
================================================
FILE: .github/workflows/go.yml
================================================
name: Go
on:
push:
branches: ["main"]
paths:
- "codes/go/**/*.go"
- "en/codes/go/**/*.go"
pull_request:
branches: ["main"]
paths:
- "codes/go/**/*.go"
- "en/codes/go/**/*.go"
workflow_dispatch:
jobs:
build:
name: Go ${{ matrix.go-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ${{ matrix.code-dir }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: ["1.19.x"]
code-dir: ["codes/go", "en/codes/go"]
steps:
- uses: actions/checkout@v4
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Check out code into the Go module directory
run: go get -v -t -d ./...
- name: Build
run: go build -v ./...
- name: Test with Go
run: go test -v ./...
================================================
FILE: .github/workflows/java.yml
================================================
# # This workflow will install OpenJDK and build the Java project
# For more information see: https://github.com/actions/setup-java
name: Java
on:
push:
branches: ["main"]
paths:
- "codes/java/**/*.java"
- "en/codes/java/**/*.java"
pull_request:
branches: ["main"]
paths:
- "codes/java/**/*.java"
- "en/codes/java/**/*.java"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
java: ["11", "17"]
code-dir: ["codes/java", "en/codes/java"]
name: Java ${{ matrix.Java }} sample
steps:
- uses: actions/checkout@v4
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: ${{ matrix.java }}
- run: javac -d ${{ matrix.code-dir }}/build ${{ matrix.code-dir }}/**/*.java
================================================
FILE: .github/workflows/javascript.yml
================================================
name: JavaScript
on:
push:
branches: ["main"]
paths:
- "codes/javascript/**/*.js"
- "en/codes/javascript/**/*.js"
pull_request:
branches: ["main"]
paths:
- "codes/javascript/**/*.js"
- "en/codes/javascript/**/*.js"
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
code-dir: ["codes/javascript", "en/codes/javascript"]
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v6
with:
node-version: 24.x
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Run JavaScript Code
run: deno run -A ${{ matrix.code-dir }}/test_all.js
================================================
FILE: .github/workflows/kotlin.yml
================================================
name: Kotlin
on:
push:
branches: ["main"]
paths:
- "codes/kotlin/**/*.kt"
- "en/codes/kotlin/**/*.kt"
pull_request:
branches: ["main"]
paths:
- "codes/kotlin/**/*.kt"
- "en/codes/kotlin/**/*.kt"
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
code-dir: ["codes/kotlin", "en/codes/kotlin"]
name: Kotlin on ${{ matrix.os }}
steps:
- uses: actions/checkout@v4.1.2
- name: Build JAR
run: kotlinc ${{ matrix.code-dir }}/**/*.kt -include-runtime -d ${{ matrix.code-dir }}/build/test.jar
================================================
FILE: .github/workflows/python.yml
================================================
# This workflow will install Python dependencies, run tests and lint with Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python
on:
push:
branches: ["main"]
paths:
- "codes/python/**/*.py"
- "en/codes/python/**/*.py"
pull_request:
branches: ["main"]
paths:
- "codes/python/**/*.py"
- "en/codes/python/**/*.py"
workflow_dispatch:
permissions:
contents: read
jobs:
build:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10"]
code-dir: ["codes/python", "en/codes/python"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black
- name: Lint with black
run: |
black ${{ matrix.code-dir }}
- name: Test python code
run: |
cd ${{ matrix.code-dir }} && python test_all.py
================================================
FILE: .github/workflows/ruby.yml
================================================
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by separate terms of service, privacy policy, and support documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake。
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
name: Ruby
on:
push:
branches: ["main"]
paths:
- "codes/ruby/**/*.rb"
- "en/codes/ruby/**/*.rb"
pull_request:
branches: ["main"]
paths:
- "codes/ruby/**/*.rb"
- "en/codes/ruby/**/*.rb"
workflow_dispatch:
permissions:
contents: read
jobs:
test:
name: Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
ruby-version: ["3.3"]
code-dir: ["codes/ruby", "en/codes/ruby"]
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Run tests
run: ruby ${{ matrix.code-dir }}/test_all.rb
================================================
FILE: .github/workflows/rust.yml
================================================
name: Rust
on:
push:
branches: ["main"]
paths:
- "codes/rust/**/*.rs"
- "codes/rust/Cargo.toml"
- "en/codes/rust/**/*.rs"
- "en/codes/rust/Cargo.toml"
pull_request:
branches: ["main"]
paths:
- "codes/rust/**/*.rs"
- "codes/rust/Cargo.toml"
- "en/codes/rust/**/*.rs"
- "en/codes/rust/Cargo.toml"
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
code-dir: ["codes/rust", "en/codes/rust"]
steps:
- uses: brndnmtthws/rust-action-rustup@v1
with:
toolchain: nightly
- uses: actions/checkout@v4
- name: Build
run: cargo build --manifest-path=${{ matrix.code-dir }}/Cargo.toml && cargo build --manifest-path=${{ matrix.code-dir }}/Cargo.toml --release
================================================
FILE: .github/workflows/swift.yml
================================================
# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift
name: Swift
on:
push:
branches: ["main"]
paths:
- "codes/swift/**/*.swift"
- "en/codes/swift/**/*.swift"
pull_request:
branches: ["main"]
paths:
- "codes/swift/**/*.swift"
- "en/codes/swift/**/*.swift"
workflow_dispatch:
jobs:
build:
name: Swift on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-22.04", "macos-14"]
code-dir: ["codes/swift", "en/codes/swift"]
steps:
- uses: actions/checkout@v4
- name: Build
run: swift build --package-path ${{ matrix.code-dir }}
================================================
FILE: .github/workflows/typescript.yml
================================================
name: TypeScript
on:
push:
branches: ["main"]
paths:
- "codes/typescript/**/*.ts"
- "en/codes/typescript/**/*.ts"
pull_request:
branches: ["main"]
paths:
- "codes/typescript/**/*.ts"
- "en/codes/typescript/**/*.ts"
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
code-dir: ["codes/typescript", "en/codes/typescript"]
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v6
with:
node-version: 24.x
- name: Install dependencies
run: cd ${{ matrix.code-dir }} && npm install
- name: Check TypeScript code
run: cd ${{ matrix.code-dir }} && npm run check
================================================
FILE: .gitignore
================================================
.DS_Store
.vscode/
/node_modules
# build
/build
/site
/utils
================================================
FILE: Dockerfile
================================================
FROM python:3.10.0-alpine
# Official PyPI is preferred when reachable.
ENV PIP_INDEX_URL=https://pypi.org/simple
# Use the mirror when official PyPI is unreachable.
# ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install --upgrade pip
RUN pip install mkdocs-material==9.5.5 mkdocs-glightbox
WORKDIR /hello-algo
COPY overrides ./build/overrides
COPY docs ./build/docs
COPY mkdocs.yml mkdocs.yml
RUN mkdocs build -f mkdocs.yml
COPY zh-hant/docs ./build/zh-hant/docs
COPY zh-hant/mkdocs.yml ./zh-hant/mkdocs.yml
RUN mkdocs build -f ./zh-hant/mkdocs.yml
COPY en/docs ./build/en/docs
COPY en/mkdocs.yml ./en/mkdocs.yml
RUN mkdocs build -f ./en/mkdocs.yml
COPY ja/docs ./build/ja/docs
COPY ja/mkdocs.yml ./ja/mkdocs.yml
RUN mkdocs build -f ./ja/mkdocs.yml
COPY ru/docs ./build/ru/docs
COPY ru/mkdocs.yml ./ru/mkdocs.yml
RUN mkdocs build -f ./ru/mkdocs.yml
WORKDIR /hello-algo/site
EXPOSE 8000
CMD ["python", "-m", "http.server", "8000"]
================================================
FILE: LICENSE
================================================
Attribution-NonCommercial-ShareAlike 4.0 International
=======================================================================
Creative Commons Corporation ("Creative Commons") is not a law firm and
does not provide legal services or legal advice. Distribution of
Creative Commons public licenses does not create a lawyer-client or
other relationship. Creative Commons makes its licenses and related
information available on an "as-is" basis. Creative Commons gives no
warranties regarding its licenses, any material licensed under their
terms and conditions, or any related information. Creative Commons
disclaims all liability for damages resulting from their use to the
fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and
conditions that creators and other rights holders may use to share
original works of authorship and other material subject to copyright
and certain other rights specified in the public license below. The
following considerations are for informational purposes only, are not
exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are
intended for use by those authorized to give the public
permission to use material in ways otherwise restricted by
copyright and certain other rights. Our licenses are
irrevocable. Licensors should read and understand the terms
and conditions of the license they choose before applying it.
Licensors should also secure all rights necessary before
applying our licenses so that the public can reuse the
material as expected. Licensors should clearly mark any
material not subject to the license. This includes other CC-
licensed material, or material used under an exception or
limitation to copyright. More considerations for licensors:
wiki.creativecommons.org/Considerations_for_licensors
Considerations for the public: By using one of our public
licenses, a licensor grants the public permission to use the
licensed material under specified terms and conditions. If
the licensor's permission is not necessary for any reason--for
example, because of any applicable exception or limitation to
copyright--then that use is not regulated by the license. Our
licenses grant only permissions under copyright and certain
other rights that a licensor has authority to grant. Use of
the licensed material may still be restricted for other
reasons, including because others have copyright or other
rights in the material. A licensor may make special requests,
such as asking that all changes be marked or described.
Although not required by our licenses, you are encouraged to
respect those requests where reasonable. More considerations
for the public:
wiki.creativecommons.org/Considerations_for_licensees
=======================================================================
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
Public License
By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
Attribution-NonCommercial-ShareAlike 4.0 International Public License
("Public License"). To the extent this Public License may be
interpreted as a contract, You are granted the Licensed Rights in
consideration of Your acceptance of these terms and conditions, and the
Licensor grants You such rights in consideration of benefits the
Licensor receives from making the Licensed Material available under
these terms and conditions.
Section 1 -- Definitions.
a. Adapted Material means material subject to Copyright and Similar
Rights that is derived from or based upon the Licensed Material
and in which the Licensed Material is translated, altered,
arranged, transformed, or otherwise modified in a manner requiring
permission under the Copyright and Similar Rights held by the
Licensor. For purposes of this Public License, where the Licensed
Material is a musical work, performance, or sound recording,
Adapted Material is always produced where the Licensed Material is
synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.
c. BY-NC-SA Compatible License means a license listed at
creativecommons.org/compatiblelicenses, approved by Creative
Commons as essentially the equivalent of this Public License.
d. Copyright and Similar Rights means copyright and/or similar rights
closely related to copyright including, without limitation,
performance, broadcast, sound recording, and Sui Generis Database
Rights, without regard to how the rights are labeled or
categorized. For purposes of this Public License, the rights
specified in Section 2(b)(1)-(2) are not Copyright and Similar
Rights.
e. Effective Technological Measures means those measures that, in the
absence of proper authority, may not be circumvented under laws
fulfilling obligations under Article 11 of the WIPO Copyright
Treaty adopted on December 20, 1996, and/or similar international
agreements.
f. Exceptions and Limitations means fair use, fair dealing, and/or
any other exception or limitation to Copyright and Similar Rights
that applies to Your use of the Licensed Material.
g. License Elements means the license attributes listed in the name
of a Creative Commons Public License. The License Elements of this
Public License are Attribution, NonCommercial, and ShareAlike.
h. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
License.
i. Licensed Rights means the rights granted to You subject to the
terms and conditions of this Public License, which are limited to
all Copyright and Similar Rights that apply to Your use of the
Licensed Material and that the Licensor has authority to license.
j. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.
k. NonCommercial means not primarily intended for or directed towards
commercial advantage or monetary compensation. For purposes of
this Public License, the exchange of the Licensed Material for
other material subject to Copyright and Similar Rights by digital
file-sharing or similar means is NonCommercial provided there is
no payment of monetary compensation in connection with the
exchange.
l. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
available to the public including in ways that members of the
public may access the material from a place and at a time
individually chosen by them.
m. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.
n. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.
Section 2 -- Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License,
the Licensor hereby grants You a worldwide, royalty-free,
non-sublicensable, non-exclusive, irrevocable license to
exercise the Licensed Rights in the Licensed Material to:
a. reproduce and Share the Licensed Material, in whole or
in part, for NonCommercial purposes only; and
b. produce, reproduce, and Share Adapted Material for
NonCommercial purposes only.
2. Exceptions and Limitations. For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public
License does not apply, and You do not need to comply with
its terms and conditions.
3. Term. The term of this Public License is specified in Section
6(a).
4. Media and formats; technical modifications allowed. The
Licensor authorizes You to exercise the Licensed Rights in
all media and formats whether now known or hereafter created,
and to make technical modifications necessary to do so. The
Licensor waives and/or agrees not to assert any right or
authority to forbid You from making technical modifications
necessary to exercise the Licensed Rights, including
technical modifications necessary to circumvent Effective
Technological Measures. For purposes of this Public License,
simply making modifications authorized by this Section 2(a)
(4) never produces Adapted Material.
5. Downstream recipients.
a. Offer from the Licensor -- Licensed Material. Every
recipient of the Licensed Material automatically
receives an offer from the Licensor to exercise the
Licensed Rights under the terms and conditions of this
Public License.
b. Additional offer from the Licensor -- Adapted Material.
Every recipient of Adapted Material from You
automatically receives an offer from the Licensor to
exercise the Licensed Rights in the Adapted Material
under the conditions of the Adapter's License You apply.
c. No downstream restrictions. You may not offer or impose
any additional or different terms or conditions on, or
apply any Effective Technological Measures to, the
Licensed Material if doing so restricts exercise of the
Licensed Rights by any recipient of the Licensed
Material.
6. No endorsement. Nothing in this Public License constitutes or
may be construed as permission to assert or imply that You
are, or that Your use of the Licensed Material is, connected
with, or sponsored, endorsed, or granted official status by,
the Licensor or others designated to receive attribution as
provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not
licensed under this Public License, nor are publicity,
privacy, and/or other similar personality rights; however, to
the extent possible, the Licensor waives and/or agrees not to
assert any such rights held by the Licensor to the limited
extent necessary to allow You to exercise the Licensed
Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this
Public License.
3. To the extent possible, the Licensor waives any right to
collect royalties from You for the exercise of the Licensed
Rights, whether directly or through a collecting society
under any voluntary or waivable statutory or compulsory
licensing scheme. In all other cases the Licensor expressly
reserves any right to collect such royalties, including when
the Licensed Material is used other than for NonCommercial
purposes.
Section 3 -- License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the
following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified
form), You must:
a. retain the following if it is supplied by the Licensor
with the Licensed Material:
i. identification of the creator(s) of the Licensed
Material and any others designated to receive
attribution, in any reasonable manner requested by
the Licensor (including by pseudonym if
designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of
warranties;
v. a URI or hyperlink to the Licensed Material to the
extent reasonably practicable;
b. indicate if You modified the Licensed Material and
retain an indication of any previous modifications; and
c. indicate the Licensed Material is licensed under this
Public License, and include the text of, or the URI or
hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any
reasonable manner based on the medium, means, and context in
which You Share the Licensed Material. For example, it may be
reasonable to satisfy the conditions by providing a URI or
hyperlink to a resource that includes the required
information.
3. If requested by the Licensor, You must remove any of the
information required by Section 3(a)(1)(A) to the extent
reasonably practicable.
b. ShareAlike.
In addition to the conditions in Section 3(a), if You Share
Adapted Material You produce, the following conditions also apply.
1. The Adapter's License You apply must be a Creative Commons
license with the same License Elements, this version or
later, or a BY-NC-SA Compatible License.
2. You must include the text of, or the URI or hyperlink to, the
Adapter's License You apply. You may satisfy this condition
in any reasonable manner based on the medium, means, and
context in which You Share Adapted Material.
3. You may not offer or impose any additional or different terms
or conditions on, or apply any Effective Technological
Measures to, Adapted Material that restrict exercise of the
rights granted under the Adapter's License You apply.
Section 4 -- Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that
apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
portion of the contents of the database for NonCommercial purposes
only;
b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material,
including for purposes of Section 3(b); and
c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not
replace Your obligations under this Public License where the Licensed
Rights include other Copyright and Similar Rights.
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
c. The disclaimer of warranties and limitation of liability provided
above shall be interpreted in a manner that, to the extent
possible, most closely approximates an absolute disclaimer and
waiver of all liability.
Section 6 -- Term and Termination.
a. This Public License applies for the term of the Copyright and
Similar Rights licensed here. However, if You fail to comply with
this Public License, then Your rights under this Public License
terminate automatically.
b. Where Your right to use the Licensed Material has terminated under
Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided
it is cured within 30 days of Your discovery of the
violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any
right the Licensor may have to seek remedies for Your violations
of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the
Licensed Material under separate terms or conditions or stop
distributing the Licensed Material at any time; however, doing so
will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
License.
Section 7 -- Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different
terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the
Licensed Material not stated herein are separate from and
independent of the terms and conditions of this Public License.
Section 8 -- Interpretation.
a. For the avoidance of doubt, this Public License does not, and
shall not be interpreted to, reduce, limit, restrict, or impose
conditions on any use of the Licensed Material that could lawfully
be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is
deemed unenforceable, it shall be automatically reformed to the
minimum extent necessary to make it enforceable. If the provision
cannot be reformed, it shall be severed from this Public License
without affecting the enforceability of the remaining terms and
conditions.
c. No term or condition of this Public License will be waived and no
failure to comply consented to unless expressly agreed to by the
Licensor.
d. Nothing in this Public License constitutes or may be interpreted
as a limitation upon, or waiver of, any privileges and immunities
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.
=======================================================================
Creative Commons is not a party to its public
licenses. Notwithstanding, Creative Commons may elect to apply one of
its public licenses to material it publishes and in those instances
will be considered the “Licensor.” The text of the Creative Commons
public licenses is dedicated to the public domain under the CC0 Public
Domain Dedication. Except for the limited purpose of indicating that
material is shared under a Creative Commons public license or as
otherwise permitted by the Creative Commons policies published at
creativecommons.org/policies, Creative Commons does not authorize the
use of the trademark "Creative Commons" or any other trademark or logo
of Creative Commons without its prior written consent including,
without limitation, in connection with any unauthorized modifications
to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For
the avoidance of doubt, this paragraph does not form part of the
public licenses.
Creative Commons may be contacted at creativecommons.org.
================================================
FILE: README.md
================================================
<p align="center">
<a href="https://www.hello-algo.com/">
<img src="https://www.hello-algo.com/index.assets/hello_algo_header.png" width="450"></a>
</p>
<p align="center">
<img style="height: 60px;" src="https://readme-typing-svg.demolab.com?font=Noto+Sans+SC&weight=400&duration=3500&pause=2000&color=21C8B8¢er=true&vCenter=true&random=false&width=200&lines=Hello%2C+%E7%AE%97%E6%B3%95+!" alt="hello-algo-typing-svg" />
</br>
动画图解、一键运行的数据结构与算法教程
</p>
<p align="center">
<a href="https://www.hello-algo.com/">
<img src="https://www.hello-algo.com/index.assets/btn_read_online_dark.svg" height="45"></a>
<a href="https://github.com/krahets/hello-algo/releases">
<img src="https://www.hello-algo.com/index.assets/btn_download_pdf_epub_dark.svg" height="45"></a>
</p>
<p align="center">
<img src="https://www.hello-algo.com/index.assets/animation.gif" width="395">
<img src="https://www.hello-algo.com/index.assets/running_code.gif" width="395">
</p>
<p align="center">
<img src="https://img.shields.io/badge/Python-snow?logo=python&logoColor=3776AB" alt="" />
<img src="https://img.shields.io/badge/Java-snow?logo=coffeescript&logoColor=FC4C02" alt="" />
<img src="https://img.shields.io/badge/C%2B%2B-snow?logo=c%2B%2B&logoColor=00599C" alt="" />
<img src="https://img.shields.io/badge/C-snow?logo=c&logoColor=A8B9CC" alt="" />
<img src="https://img.shields.io/badge/C%23-snow?logo=csharp&logoColor=512BD4" alt="" />
<img src="https://img.shields.io/badge/JavaScript-snow?logo=javascript&logoColor=E9CE30" alt="" />
<img src="https://img.shields.io/badge/Go-snow?logo=go&logoColor=00ADD8" alt="" />
<img src="https://img.shields.io/badge/Swift-snow?logo=swift&logoColor=F05138" alt="" />
<img src="https://img.shields.io/badge/Rust-snow?logo=rust&logoColor=000000" alt="" />
<img src="https://img.shields.io/badge/Ruby-snow?logo=ruby&logoColor=CC342D" alt="" />
<img src="https://img.shields.io/badge/Kotlin-snow?logo=kotlin&logoColor=7F52FF" alt="" />
<img src="https://img.shields.io/badge/TypeScript-snow?logo=typescript&logoColor=3178C6" alt="" />
<img src="https://img.shields.io/badge/Dart-snow?logo=dart&logoColor=0175C2" alt="" />
</p>
<p align="center">
简体中文
|
<a href="https://github.com/krahets/hello-algo/blob/main/zh-hant/README.md">繁體中文</a>
|
<a href="https://github.com/krahets/hello-algo/blob/main/en/README.md">English</a>
|
<a href="https://github.com/krahets/hello-algo/blob/main/ja/README.md">日本語</a>
|
<a href="https://github.com/krahets/hello-algo/blob/main/ru/README.md">Русский</a>
</p>
## 关于本书
本项目旨在打造一本开源免费、新手友好的数据结构与算法入门教程。
- 全书采用动画图解,内容清晰易懂、学习曲线平滑,引导初学者探索数据结构与算法的知识地图。
- 源代码可一键运行,帮助读者在练习中提升编程技能,了解算法工作原理和数据结构底层实现。
- 提倡读者互助学习,欢迎大家在评论区提出问题与分享见解,在交流讨论中共同进步。
若本书对您有所帮助,请在页面右上角点个 Star :star: 支持一下,谢谢!
## 推荐语
> “一本通俗易懂的数据结构与算法入门书,引导读者手脑并用地学习,强烈推荐算法初学者阅读。”
>
> **—— 邓俊辉,清华大学计算机系教授**
> “如果我当年学数据结构与算法的时候有《Hello 算法》,学起来应该会简单 10 倍!”
>
> **—— 李沐,亚马逊资深首席科学家**
## 鸣谢
<p align="left">
<a href="https://go.warp.dev/hello-algo">
<img src="https://github.com/warpdotdev/brand-assets/blob/main/Github/Sponsor/Warp-Github-LG-02.png" alt="Warp-Github-LG-02" width="500"></a>
</p>
[Warp is built for coding with multiple AI agents.](https://go.warp.dev/hello-algo)
强烈推荐 Warp 终端,高颜值 + 好用的 AI,体验非常棒!
## 贡献
本开源书仍在持续更新之中,欢迎您参与本项目,一同为读者提供更优质的学习内容。
- [内容修正](https://www.hello-algo.com/chapter_appendix/contribution/):请您协助修正或在评论区指出语法错误、内容缺失、文字歧义、无效链接或代码 bug 等问题。
- [代码转译](https://github.com/krahets/hello-algo/issues/15):期待您贡献各种语言代码,已支持 Python、Java、C++、Go、JavaScript 等 12 门编程语言。
- [中译英](https://github.com/krahets/hello-algo/issues/914):诚邀您加入我们的翻译小组,成员主要来自计算机相关专业、英语专业和英文母语者。
欢迎您提出宝贵意见和建议,如有任何问题请提交 Issues 或微信联系 `krahets-jyd` 。
感谢本开源书的每一位撰稿人,是他们的无私奉献让这本书变得更好,他们是:
<p align="left">
<a href="https://github.com/krahets/hello-algo/graphs/contributors">
<img width="770" src="https://contrib.rocks/image?repo=krahets/hello-algo&max=300&columns=16" />
</a>
</p>
## License
The texts, code, images, photos, and videos in this repository are licensed under [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/).
================================================
FILE: codes/Dockerfile
================================================
FROM ubuntu:latest
# Use Ubuntu image from Aliyun
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
sed -i 's/ports.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
RUN apt-get update && apt-get install -y wget
# Install languages environment
ARG LANGS
RUN for LANG in $LANGS; do \
case $LANG in \
python) \
apt-get install -y python3.10 && \
update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 ;; \
cpp) \
apt-get install -y g++ gdb ;; \
java) \
apt-get install -y openjdk-17-jdk ;; \
csharp) \
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && \
apt-get update && \
apt-get install -y dotnet-sdk-8.0 ;; \
# More languages...
*) \
echo "Warning: No installation workflow for $LANG" ;; \
esac \
done
WORKDIR /codes
COPY ./ ./
CMD ["/bin/bash"]
================================================
FILE: codes/c/.gitignore
================================================
# Ignore all
*
# Unignore all with extensions
!*.*
# Unignore all dirs
!*/
*.dSYM/
build/
================================================
FILE: codes/c/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.10)
project(hello_algo C)
set(CMAKE_C_STANDARD 11)
include_directories(./include)
add_subdirectory(chapter_computational_complexity)
add_subdirectory(chapter_array_and_linkedlist)
add_subdirectory(chapter_stack_and_queue)
add_subdirectory(chapter_hashing)
add_subdirectory(chapter_tree)
add_subdirectory(chapter_heap)
add_subdirectory(chapter_graph)
add_subdirectory(chapter_searching)
add_subdirectory(chapter_sorting)
add_subdirectory(chapter_divide_and_conquer)
add_subdirectory(chapter_backtracking)
add_subdirectory(chapter_dynamic_programming)
add_subdirectory(chapter_greedy)
================================================
FILE: codes/c/chapter_array_and_linkedlist/CMakeLists.txt
================================================
add_executable(array array.c)
add_executable(linked_list linked_list.c)
add_executable(my_list my_list.c)
================================================
FILE: codes/c/chapter_array_and_linkedlist/array.c
================================================
/**
* File: array.c
* Created Time: 2022-12-20
* Author: MolDuM (moldum@163.com)
*/
#include "../utils/common.h"
/* 随机访问元素 */
int randomAccess(int *nums, int size) {
// 在区间 [0, size) 中随机抽取一个数字
int randomIndex = rand() % size;
// 获取并返回随机元素
int randomNum = nums[randomIndex];
return randomNum;
}
/* 扩展数组长度 */
int *extend(int *nums, int size, int enlarge) {
// 初始化一个扩展长度后的数组
int *res = (int *)malloc(sizeof(int) * (size + enlarge));
// 将原数组中的所有元素复制到新数组
for (int i = 0; i < size; i++) {
res[i] = nums[i];
}
// 初始化扩展后的空间
for (int i = size; i < size + enlarge; i++) {
res[i] = 0;
}
// 返回扩展后的新数组
return res;
}
/* 在数组的索引 index 处插入元素 num */
void insert(int *nums, int size, int num, int index) {
// 把索引 index 以及之后的所有元素向后移动一位
for (int i = size - 1; i > index; i--) {
nums[i] = nums[i - 1];
}
// 将 num 赋给 index 处的元素
nums[index] = num;
}
/* 删除索引 index 处的元素 */
// 注意:stdio.h 占用了 remove 关键词
void removeItem(int *nums, int size, int index) {
// 把索引 index 之后的所有元素向前移动一位
for (int i = index; i < size - 1; i++) {
nums[i] = nums[i + 1];
}
}
/* 遍历数组 */
void traverse(int *nums, int size) {
int count = 0;
// 通过索引遍历数组
for (int i = 0; i < size; i++) {
count += nums[i];
}
}
/* 在数组中查找指定元素 */
int find(int *nums, int size, int target) {
for (int i = 0; i < size; i++) {
if (nums[i] == target)
return i;
}
return -1;
}
/* Driver Code */
int main() {
/* 初始化数组 */
int size = 5;
int arr[5];
printf("数组 arr = ");
printArray(arr, size);
int nums[] = {1, 3, 2, 5, 4};
printf("数组 nums = ");
printArray(nums, size);
/* 随机访问 */
int randomNum = randomAccess(nums, size);
printf("在 nums 中获取随机元素 %d", randomNum);
/* 长度扩展 */
int enlarge = 3;
int *res = extend(nums, size, enlarge);
size += enlarge;
printf("将数组长度扩展至 8 ,得到 nums = ");
printArray(res, size);
/* 插入元素 */
insert(res, size, 6, 3);
printf("在索引 3 处插入数字 6 ,得到 nums = ");
printArray(res, size);
/* 删除元素 */
removeItem(res, size, 2);
printf("删除索引 2 处的元素,得到 nums = ");
printArray(res, size);
/* 遍历数组 */
traverse(res, size);
/* 查找元素 */
int index = find(res, size, 3);
printf("在 res 中查找元素 3 ,得到索引 = %d\n", index);
/* 释放内存 */
free(res);
return 0;
}
================================================
FILE: codes/c/chapter_array_and_linkedlist/linked_list.c
================================================
/**
* File: linked_list.c
* Created Time: 2023-01-12
* Author: Zero (glj0@outlook.com)
*/
#include "../utils/common.h"
/* 在链表的节点 n0 之后插入节点 P */
void insert(ListNode *n0, ListNode *P) {
ListNode *n1 = n0->next;
P->next = n1;
n0->next = P;
}
/* 删除链表的节点 n0 之后的首个节点 */
// 注意:stdio.h 占用了 remove 关键词
void removeItem(ListNode *n0) {
if (!n0->next)
return;
// n0 -> P -> n1
ListNode *P = n0->next;
ListNode *n1 = P->next;
n0->next = n1;
// 释放内存
free(P);
}
/* 访问链表中索引为 index 的节点 */
ListNode *access(ListNode *head, int index) {
for (int i = 0; i < index; i++) {
if (head == NULL)
return NULL;
head = head->next;
}
return head;
}
/* 在链表中查找值为 target 的首个节点 */
int find(ListNode *head, int target) {
int index = 0;
while (head) {
if (head->val == target)
return index;
head = head->next;
index++;
}
return -1;
}
/* Driver Code */
int main() {
/* 初始化链表 */
// 初始化各个节点
ListNode *n0 = newListNode(1);
ListNode *n1 = newListNode(3);
ListNode *n2 = newListNode(2);
ListNode *n3 = newListNode(5);
ListNode *n4 = newListNode(4);
// 构建节点之间的引用
n0->next = n1;
n1->next = n2;
n2->next = n3;
n3->next = n4;
printf("初始化的链表为\r\n");
printLinkedList(n0);
/* 插入节点 */
insert(n0, newListNode(0));
printf("插入节点后的链表为\r\n");
printLinkedList(n0);
/* 删除节点 */
removeItem(n0);
printf("删除节点后的链表为\r\n");
printLinkedList(n0);
/* 访问节点 */
ListNode *node = access(n0, 3);
printf("链表中索引 3 处的节点的值 = %d\r\n", node->val);
/* 查找节点 */
int index = find(n0, 2);
printf("链表中值为 2 的节点的索引 = %d\r\n", index);
// 释放内存
freeMemoryLinkedList(n0);
return 0;
}
================================================
FILE: codes/c/chapter_array_and_linkedlist/my_list.c
================================================
/**
* File: my_list.c
* Created Time: 2023-01-12
* Author: Zero (glj0@outlook.com)
*/
#include "../utils/common.h"
/* 列表类 */
typedef struct {
int *arr; // 数组(存储列表元素)
int capacity; // 列表容量
int size; // 列表大小
int extendRatio; // 列表每次扩容的倍数
} MyList;
void extendCapacity(MyList *nums);
/* 构造函数 */
MyList *newMyList() {
MyList *nums = malloc(sizeof(MyList));
nums->capacity = 10;
nums->arr = malloc(sizeof(int) * nums->capacity);
nums->size = 0;
nums->extendRatio = 2;
return nums;
}
/* 析构函数 */
void delMyList(MyList *nums) {
free(nums->arr);
free(nums);
}
/* 获取列表长度 */
int size(MyList *nums) {
return nums->size;
}
/* 获取列表容量 */
int capacity(MyList *nums) {
return nums->capacity;
}
/* 访问元素 */
int get(MyList *nums, int index) {
assert(index >= 0 && index < nums->size);
return nums->arr[index];
}
/* 更新元素 */
void set(MyList *nums, int index, int num) {
assert(index >= 0 && index < nums->size);
nums->arr[index] = num;
}
/* 在尾部添加元素 */
void add(MyList *nums, int num) {
if (size(nums) == capacity(nums)) {
extendCapacity(nums); // 扩容
}
nums->arr[size(nums)] = num;
nums->size++;
}
/* 在中间插入元素 */
void insert(MyList *nums, int index, int num) {
assert(index >= 0 && index < size(nums));
// 元素数量超出容量时,触发扩容机制
if (size(nums) == capacity(nums)) {
extendCapacity(nums); // 扩容
}
for (int i = size(nums); i > index; --i) {
nums->arr[i] = nums->arr[i - 1];
}
nums->arr[index] = num;
nums->size++;
}
/* 删除元素 */
// 注意:stdio.h 占用了 remove 关键词
int removeItem(MyList *nums, int index) {
assert(index >= 0 && index < size(nums));
int num = nums->arr[index];
for (int i = index; i < size(nums) - 1; i++) {
nums->arr[i] = nums->arr[i + 1];
}
nums->size--;
return num;
}
/* 列表扩容 */
void extendCapacity(MyList *nums) {
// 先分配空间
int newCapacity = capacity(nums) * nums->extendRatio;
int *extend = (int *)malloc(sizeof(int) * newCapacity);
int *temp = nums->arr;
// 拷贝旧数据到新数据
for (int i = 0; i < size(nums); i++)
extend[i] = nums->arr[i];
// 释放旧数据
free(temp);
// 更新新数据
nums->arr = extend;
nums->capacity = newCapacity;
}
/* 将列表转换为 Array 用于打印 */
int *toArray(MyList *nums) {
return nums->arr;
}
/* Driver Code */
int main() {
/* 初始化列表 */
MyList *nums = newMyList();
/* 在尾部添加元素 */
add(nums, 1);
add(nums, 3);
add(nums, 2);
add(nums, 5);
add(nums, 4);
printf("列表 nums = ");
printArray(toArray(nums), size(nums));
printf("容量 = %d ,长度 = %d\n", capacity(nums), size(nums));
/* 在中间插入元素 */
insert(nums, 3, 6);
printf("在索引 3 处插入数字 6 ,得到 nums = ");
printArray(toArray(nums), size(nums));
/* 删除元素 */
removeItem(nums, 3);
printf("删除索引 3 处的元素,得到 nums = ");
printArray(toArray(nums), size(nums));
/* 访问元素 */
int num = get(nums, 1);
printf("访问索引 1 处的元素,得到 num = %d\n", num);
/* 更新元素 */
set(nums, 1, 0);
printf("将索引 1 处的元素更新为 0 ,得到 nums = ");
printArray(toArray(nums), size(nums));
/* 测试扩容机制 */
for (int i = 0; i < 10; i++) {
// 在 i = 5 时,列表长度将超出列表容量,此时触发扩容机制
add(nums, i);
}
printf("扩容后的列表 nums = ");
printArray(toArray(nums), size(nums));
printf("容量 = %d ,长度 = %d\n", capacity(nums), size(nums));
/* 释放分配内存 */
delMyList(nums);
return 0;
}
================================================
FILE: codes/c/chapter_backtracking/CMakeLists.txt
================================================
add_executable(permutations_i permutations_i.c)
add_executable(permutations_ii permutations_ii.c)
add_executable(preorder_traversal_i_compact preorder_traversal_i_compact.c)
add_executable(preorder_traversal_ii_compact preorder_traversal_ii_compact.c)
add_executable(preorder_traversal_iii_compact preorder_traversal_iii_compact.c)
add_executable(preorder_traversal_iii_template preorder_traversal_iii_template.c)
add_executable(subset_sum_i_naive subset_sum_i_naive.c)
add_executable(subset_sum_i subset_sum_i.c)
add_executable(subset_sum_ii subset_sum_ii.c)
add_executable(n_queens n_queens.c)
================================================
FILE: codes/c/chapter_backtracking/n_queens.c
================================================
/**
* File : n_queens.c
* Created Time: 2023-09-25
* Author : lucas (superrat6@gmail.com)
*/
#include "../utils/common.h"
#define MAX_SIZE 100
/* 回溯算法:n 皇后 */
void backtrack(int row, int n, char state[MAX_SIZE][MAX_SIZE], char ***res, int *resSize, bool cols[MAX_SIZE],
bool diags1[2 * MAX_SIZE - 1], bool diags2[2 * MAX_SIZE - 1]) {
// 当放置完所有行时,记录解
if (row == n) {
res[*resSize] = (char **)malloc(sizeof(char *) * n);
for (int i = 0; i < n; ++i) {
res[*resSize][i] = (char *)malloc(sizeof(char) * (n + 1));
strcpy(res[*resSize][i], state[i]);
}
(*resSize)++;
return;
}
// 遍历所有列
for (int col = 0; col < n; col++) {
// 计算该格子对应的主对角线和次对角线
int diag1 = row - col + n - 1;
int diag2 = row + col;
// 剪枝:不允许该格子所在列、主对角线、次对角线上存在皇后
if (!cols[col] && !diags1[diag1] && !diags2[diag2]) {
// 尝试:将皇后放置在该格子
state[row][col] = 'Q';
cols[col] = diags1[diag1] = diags2[diag2] = true;
// 放置下一行
backtrack(row + 1, n, state, res, resSize, cols, diags1, diags2);
// 回退:将该格子恢复为空位
state[row][col] = '#';
cols[col] = diags1[diag1] = diags2[diag2] = false;
}
}
}
/* 求解 n 皇后 */
char ***nQueens(int n, int *returnSize) {
char state[MAX_SIZE][MAX_SIZE];
// 初始化 n*n 大小的棋盘,其中 'Q' 代表皇后,'#' 代表空位
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
state[i][j] = '#';
}
state[i][n] = '\0';
}
bool cols[MAX_SIZE] = {false}; // 记录列是否有皇后
bool diags1[2 * MAX_SIZE - 1] = {false}; // 记录主对角线上是否有皇后
bool diags2[2 * MAX_SIZE - 1] = {false}; // 记录次对角线上是否有皇后
char ***res = (char ***)malloc(sizeof(char **) * MAX_SIZE);
*returnSize = 0;
backtrack(0, n, state, res, returnSize, cols, diags1, diags2);
return res;
}
/* Driver Code */
int main() {
int n = 4;
int returnSize;
char ***res = nQueens(n, &returnSize);
printf("输入棋盘长宽为%d\n", n);
printf("皇后放置方案共有 %d 种\n", returnSize);
for (int i = 0; i < returnSize; ++i) {
for (int j = 0; j < n; ++j) {
printf("[");
for (int k = 0; res[i][j][k] != '\0'; ++k) {
printf("%c", res[i][j][k]);
if (res[i][j][k + 1] != '\0') {
printf(", ");
}
}
printf("]\n");
}
printf("---------------------\n");
}
// 释放内存
for (int i = 0; i < returnSize; ++i) {
for (int j = 0; j < n; ++j) {
free(res[i][j]);
}
free(res[i]);
}
free(res);
return 0;
}
================================================
FILE: codes/c/chapter_backtracking/permutations_i.c
================================================
/**
* File: permutations_i.c
* Created Time: 2023-06-04
* Author: Gonglja (glj0@outlook.com), krahets (krahets@163.com)
*/
#include "../utils/common.h"
// 假设最多有 1000 个排列
#define MAX_SIZE 1000
/* 回溯算法:全排列 I */
void backtrack(int *state, int stateSize, int *choices, int choicesSize, bool *selected, int **res, int *resSize) {
// 当状态长度等于元素数量时,记录解
if (stateSize == choicesSize) {
res[*resSize] = (int *)malloc(choicesSize * sizeof(int));
for (int i = 0; i < choicesSize; i++) {
res[*resSize][i] = state[i];
}
(*resSize)++;
return;
}
// 遍历所有选择
for (int i = 0; i < choicesSize; i++) {
int choice = choices[i];
// 剪枝:不允许重复选择元素
if (!selected[i]) {
// 尝试:做出选择,更新状态
selected[i] = true;
state[stateSize] = choice;
// 进行下一轮选择
backtrack(state, stateSize + 1, choices, choicesSize, selected, res, resSize);
// 回退:撤销选择,恢复到之前的状态
selected[i] = false;
}
}
}
/* 全排列 I */
int **permutationsI(int *nums, int numsSize, int *returnSize) {
int *state = (int *)malloc(numsSize * sizeof(int));
bool *selected = (bool *)malloc(numsSize * sizeof(bool));
for (int i = 0; i < numsSize; i++) {
selected[i] = false;
}
int **res = (int **)malloc(MAX_SIZE * sizeof(int *));
*returnSize = 0;
backtrack(state, 0, nums, numsSize, selected, res, returnSize);
free(state);
free(selected);
return res;
}
/* Driver Code */
int main() {
int nums[] = {1, 2, 3};
int numsSize = sizeof(nums) / sizeof(nums[0]);
int returnSize;
int **res = permutationsI(nums, numsSize, &returnSize);
printf("输入数组 nums = ");
printArray(nums, numsSize);
printf("\n所有排列 res = \n");
for (int i = 0; i < returnSize; i++) {
printArray(res[i], numsSize);
}
// 释放内存
for (int i = 0; i < returnSize; i++) {
free(res[i]);
}
free(res);
return 0;
}
================================================
FILE: codes/c/chapter_backtracking/permutations_ii.c
================================================
/**
* File: permutations_ii.c
* Created Time: 2023-10-17
* Author: krahets (krahets@163.com)
*/
#include "../utils/common.h"
// 假设最多有 1000 个排列,元素最大为 1000
#define MAX_SIZE 1000
/* 回溯算法:全排列 II */
void backtrack(int *state, int stateSize, int *choices, int choicesSize, bool *selected, int **res, int *resSize) {
// 当状态长度等于元素数量时,记录解
if (stateSize == choicesSize) {
res[*resSize] = (int *)malloc(choicesSize * sizeof(int));
for (int i = 0; i < choicesSize; i++) {
res[*resSize][i] = state[i];
}
(*resSize)++;
return;
}
// 遍历所有选择
bool duplicated[MAX_SIZE] = {false};
for (int i = 0; i < choicesSize; i++) {
int choice = choices[i];
// 剪枝:不允许重复选择元素 且 不允许重复选择相等元素
if (!selected[i] && !duplicated[choice]) {
// 尝试:做出选择,更新状态
duplicated[choice] = true; // 记录选择过的元素值
selected[i] = true;
state[stateSize] = choice;
// 进行下一轮选择
backtrack(state, stateSize + 1, choices, choicesSize, selected, res, resSize);
// 回退:撤销选择,恢复到之前的状态
selected[i] = false;
}
}
}
/* 全排列 II */
int **permutationsII(int *nums, int numsSize, int *returnSize) {
int *state = (int *)malloc(numsSize * sizeof(int));
bool *selected = (bool *)malloc(numsSize * sizeof(bool));
for (int i = 0; i < numsSize; i++) {
selected[i] = false;
}
int **res = (int **)malloc(MAX_SIZE * sizeof(int *));
*returnSize = 0;
backtrack(state, 0, nums, numsSize, selected, res, returnSize);
free(state);
free(selected);
return res;
}
/* Driver Code */
int main() {
int nums[] = {1, 1, 2};
int numsSize = sizeof(nums) / sizeof(nums[0]);
int returnSize;
int **res = permutationsII(nums, numsSize, &returnSize);
printf("输入数组 nums = ");
printArray(nums, numsSize);
printf("\n所有排列 res = \n");
for (int i = 0; i < returnSize; i++) {
printArray(res[i], numsSize);
}
// 释放内存
for (int i = 0; i < returnSize; i++) {
free(res[i]);
}
free(res);
return 0;
}
================================================
FILE: codes/c/chapter_backtracking/preorder_traversal_i_compact.c
================================================
/**
* File: preorder_traversal_i_compact.c
* Created Time: 2023-05-10
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
// 假设结果长度不超过 100
#define MAX_SIZE 100
TreeNode *res[MAX_SIZE];
int resSize = 0;
/* 前序遍历:例题一 */
void preOrder(TreeNode *root) {
if (root == NULL) {
return;
}
if (root->val == 7) {
// 记录解
res[resSize++] = root;
}
preOrder(root->left);
preOrder(root->right);
}
/* Driver Code */
int main() {
int arr[] = {1, 7, 3, 4, 5, 6, 7};
TreeNode *root = arrayToTree(arr, sizeof(arr) / sizeof(arr[0]));
printf("\n初始化二叉树\n");
printTree(root);
// 前序遍历
preOrder(root);
printf("\n输出所有值为 7 的节点\n");
int *vals = malloc(resSize * sizeof(int));
for (int i = 0; i < resSize; i++) {
vals[i] = res[i]->val;
}
printArray(vals, resSize);
// 释放内存
freeMemoryTree(root);
free(vals);
return 0;
}
================================================
FILE: codes/c/chapter_backtracking/preorder_traversal_ii_compact.c
================================================
/**
* File: preorder_traversal_ii_compact.c
* Created Time: 2023-05-28
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
// 假设路径和结果长度不超过 100
#define MAX_SIZE 100
#define MAX_RES_SIZE 100
TreeNode *path[MAX_SIZE];
TreeNode *res[MAX_RES_SIZE][MAX_SIZE];
int pathSize = 0, resSize = 0;
/* 前序遍历:例题二 */
void preOrder(TreeNode *root) {
if (root == NULL) {
return;
}
// 尝试
path[pathSize++] = root;
if (root->val == 7) {
// 记录解
for (int i = 0; i < pathSize; ++i) {
res[resSize][i] = path[i];
}
resSize++;
}
preOrder(root->left);
preOrder(root->right);
// 回退
pathSize--;
}
/* Driver Code */
int main() {
int arr[] = {1, 7, 3, 4, 5, 6, 7};
TreeNode *root = arrayToTree(arr, sizeof(arr) / sizeof(arr[0]));
printf("\n初始化二叉树\n");
printTree(root);
// 前序遍历
preOrder(root);
printf("\n输出所有根节点到节点 7 的路径\n");
for (int i = 0; i < resSize; ++i) {
int *vals = malloc(MAX_SIZE * sizeof(int));
int size = 0;
for (int j = 0; res[i][j] != NULL; ++j) {
vals[size++] = res[i][j]->val;
}
printArray(vals, size);
free(vals);
}
// 释放内存
freeMemoryTree(root);
return 0;
}
================================================
FILE: codes/c/chapter_backtracking/preorder_traversal_iii_compact.c
================================================
/**
* File: preorder_traversal_iii_compact.c
* Created Time: 2023-06-04
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
// 假设路径和结果长度不超过 100
#define MAX_SIZE 100
#define MAX_RES_SIZE 100
TreeNode *path[MAX_SIZE];
TreeNode *res[MAX_RES_SIZE][MAX_SIZE];
int pathSize = 0, resSize = 0;
/* 前序遍历:例题三 */
void preOrder(TreeNode *root) {
// 剪枝
if (root == NULL || root->val == 3) {
return;
}
// 尝试
path[pathSize++] = root;
if (root->val == 7) {
// 记录解
for (int i = 0; i < pathSize; i++) {
res[resSize][i] = path[i];
}
resSize++;
}
preOrder(root->left);
preOrder(root->right);
// 回退
pathSize--;
}
/* Driver Code */
int main() {
int arr[] = {1, 7, 3, 4, 5, 6, 7};
TreeNode *root = arrayToTree(arr, sizeof(arr) / sizeof(arr[0]));
printf("\n初始化二叉树\n");
printTree(root);
// 前序遍历
preOrder(root);
printf("\n输出所有根节点到节点 7 的路径,要求路径中不包含值为 3 的节点\n");
for (int i = 0; i < resSize; ++i) {
int *vals = malloc(MAX_SIZE * sizeof(int));
int size = 0;
for (int j = 0; res[i][j] != NULL; ++j) {
vals[size++] = res[i][j]->val;
}
printArray(vals, size);
free(vals);
}
// 释放内存
freeMemoryTree(root);
return 0;
}
================================================
FILE: codes/c/chapter_backtracking/preorder_traversal_iii_template.c
================================================
/**
* File: preorder_traversal_iii_template.c
* Created Time: 2023-06-04
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
// 假设路径和结果长度不超过 100
#define MAX_SIZE 100
#define MAX_RES_SIZE 100
TreeNode *path[MAX_SIZE];
TreeNode *res[MAX_RES_SIZE][MAX_SIZE];
int pathSize = 0, resSize = 0;
/* 判断当前状态是否为解 */
bool isSolution(void) {
return pathSize > 0 && path[pathSize - 1]->val == 7;
}
/* 记录解 */
void recordSolution(void) {
for (int i = 0; i < pathSize; i++) {
res[resSize][i] = path[i];
}
resSize++;
}
/* 判断在当前状态下,该选择是否合法 */
bool isValid(TreeNode *choice) {
return choice != NULL && choice->val != 3;
}
/* 更新状态 */
void makeChoice(TreeNode *choice) {
path[pathSize++] = choice;
}
/* 恢复状态 */
void undoChoice(void) {
pathSize--;
}
/* 回溯算法:例题三 */
void backtrack(TreeNode *choices[2]) {
// 检查是否为解
if (isSolution()) {
// 记录解
recordSolution();
}
// 遍历所有选择
for (int i = 0; i < 2; i++) {
TreeNode *choice = choices[i];
// 剪枝:检查选择是否合法
if (isValid(choice)) {
// 尝试:做出选择,更新状态
makeChoice(choice);
// 进行下一轮选择
TreeNode *nextChoices[2] = {choice->left, choice->right};
backtrack(nextChoices);
// 回退:撤销选择,恢复到之前的状态
undoChoice();
}
}
}
/* Driver Code */
int main() {
int arr[] = {1, 7, 3, 4, 5, 6, 7};
TreeNode *root = arrayToTree(arr, sizeof(arr) / sizeof(arr[0]));
printf("\n初始化二叉树\n");
printTree(root);
// 回溯算法
TreeNode *choices[2] = {root, NULL};
backtrack(choices);
printf("\n输出所有根节点到节点 7 的路径,要求路径中不包含值为 3 的节点\n");
for (int i = 0; i < resSize; ++i) {
int *vals = malloc(MAX_SIZE * sizeof(int));
int size = 0;
for (int j = 0; res[i][j] != NULL; ++j) {
vals[size++] = res[i][j]->val;
}
printArray(vals, size);
free(vals);
}
// 释放内存
freeMemoryTree(root);
return 0;
}
================================================
FILE: codes/c/chapter_backtracking/subset_sum_i.c
================================================
/**
* File: subset_sum_i.c
* Created Time: 2023-07-29
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
#define MAX_SIZE 100
#define MAX_RES_SIZE 100
// 状态(子集)
int state[MAX_SIZE];
int stateSize = 0;
// 结果列表(子集列表)
int res[MAX_RES_SIZE][MAX_SIZE];
int resColSizes[MAX_RES_SIZE];
int resSize = 0;
/* 回溯算法:子集和 I */
void backtrack(int target, int *choices, int choicesSize, int start) {
// 子集和等于 target 时,记录解
if (target == 0) {
for (int i = 0; i < stateSize; ++i) {
res[resSize][i] = state[i];
}
resColSizes[resSize++] = stateSize;
return;
}
// 遍历所有选择
// 剪枝二:从 start 开始遍历,避免生成重复子集
for (int i = start; i < choicesSize; i++) {
// 剪枝一:若子集和超过 target ,则直接结束循环
// 这是因为数组已排序,后边元素更大,子集和一定超过 target
if (target - choices[i] < 0) {
break;
}
// 尝试:做出选择,更新 target, start
state[stateSize] = choices[i];
stateSize++;
// 进行下一轮选择
backtrack(target - choices[i], choices, choicesSize, i);
// 回退:撤销选择,恢复到之前的状态
stateSize--;
}
}
/* 比较函数 */
int cmp(const void *a, const void *b) {
return (*(int *)a - *(int *)b);
}
/* 求解子集和 I */
void subsetSumI(int *nums, int numsSize, int target) {
qsort(nums, numsSize, sizeof(int), cmp); // 对 nums 进行排序
int start = 0; // 遍历起始点
backtrack(target, nums, numsSize, start);
}
/* Driver Code */
int main() {
int nums[] = {3, 4, 5};
int numsSize = sizeof(nums) / sizeof(nums[0]);
int target = 9;
subsetSumI(nums, numsSize, target);
printf("输入数组 nums = ");
printArray(nums, numsSize);
printf("target = %d\n", target);
printf("所有和等于 %d 的子集 res = \n", target);
for (int i = 0; i < resSize; ++i) {
printArray(res[i], resColSizes[i]);
}
return 0;
}
================================================
FILE: codes/c/chapter_backtracking/subset_sum_i_naive.c
================================================
/**
* File: subset_sum_i_naive.c
* Created Time: 2023-07-28
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
#define MAX_SIZE 100
#define MAX_RES_SIZE 100
// 状态(子集)
int state[MAX_SIZE];
int stateSize = 0;
// 结果列表(子集列表)
int res[MAX_RES_SIZE][MAX_SIZE];
int resColSizes[MAX_RES_SIZE];
int resSize = 0;
/* 回溯算法:子集和 I */
void backtrack(int target, int total, int *choices, int choicesSize) {
// 子集和等于 target 时,记录解
if (total == target) {
for (int i = 0; i < stateSize; i++) {
res[resSize][i] = state[i];
}
resColSizes[resSize++] = stateSize;
return;
}
// 遍历所有选择
for (int i = 0; i < choicesSize; i++) {
// 剪枝:若子集和超过 target ,则跳过该选择
if (total + choices[i] > target) {
continue;
}
// 尝试:做出选择,更新元素和 total
state[stateSize++] = choices[i];
// 进行下一轮选择
backtrack(target, total + choices[i], choices, choicesSize);
// 回退:撤销选择,恢复到之前的状态
stateSize--;
}
}
/* 求解子集和 I(包含重复子集) */
void subsetSumINaive(int *nums, int numsSize, int target) {
resSize = 0; // 初始化解的数量为0
backtrack(target, 0, nums, numsSize);
}
/* Driver Code */
int main() {
int nums[] = {3, 4, 5};
int numsSize = sizeof(nums) / sizeof(nums[0]);
int target = 9;
subsetSumINaive(nums, numsSize, target);
printf("输入数组 nums = ");
printArray(nums, numsSize);
printf("target = %d\n", target);
printf("所有和等于 %d 的子集 res = \n", target);
for (int i = 0; i < resSize; i++) {
printArray(res[i], resColSizes[i]);
}
return 0;
}
================================================
FILE: codes/c/chapter_backtracking/subset_sum_ii.c
================================================
/**
* File: subset_sum_ii.c
* Created Time: 2023-07-29
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
#define MAX_SIZE 100
#define MAX_RES_SIZE 100
// 状态(子集)
int state[MAX_SIZE];
int stateSize = 0;
// 结果列表(子集列表)
int res[MAX_RES_SIZE][MAX_SIZE];
int resColSizes[MAX_RES_SIZE];
int resSize = 0;
/* 回溯算法:子集和 II */
void backtrack(int target, int *choices, int choicesSize, int start) {
// 子集和等于 target 时,记录解
if (target == 0) {
for (int i = 0; i < stateSize; i++) {
res[resSize][i] = state[i];
}
resColSizes[resSize++] = stateSize;
return;
}
// 遍历所有选择
// 剪枝二:从 start 开始遍历,避免生成重复子集
// 剪枝三:从 start 开始遍历,避免重复选择同一元素
for (int i = start; i < choicesSize; i++) {
// 剪枝一:若子集和超过 target ,则直接跳过
if (target - choices[i] < 0) {
continue;
}
// 剪枝四:如果该元素与左边元素相等,说明该搜索分支重复,直接跳过
if (i > start && choices[i] == choices[i - 1]) {
continue;
}
// 尝试:做出选择,更新 target, start
state[stateSize] = choices[i];
stateSize++;
// 进行下一轮选择
backtrack(target - choices[i], choices, choicesSize, i + 1);
// 回退:撤销选择,恢复到之前的状态
stateSize--;
}
}
/* 比较函数 */
int cmp(const void *a, const void *b) {
return (*(int *)a - *(int *)b);
}
/* 求解子集和 II */
void subsetSumII(int *nums, int numsSize, int target) {
// 对 nums 进行排序
qsort(nums, numsSize, sizeof(int), cmp);
// 开始回溯
backtrack(target, nums, numsSize, 0);
}
/* Driver Code */
int main() {
int nums[] = {4, 4, 5};
int numsSize = sizeof(nums) / sizeof(nums[0]);
int target = 9;
subsetSumII(nums, numsSize, target);
printf("输入数组 nums = ");
printArray(nums, numsSize);
printf("target = %d\n", target);
printf("所有和等于 %d 的子集 res = \n", target);
for (int i = 0; i < resSize; ++i) {
printArray(res[i], resColSizes[i]);
}
return 0;
}
================================================
FILE: codes/c/chapter_computational_complexity/CMakeLists.txt
================================================
add_executable(iteration iteration.c)
add_executable(recursion recursion.c)
add_executable(time_complexity time_complexity.c)
add_executable(worst_best_time_complexity worst_best_time_complexity.c)
add_executable(space_complexity space_complexity.c)
================================================
FILE: codes/c/chapter_computational_complexity/iteration.c
================================================
/**
* File: iteration.c
* Created Time: 2023-09-09
* Author: Gonglja (glj0@outlook.com), MwumLi (mwumli@hotmail.com)
*/
#include "../utils/common.h"
/* for 循环 */
int forLoop(int n) {
int res = 0;
// 循环求和 1, 2, ..., n-1, n
for (int i = 1; i <= n; i++) {
res += i;
}
return res;
}
/* while 循环 */
int whileLoop(int n) {
int res = 0;
int i = 1; // 初始化条件变量
// 循环求和 1, 2, ..., n-1, n
while (i <= n) {
res += i;
i++; // 更新条件变量
}
return res;
}
/* while 循环(两次更新) */
int whileLoopII(int n) {
int res = 0;
int i = 1; // 初始化条件变量
// 循环求和 1, 4, 10, ...
while (i <= n) {
res += i;
// 更新条件变量
i++;
i *= 2;
}
return res;
}
/* 双层 for 循环 */
char *nestedForLoop(int n) {
// n * n 为对应点数量,"(i, j), " 对应字符串长最大为 6+10*2,加上最后一个空字符 \0 的额外空间
int size = n * n * 26 + 1;
char *res = malloc(size * sizeof(char));
// 循环 i = 1, 2, ..., n-1, n
for (int i = 1; i <= n; i++) {
// 循环 j = 1, 2, ..., n-1, n
for (int j = 1; j <= n; j++) {
char tmp[26];
snprintf(tmp, sizeof(tmp), "(%d, %d), ", i, j);
strncat(res, tmp, size - strlen(res) - 1);
}
}
return res;
}
/* Driver Code */
int main() {
int n = 5;
int res;
res = forLoop(n);
printf("\nfor 循环的求和结果 res = %d\n", res);
res = whileLoop(n);
printf("\nwhile 循环的求和结果 res = %d\n", res);
res = whileLoopII(n);
printf("\nwhile 循环(两次更新)求和结果 res = %d\n", res);
char *resStr = nestedForLoop(n);
printf("\n双层 for 循环的遍历结果 %s\r\n", resStr);
free(resStr);
return 0;
}
================================================
FILE: codes/c/chapter_computational_complexity/recursion.c
================================================
/**
* File: recursion.c
* Created Time: 2023-09-09
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
/* 递归 */
int recur(int n) {
// 终止条件
if (n == 1)
return 1;
// 递:递归调用
int res = recur(n - 1);
// 归:返回结果
return n + res;
}
/* 使用迭代模拟递归 */
int forLoopRecur(int n) {
int stack[1000]; // 借助一个大数组来模拟栈
int top = -1; // 栈顶索引
int res = 0;
// 递:递归调用
for (int i = n; i > 0; i--) {
// 通过“入栈操作”模拟“递”
stack[1 + top++] = i;
}
// 归:返回结果
while (top >= 0) {
// 通过“出栈操作”模拟“归”
res += stack[top--];
}
// res = 1+2+3+...+n
return res;
}
/* 尾递归 */
int tailRecur(int n, int res) {
// 终止条件
if (n == 0)
return res;
// 尾递归调用
return tailRecur(n - 1, res + n);
}
/* 斐波那契数列:递归 */
int fib(int n) {
// 终止条件 f(1) = 0, f(2) = 1
if (n == 1 || n == 2)
return n - 1;
// 递归调用 f(n) = f(n-1) + f(n-2)
int res = fib(n - 1) + fib(n - 2);
// 返回结果 f(n)
return res;
}
/* Driver Code */
int main() {
int n = 5;
int res;
res = recur(n);
printf("\n递归函数的求和结果 res = %d\n", res);
res = forLoopRecur(n);
printf("\n使用迭代模拟递归求和结果 res = %d\n", res);
res = tailRecur(n, 0);
printf("\n尾递归函数的求和结果 res = %d\n", res);
res = fib(n);
printf("\n斐波那契数列的第 %d 项为 %d\n", n, res);
return 0;
}
================================================
FILE: codes/c/chapter_computational_complexity/space_complexity.c
================================================
/**
* File: space_complexity.c
* Created Time: 2023-04-15
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
/* 函数 */
int func() {
// 执行某些操作
return 0;
}
/* 常数阶 */
void constant(int n) {
// 常量、变量、对象占用 O(1) 空间
const int a = 0;
int b = 0;
int nums[1000];
ListNode *node = newListNode(0);
free(node);
// 循环中的变量占用 O(1) 空间
for (int i = 0; i < n; i++) {
int c = 0;
}
// 循环中的函数占用 O(1) 空间
for (int i = 0; i < n; i++) {
func();
}
}
/* 哈希表 */
typedef struct {
int key;
int val;
UT_hash_handle hh; // 基于 uthash.h 实现
} HashTable;
/* 线性阶 */
void linear(int n) {
// 长度为 n 的数组占用 O(n) 空间
int *nums = malloc(sizeof(int) * n);
free(nums);
// 长度为 n 的列表占用 O(n) 空间
ListNode **nodes = malloc(sizeof(ListNode *) * n);
for (int i = 0; i < n; i++) {
nodes[i] = newListNode(i);
}
// 内存释放
for (int i = 0; i < n; i++) {
free(nodes[i]);
}
free(nodes);
// 长度为 n 的哈希表占用 O(n) 空间
HashTable *h = NULL;
for (int i = 0; i < n; i++) {
HashTable *tmp = malloc(sizeof(HashTable));
tmp->key = i;
tmp->val = i;
HASH_ADD_INT(h, key, tmp);
}
// 内存释放
HashTable *curr, *tmp;
HASH_ITER(hh, h, curr, tmp) {
HASH_DEL(h, curr);
free(curr);
}
}
/* 线性阶(递归实现) */
void linearRecur(int n) {
printf("递归 n = %d\r\n", n);
if (n == 1)
return;
linearRecur(n - 1);
}
/* 平方阶 */
void quadratic(int n) {
// 二维列表占用 O(n^2) 空间
int **numMatrix = malloc(sizeof(int *) * n);
for (int i = 0; i < n; i++) {
int *tmp = malloc(sizeof(int) * n);
for (int j = 0; j < n; j++) {
tmp[j] = 0;
}
numMatrix[i] = tmp;
}
// 内存释放
for (int i = 0; i < n; i++) {
free(numMatrix[i]);
}
free(numMatrix);
}
/* 平方阶(递归实现) */
int quadraticRecur(int n) {
if (n <= 0)
return 0;
int *nums = malloc(sizeof(int) * n);
printf("递归 n = %d 中的 nums 长度 = %d\r\n", n, n);
int res = quadraticRecur(n - 1);
free(nums);
return res;
}
/* 指数阶(建立满二叉树) */
TreeNode *buildTree(int n) {
if (n == 0)
return NULL;
TreeNode *root = newTreeNode(0);
root->left = buildTree(n - 1);
root->right = buildTree(n - 1);
return root;
}
/* Driver Code */
int main() {
int n = 5;
// 常数阶
constant(n);
// 线性阶
linear(n);
linearRecur(n);
// 平方阶
quadratic(n);
quadraticRecur(n);
// 指数阶
TreeNode *root = buildTree(n);
printTree(root);
// 释放内存
freeMemoryTree(root);
return 0;
}
================================================
FILE: codes/c/chapter_computational_complexity/time_complexity.c
================================================
/**
* File: time_complexity.c
* Created Time: 2023-01-03
* Author: codingonion (coderonion@gmail.com)
*/
#include "../utils/common.h"
/* 常数阶 */
int constant(int n) {
int count = 0;
int size = 100000;
int i = 0;
for (int i = 0; i < size; i++) {
count++;
}
return count;
}
/* 线性阶 */
int linear(int n) {
int count = 0;
for (int i = 0; i < n; i++) {
count++;
}
return count;
}
/* 线性阶(遍历数组) */
int arrayTraversal(int *nums, int n) {
int count = 0;
// 循环次数与数组长度成正比
for (int i = 0; i < n; i++) {
count++;
}
return count;
}
/* 平方阶 */
int quadratic(int n) {
int count = 0;
// 循环次数与数据大小 n 成平方关系
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
count++;
}
}
return count;
}
/* 平方阶(冒泡排序) */
int bubbleSort(int *nums, int n) {
int count = 0; // 计数器
// 外循环:未排序区间为 [0, i]
for (int i = n - 1; i > 0; i--) {
// 内循环:将未排序区间 [0, i] 中的最大元素交换至该区间的最右端
for (int j = 0; j < i; j++) {
if (nums[j] > nums[j + 1]) {
// 交换 nums[j] 与 nums[j + 1]
int tmp = nums[j];
nums[j] = nums[j + 1];
nums[j + 1] = tmp;
count += 3; // 元素交换包含 3 个单元操作
}
}
}
return count;
}
/* 指数阶(循环实现) */
int exponential(int n) {
int count = 0;
int bas = 1;
// 细胞每轮一分为二,形成数列 1, 2, 4, 8, ..., 2^(n-1)
for (int i = 0; i < n; i++) {
for (int j = 0; j < bas; j++) {
count++;
}
bas *= 2;
}
// count = 1 + 2 + 4 + 8 + .. + 2^(n-1) = 2^n - 1
return count;
}
/* 指数阶(递归实现) */
int expRecur(int n) {
if (n == 1)
return 1;
return expRecur(n - 1) + expRecur(n - 1) + 1;
}
/* 对数阶(循环实现) */
int logarithmic(int n) {
int count = 0;
while (n > 1) {
n = n / 2;
count++;
}
return count;
}
/* 对数阶(递归实现) */
int logRecur(int n) {
if (n <= 1)
return 0;
return logRecur(n / 2) + 1;
}
/* 线性对数阶 */
int linearLogRecur(int n) {
if (n <= 1)
return 1;
int count = linearLogRecur(n / 2) + linearLogRecur(n / 2);
for (int i = 0; i < n; i++) {
count++;
}
return count;
}
/* 阶乘阶(递归实现) */
int factorialRecur(int n) {
if (n == 0)
return 1;
int count = 0;
for (int i = 0; i < n; i++) {
count += factorialRecur(n - 1);
}
return count;
}
/* Driver Code */
int main(int argc, char *argv[]) {
// 可以修改 n 运行,体会一下各种复杂度的操作数量变化趋势
int n = 8;
printf("输入数据大小 n = %d\n", n);
int count = constant(n);
printf("常数阶的操作数量 = %d\n", count);
count = linear(n);
printf("线性阶的操作数量 = %d\n", count);
// 分配堆区内存(创建一维可变长数组:数组中元素数量为 n ,元素类型为 int )
int *nums = (int *)malloc(n * sizeof(int));
count = arrayTraversal(nums, n);
printf("线性阶(遍历数组)的操作数量 = %d\n", count);
count = quadratic(n);
printf("平方阶的操作数量 = %d\n", count);
for (int i = 0; i < n; i++) {
nums[i] = n - i; // [n,n-1,...,2,1]
}
count = bubbleSort(nums, n);
printf("平方阶(冒泡排序)的操作数量 = %d\n", count);
count = exponential(n);
printf("指数阶(循环实现)的操作数量 = %d\n", count);
count = expRecur(n);
printf("指数阶(递归实现)的操作数量 = %d\n", count);
count = logarithmic(n);
printf("对数阶(循环实现)的操作数量 = %d\n", count);
count = logRecur(n);
printf("对数阶(递归实现)的操作数量 = %d\n", count);
count = linearLogRecur(n);
printf("线性对数阶(递归实现)的操作数量 = %d\n", count);
count = factorialRecur(n);
printf("阶乘阶(递归实现)的操作数量 = %d\n", count);
// 释放堆区内存
if (nums != NULL) {
free(nums);
nums = NULL;
}
getchar();
return 0;
}
================================================
FILE: codes/c/chapter_computational_complexity/worst_best_time_complexity.c
================================================
/**
* File: worst_best_time_complexity.c
* Created Time: 2023-01-03
* Author: codingonion (coderonion@gmail.com)
*/
#include "../utils/common.h"
/* 生成一个数组,元素为 { 1, 2, ..., n },顺序被打乱 */
int *randomNumbers(int n) {
// 分配堆区内存(创建一维可变长数组:数组中元素数量为 n ,元素类型为 int )
int *nums = (int *)malloc(n * sizeof(int));
// 生成数组 nums = { 1, 2, 3, ..., n }
for (int i = 0; i < n; i++) {
nums[i] = i + 1;
}
// 随机打乱数组元素
for (int i = n - 1; i > 0; i--) {
int j = rand() % (i + 1);
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
}
return nums;
}
/* 查找数组 nums 中数字 1 所在索引 */
int findOne(int *nums, int n) {
for (int i = 0; i < n; i++) {
// 当元素 1 在数组头部时,达到最佳时间复杂度 O(1)
// 当元素 1 在数组尾部时,达到最差时间复杂度 O(n)
if (nums[i] == 1)
return i;
}
return -1;
}
/* Driver Code */
int main(int argc, char *argv[]) {
// 初始化随机数种子
srand((unsigned int)time(NULL));
for (int i = 0; i < 10; i++) {
int n = 100;
int *nums = randomNumbers(n);
int index = findOne(nums, n);
printf("\n数组 [ 1, 2, ..., n ] 被打乱后 = ");
printArray(nums, n);
printf("数字 1 的索引为 %d\n", index);
// 释放堆区内存
if (nums != NULL) {
free(nums);
nums = NULL;
}
}
return 0;
}
================================================
FILE: codes/c/chapter_divide_and_conquer/CMakeLists.txt
================================================
add_executable(binary_search_recur binary_search_recur.c)
add_executable(build_tree build_tree.c)
add_executable(hanota hanota.c)
================================================
FILE: codes/c/chapter_divide_and_conquer/binary_search_recur.c
================================================
/**
* File: binary_search_recur.c
* Created Time: 2023-10-01
* Author: Zuoxun (845242523@qq.com)
*/
#include "../utils/common.h"
/* 二分查找:问题 f(i, j) */
int dfs(int nums[], int target, int i, int j) {
// 若区间为空,代表无目标元素,则返回 -1
if (i > j) {
return -1;
}
// 计算中点索引 m
int m = (i + j) / 2;
if (nums[m] < target) {
// 递归子问题 f(m+1, j)
return dfs(nums, target, m + 1, j);
} else if (nums[m] > target) {
// 递归子问题 f(i, m-1)
return dfs(nums, target, i, m - 1);
} else {
// 找到目标元素,返回其索引
return m;
}
}
/* 二分查找 */
int binarySearch(int nums[], int target, int numsSize) {
int n = numsSize;
// 求解问题 f(0, n-1)
return dfs(nums, target, 0, n - 1);
}
/* Driver Code */
int main() {
int target = 6;
int nums[] = {1, 3, 6, 8, 12, 15, 23, 26, 31, 35};
int numsSize = sizeof(nums) / sizeof(nums[0]);
// 二分查找(双闭区间)
int index = binarySearch(nums, target, numsSize);
printf("目标元素 6 的索引 = %d\n", index);
return 0;
}
================================================
FILE: codes/c/chapter_divide_and_conquer/build_tree.c
================================================
/**
* File : build_tree.c
* Created Time: 2023-10-16
* Author : lucas (superrat6@gmail.com)
*/
#include "../utils/common.h"
// 假设所有元素都小于 1000
#define MAX_SIZE 1000
/* 构建二叉树:分治 */
TreeNode *dfs(int *preorder, int *inorderMap, int i, int l, int r, int size) {
// 子树区间为空时终止
if (r - l < 0)
return NULL;
// 初始化根节点
TreeNode *root = (TreeNode *)malloc(sizeof(TreeNode));
root->val = preorder[i];
root->left = NULL;
root->right = NULL;
// 查询 m ,从而划分左右子树
int m = inorderMap[preorder[i]];
// 子问题:构建左子树
root->left = dfs(preorder, inorderMap, i + 1, l, m - 1, size);
// 子问题:构建右子树
root->right = dfs(preorder, inorderMap, i + 1 + m - l, m + 1, r, size);
// 返回根节点
return root;
}
/* 构建二叉树 */
TreeNode *buildTree(int *preorder, int preorderSize, int *inorder, int inorderSize) {
// 初始化哈希表,存储 inorder 元素到索引的映射
int *inorderMap = (int *)malloc(sizeof(int) * MAX_SIZE);
for (int i = 0; i < inorderSize; i++) {
inorderMap[inorder[i]] = i;
}
TreeNode *root = dfs(preorder, inorderMap, 0, 0, inorderSize - 1, inorderSize);
free(inorderMap);
return root;
}
/* Driver Code */
int main() {
int preorder[] = {3, 9, 2, 1, 7};
int inorder[] = {9, 3, 1, 2, 7};
int preorderSize = sizeof(preorder) / sizeof(preorder[0]);
int inorderSize = sizeof(inorder) / sizeof(inorder[0]);
printf("前序遍历 = ");
printArray(preorder, preorderSize);
printf("中序遍历 = ");
printArray(inorder, inorderSize);
TreeNode *root = buildTree(preorder, preorderSize, inorder, inorderSize);
printf("构建的二叉树为:\n");
printTree(root);
freeMemoryTree(root);
return 0;
}
================================================
FILE: codes/c/chapter_divide_and_conquer/hanota.c
================================================
/**
* File: hanota.c
* Created Time: 2023-10-01
* Author: Zuoxun (845242523@qq.com), lucas(superrat6@gmail.com)
*/
#include "../utils/common.h"
// 假设最多有 1000 个排列
#define MAX_SIZE 1000
/* 移动一个圆盘 */
void move(int *src, int *srcSize, int *tar, int *tarSize) {
// 从 src 顶部拿出一个圆盘
int pan = src[*srcSize - 1];
src[*srcSize - 1] = 0;
(*srcSize)--;
// 将圆盘放入 tar 顶部
tar[*tarSize] = pan;
(*tarSize)++;
}
/* 求解汉诺塔问题 f(i) */
void dfs(int i, int *src, int *srcSize, int *buf, int *bufSize, int *tar, int *tarSize) {
// 若 src 只剩下一个圆盘,则直接将其移到 tar
if (i == 1) {
move(src, srcSize, tar, tarSize);
return;
}
// 子问题 f(i-1) :将 src 顶部 i-1 个圆盘借助 tar 移到 buf
dfs(i - 1, src, srcSize, tar, tarSize, buf, bufSize);
// 子问题 f(1) :将 src 剩余一个圆盘移到 tar
move(src, srcSize, tar, tarSize);
// 子问题 f(i-1) :将 buf 顶部 i-1 个圆盘借助 src 移到 tar
dfs(i - 1, buf, bufSize, src, srcSize, tar, tarSize);
}
/* 求解汉诺塔问题 */
void solveHanota(int *A, int *ASize, int *B, int *BSize, int *C, int *CSize) {
// 将 A 顶部 n 个圆盘借助 B 移到 C
dfs(*ASize, A, ASize, B, BSize, C, CSize);
}
/* Driver Code */
int main() {
// 列表尾部是柱子顶部
int a[] = {5, 4, 3, 2, 1};
int b[MAX_SIZE] = {0};
int c[MAX_SIZE] = {0};
int ASize = sizeof(a) / sizeof(a[0]);
int BSize = 0;
int CSize = 0;
printf("\n初始状态下:");
printf("\nA = ");
printArray(a, ASize);
printf("B = ");
printArray(b, BSize);
printf("C = ");
printArray(c, CSize);
solveHanota(a, &ASize, b, &BSize, c, &CSize);
printf("\n圆盘移动完成后:");
printf("A = ");
printArray(a, ASize);
printf("B = ");
printArray(b, BSize);
printf("C = ");
printArray(c, CSize);
return 0;
}
================================================
FILE: codes/c/chapter_dynamic_programming/CMakeLists.txt
================================================
add_executable(climbing_stairs_constraint_dp climbing_stairs_constraint_dp.c)
add_executable(min_cost_climbing_stairs_dp min_cost_climbing_stairs_dp.c)
add_executable(min_path_sum min_path_sum.c)
add_executable(knapsack knapsack.c)
add_executable(unbounded_knapsack unbounded_knapsack.c)
add_executable(coin_change coin_change.c)
add_executable(coin_change_ii coin_change_ii.c)
add_executable(edit_distance edit_distance.c)
================================================
FILE: codes/c/chapter_dynamic_programming/climbing_stairs_backtrack.c
================================================
/**
* File: climbing_stairs_backtrack.c
* Created Time: 2023-09-22
* Author: huawuque404 (huawuque404@163.com)
*/
#include "../utils/common.h"
/* 回溯 */
void backtrack(int *choices, int state, int n, int *res, int len) {
// 当爬到第 n 阶时,方案数量加 1
if (state == n)
res[0]++;
// 遍历所有选择
for (int i = 0; i < len; i++) {
int choice = choices[i];
// 剪枝:不允许越过第 n 阶
if (state + choice > n)
continue;
// 尝试:做出选择,更新状态
backtrack(choices, state + choice, n, res, len);
// 回退
}
}
/* 爬楼梯:回溯 */
int climbingStairsBacktrack(int n) {
int choices[2] = {1, 2}; // 可选择向上爬 1 阶或 2 阶
int state = 0; // 从第 0 阶开始爬
int *res = (int *)malloc(sizeof(int));
*res = 0; // 使用 res[0] 记录方案数量
int len = sizeof(choices) / sizeof(int);
backtrack(choices, state, n, res, len);
int result = *res;
free(res);
return result;
}
/* Driver Code */
int main() {
int n = 9;
int res = climbingStairsBacktrack(n);
printf("爬 %d 阶楼梯共有 %d 种方案\n", n, res);
return 0;
}
================================================
FILE: codes/c/chapter_dynamic_programming/climbing_stairs_constraint_dp.c
================================================
/**
* File: climbing_stairs_constraint_dp.c
* Created Time: 2023-10-02
* Author: Zuoxun (845242523@qq.com)
*/
#include "../utils/common.h"
/* 带约束爬楼梯:动态规划 */
int climbingStairsConstraintDP(int n) {
if (n == 1 || n == 2) {
return 1;
}
// 初始化 dp 表,用于存储子问题的解
int **dp = malloc((n + 1) * sizeof(int *));
for (int i = 0; i <= n; i++) {
dp[i] = calloc(3, sizeof(int));
}
// 初始状态:预设最小子问题的解
dp[1][1] = 1;
dp[1][2] = 0;
dp[2][1] = 0;
dp[2][2] = 1;
// 状态转移:从较小子问题逐步求解较大子问题
for (int i = 3; i <= n; i++) {
dp[i][1] = dp[i - 1][2];
dp[i][2] = dp[i - 2][1] + dp[i - 2][2];
}
int res = dp[n][1] + dp[n][2];
// 释放内存
for (int i = 0; i <= n; i++) {
free(dp[i]);
}
free(dp);
return res;
}
/* Driver Code */
int main() {
int n = 9;
int res = climbingStairsConstraintDP(n);
printf("爬 %d 阶楼梯共有 %d 种方案\n", n, res);
return 0;
}
================================================
FILE: codes/c/chapter_dynamic_programming/climbing_stairs_dfs.c
================================================
/**
* File: climbing_stairs_dfs.c
* Created Time: 2023-09-19
* Author: huawuque404 (huawuque404@163.com)
*/
#include "../utils/common.h"
/* 搜索 */
int dfs(int i) {
// 已知 dp[1] 和 dp[2] ,返回之
if (i == 1 || i == 2)
return i;
// dp[i] = dp[i-1] + dp[i-2]
int count = dfs(i - 1) + dfs(i - 2);
return count;
}
/* 爬楼梯:搜索 */
int climbingStairsDFS(int n) {
return dfs(n);
}
/* Driver Code */
int main() {
int n = 9;
int res = climbingStairsDFS(n);
printf("爬 %d 阶楼梯共有 %d 种方案\n", n, res);
return 0;
}
================================================
FILE: codes/c/chapter_dynamic_programming/climbing_stairs_dfs_mem.c
================================================
/**
* File: climbing_stairs_dfs_mem.c
* Created Time: 2023-09-19
* Author: huawuque404 (huawuque404@163.com)
*/
#include "../utils/common.h"
/* 记忆化搜索 */
int dfs(int i, int *mem) {
// 已知 dp[1] 和 dp[2] ,返回之
if (i == 1 || i == 2)
return i;
// 若存在记录 dp[i] ,则直接返回之
if (mem[i] != -1)
return mem[i];
// dp[i] = dp[i-1] + dp[i-2]
int count = dfs(i - 1, mem) + dfs(i - 2, mem);
// 记录 dp[i]
mem[i] = count;
return count;
}
/* 爬楼梯:记忆化搜索 */
int climbingStairsDFSMem(int n) {
// mem[i] 记录爬到第 i 阶的方案总数,-1 代表无记录
int *mem = (int *)malloc((n + 1) * sizeof(int));
for (int i = 0; i <= n; i++) {
mem[i] = -1;
}
int result = dfs(n, mem);
free(mem);
return result;
}
/* Driver Code */
int main() {
int n = 9;
int res = climbingStairsDFSMem(n);
printf("爬 %d 阶楼梯共有 %d 种方案\n", n, res);
return 0;
}
================================================
FILE: codes/c/chapter_dynamic_programming/climbing_stairs_dp.c
================================================
/**
* File: climbing_stairs_dp.c
* Created Time: 2023-09-19
* Author: huawuque404 (huawuque404@163.com)
*/
#include "../utils/common.h"
/* 爬楼梯:动态规划 */
int climbingStairsDP(int n) {
if (n == 1 || n == 2)
return n;
// 初始化 dp 表,用于存储子问题的解
int *dp = (int *)malloc((n + 1) * sizeof(int));
// 初始状态:预设最小子问题的解
dp[1] = 1;
dp[2] = 2;
// 状态转移:从较小子问题逐步求解较大子问题
for (int i = 3; i <= n; i++) {
dp[i] = dp[i - 1] + dp[i - 2];
}
int result = dp[n];
free(dp);
return result;
}
/* 爬楼梯:空间优化后的动态规划 */
int climbingStairsDPComp(int n) {
if (n == 1 || n == 2)
return n;
int a = 1, b = 2;
for (int i = 3; i <= n; i++) {
int tmp = b;
b = a + b;
a = tmp;
}
return b;
}
/* Driver Code */
int main() {
int n = 9;
int res = climbingStairsDP(n);
printf("爬 %d 阶楼梯共有 %d 种方案\n", n, res);
res = climbingStairsDPComp(n);
printf("爬 %d 阶楼梯共有 %d 种方案\n", n, res);
return 0;
}
================================================
FILE: codes/c/chapter_dynamic_programming/coin_change.c
================================================
/**
* File: coin_change.c
* Created Time: 2023-10-02
* Author: Zuoxun (845242523@qq.com)
*/
#include "../utils/common.h"
/* 求最小值 */
int myMin(int a, int b) {
return a < b ? a : b;
}
/* 零钱兑换:动态规划 */
int coinChangeDP(int coins[], int amt, int coinsSize) {
int n = coinsSize;
int MAX = amt + 1;
// 初始化 dp 表
int **dp = malloc((n + 1) * sizeof(int *));
for (int i = 0; i <= n; i++) {
dp[i] = calloc(amt + 1, sizeof(int));
}
// 状态转移:首行首列
for (int a = 1; a <= amt; a++) {
dp[0][a] = MAX;
}
// 状态转移:其余行和列
for (int i = 1; i <= n; i++) {
for (int a = 1; a <= amt; a++) {
if (coins[i - 1] > a) {
// 若超过目标金额,则不选硬币 i
dp[i][a] = dp[i - 1][a];
} else {
// 不选和选硬币 i 这两种方案的较小值
dp[i][a] = myMin(dp[i - 1][a], dp[i][a - coins[i - 1]] + 1);
}
}
}
int res = dp[n][amt] != MAX ? dp[n][amt] : -1;
// 释放内存
for (int i = 0; i <= n; i++) {
free(dp[i]);
}
free(dp);
return res;
}
/* 零钱兑换:空间优化后的动态规划 */
int coinChangeDPComp(int coins[], int amt, int coinsSize) {
int n = coinsSize;
int MAX = amt + 1;
// 初始化 dp 表
int *dp = malloc((amt + 1) * sizeof(int));
for (int j = 1; j <= amt; j++) {
dp[j] = MAX;
}
dp[0] = 0;
// 状态转移
for (int i = 1; i <= n; i++) {
for (int a = 1; a <= amt; a++) {
if (coins[i - 1] > a) {
// 若超过目标金额,则不选硬币 i
dp[a] = dp[a];
} else {
// 不选和选硬币 i 这两种方案的较小值
dp[a] = myMin(dp[a], dp[a - coins[i - 1]] + 1);
}
}
}
int res = dp[amt] != MAX ? dp[amt] : -1;
// 释放内存
free(dp);
return res;
}
/* Driver code */
int main() {
int coins[] = {1, 2, 5};
int coinsSize = sizeof(coins) / sizeof(coins[0]);
int amt = 4;
// 动态规划
int res = coinChangeDP(coins, amt, coinsSize);
printf("凑到目标金额所需的最少硬币数量为 %d\n", res);
// 空间优化后的动态规划
res = coinChangeDPComp(coins, amt, coinsSize);
printf("凑到目标金额所需的最少硬币数量为 %d\n", res);
return 0;
}
================================================
FILE: codes/c/chapter_dynamic_programming/coin_change_ii.c
================================================
/**
* File: coin_change_ii.c
* Created Time: 2023-10-02
* Author: Zuoxun (845242523@qq.com)
*/
#include "../utils/common.h"
/* 零钱兑换 II:动态规划 */
int coinChangeIIDP(int coins[], int amt, int coinsSize) {
int n = coinsSize;
// 初始化 dp 表
int **dp = malloc((n + 1) * sizeof(int *));
for (int i = 0; i <= n; i++) {
dp[i] = calloc(amt + 1, sizeof(int));
}
// 初始化首列
for (int i = 0; i <= n; i++) {
dp[i][0] = 1;
}
// 状态转移
for (int i = 1; i <= n; i++) {
for (int a = 1; a <= amt; a++) {
if (coins[i - 1] > a) {
// 若超过目标金额,则不选硬币 i
dp[i][a] = dp[i - 1][a];
} else {
// 不选和选硬币 i 这两种方案之和
dp[i][a] = dp[i - 1][a] + dp[i][a - coins[i - 1]];
}
}
}
int res = dp[n][amt];
// 释放内存
for (int i = 0; i <= n; i++) {
free(dp[i]);
}
free(dp);
return res;
}
/* 零钱兑换 II:空间优化后的动态规划 */
int coinChangeIIDPComp(int coins[], int amt, int coinsSize) {
int n = coinsSize;
// 初始化 dp 表
int *dp = calloc(amt + 1, sizeof(int));
dp[0] = 1;
// 状态转移
for (int i = 1; i <= n; i++) {
for (int a = 1; a <= amt; a++) {
if (coins[i - 1] > a) {
// 若超过目标金额,则不选硬币 i
dp[a] = dp[a];
} else {
// 不选和选硬币 i 这两种方案之和
dp[a] = dp[a] + dp[a - coins[i - 1]];
}
}
}
int res = dp[amt];
// 释放内存
free(dp);
return res;
}
/* Driver code */
int main() {
int coins[] = {1, 2, 5};
int coinsSize = sizeof(coins) / sizeof(coins[0]);
int amt = 5;
// 动态规划
int res = coinChangeIIDP(coins, amt, coinsSize);
printf("凑出目标金额的硬币组合数量为 %d\n", res);
// 空间优化后的动态规划
res = coinChangeIIDPComp(coins, amt, coinsSize);
printf("凑出目标金额的硬币组合数量为 %d\n", res);
return 0;
}
================================================
FILE: codes/c/chapter_dynamic_programming/edit_distance.c
================================================
/**
* File: edit_distance.c
* Created Time: 2023-10-02
* Author: Zuoxun (845242523@qq.com)
*/
#include "../utils/common.h"
/* 求最小值 */
int myMin(int a, int b) {
return a < b ? a : b;
}
/* 编辑距离:暴力搜索 */
int editDistanceDFS(char *s, char *t, int i, int j) {
// 若 s 和 t 都为空,则返回 0
if (i == 0 && j == 0)
return 0;
// 若 s 为空,则返回 t 长度
if (i == 0)
return j;
// 若 t 为空,则返回 s 长度
if (j == 0)
return i;
// 若两字符相等,则直接跳过此两字符
if (s[i - 1] == t[j - 1])
return editDistanceDFS(s, t, i - 1, j - 1);
// 最少编辑步数 = 插入、删除、替换这三种操作的最少编辑步数 + 1
int insert = editDistanceDFS(s, t, i, j - 1);
int del = editDistanceDFS(s, t, i - 1, j);
int replace = editDistanceDFS(s, t, i - 1, j - 1);
// 返回最少编辑步数
return myMin(myMin(insert, del), replace) + 1;
}
/* 编辑距离:记忆化搜索 */
int editDistanceDFSMem(char *s, char *t, int memCols, int **mem, int i, int j) {
// 若 s 和 t 都为空,则返回 0
if (i == 0 && j == 0)
return 0;
// 若 s 为空,则返回 t 长度
if (i == 0)
return j;
// 若 t 为空,则返回 s 长度
if (j == 0)
return i;
// 若已有记录,则直接返回之
if (mem[i][j] != -1)
return mem[i][j];
// 若两字符相等,则直接跳过此两字符
if (s[i - 1] == t[j - 1])
return editDistanceDFSMem(s, t, memCols, mem, i - 1, j - 1);
// 最少编辑步数 = 插入、删除、替换这三种操作的最少编辑步数 + 1
int insert = editDistanceDFSMem(s, t, memCols, mem, i, j - 1);
int del = editDistanceDFSMem(s, t, memCols, mem, i - 1, j);
int replace = editDistanceDFSMem(s, t, memCols, mem, i - 1, j - 1);
// 记录并返回最少编辑步数
mem[i][j] = myMin(myMin(insert, del), replace) + 1;
return mem[i][j];
}
/* 编辑距离:动态规划 */
int editDistanceDP(char *s, char *t, int n, int m) {
int **dp = malloc((n + 1) * sizeof(int *));
for (int i = 0; i <= n; i++) {
dp[i] = calloc(m + 1, sizeof(int));
}
// 状态转移:首行首列
for (int i = 1; i <= n; i++) {
dp[i][0] = i;
}
for (int j = 1; j <= m; j++) {
dp[0][j] = j;
}
// 状态转移:其余行和列
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (s[i - 1] == t[j - 1]) {
// 若两字符相等,则直接跳过此两字符
dp[i][j] = dp[i - 1][j - 1];
} else {
// 最少编辑步数 = 插入、删除、替换这三种操作的最少编辑步数 + 1
dp[i][j] = myMin(myMin(dp[i][j - 1], dp[i - 1][j]), dp[i - 1][j - 1]) + 1;
}
}
}
int res = dp[n][m];
// 释放内存
for (int i = 0; i <= n; i++) {
free(dp[i]);
}
return res;
}
/* 编辑距离:空间优化后的动态规划 */
int editDistanceDPComp(char *s, char *t, int n, int m) {
int *dp = calloc(m + 1, sizeof(int));
// 状态转移:首行
for (int j = 1; j <= m; j++) {
dp[j] = j;
}
// 状态转移:其余行
for (int i = 1; i <= n; i++) {
// 状态转移:首列
int leftup = dp[0]; // 暂存 dp[i-1, j-1]
dp[0] = i;
// 状态转移:其余列
for (int j = 1; j <= m; j++) {
int temp = dp[j];
if (s[i - 1] == t[j - 1]) {
// 若两字符相等,则直接跳过此两字符
dp[j] = leftup;
} else {
// 最少编辑步数 = 插入、删除、替换这三种操作的最少编辑步数 + 1
dp[j] = myMin(myMin(dp[j - 1], dp[j]), leftup) + 1;
}
leftup = temp; // 更新为下一轮的 dp[i-1, j-1]
}
}
int res = dp[m];
// 释放内存
free(dp);
return res;
}
/* Driver Code */
int main() {
char *s = "bag";
char *t = "pack";
int n = strlen(s), m = strlen(t);
// 暴力搜索
int res = editDistanceDFS(s, t, n, m);
printf("将 %s 更改为 %s 最少需要编辑 %d 步\n", s, t, res);
// 记忆化搜索
int **mem = malloc((n + 1) * sizeof(int *));
for (int i = 0; i <= n; i++) {
mem[i] = malloc((m + 1) * sizeof(int));
memset(mem[i], -1, (m + 1) * sizeof(int));
}
res = editDistanceDFSMem(s, t, m + 1, mem, n, m);
printf("将 %s 更改为 %s 最少需要编辑 %d 步\n", s, t, res);
// 释放内存
for (int i = 0; i <= n; i++) {
free(mem[i]);
}
free(mem);
// 动态规划
res = editDistanceDP(s, t, n, m);
printf("将 %s 更改为 %s 最少需要编辑 %d 步\n", s, t, res);
// 空间优化后的动态规划
res = editDistanceDPComp(s, t, n, m);
printf("将 %s 更改为 %s 最少需要编辑 %d 步\n", s, t, res);
return 0;
}
================================================
FILE: codes/c/chapter_dynamic_programming/knapsack.c
================================================
/**
* File: knapsack.c
* Created Time: 2023-10-02
* Author: Zuoxun (845242523@qq.com)
*/
#include "../utils/common.h"
/* 求最大值 */
int myMax(int a, int b) {
return a > b ? a : b;
}
/* 0-1 背包:暴力搜索 */
int knapsackDFS(int wgt[], int val[], int i, int c) {
// 若已选完所有物品或背包无剩余容量,则返回价值 0
if (i == 0 || c == 0) {
return 0;
}
// 若超过背包容量,则只能选择不放入背包
if (wgt[i - 1] > c) {
return knapsackDFS(wgt, val, i - 1, c);
}
// 计算不放入和放入物品 i 的最大价值
int no = knapsackDFS(wgt, val, i - 1, c);
int yes = knapsackDFS(wgt, val, i - 1, c - wgt[i - 1]) + val[i - 1];
// 返回两种方案中价值更大的那一个
return myMax(no, yes);
}
/* 0-1 背包:记忆化搜索 */
int knapsackDFSMem(int wgt[], int val[], int memCols, int **mem, int i, int c) {
// 若已选完所有物品或背包无剩余容量,则返回价值 0
if (i == 0 || c == 0) {
return 0;
}
// 若已有记录,则直接返回
if (mem[i][c] != -1) {
return mem[i][c];
}
// 若超过背包容量,则只能选择不放入背包
if (wgt[i - 1] > c) {
return knapsackDFSMem(wgt, val, memCols, mem, i - 1, c);
}
// 计算不放入和放入物品 i 的最大价值
int no = knapsackDFSMem(wgt, val, memCols, mem, i - 1, c);
int yes = knapsackDFSMem(wgt, val, memCols, mem, i - 1, c - wgt[i - 1]) + val[i - 1];
// 记录并返回两种方案中价值更大的那一个
mem[i][c] = myMax(no, yes);
return mem[i][c];
}
/* 0-1 背包:动态规划 */
int knapsackDP(int wgt[], int val[], int cap, int wgtSize) {
int n = wgtSize;
// 初始化 dp 表
int **dp = malloc((n + 1) * sizeof(int *));
for (int i = 0; i <= n; i++) {
dp[i] = calloc(cap + 1, sizeof(int));
}
// 状态转移
for (int i = 1; i <= n; i++) {
for (int c = 1; c <= cap; c++) {
if (wgt[i - 1] > c) {
// 若超过背包容量,则不选物品 i
dp[i][c] = dp[i - 1][c];
} else {
// 不选和选物品 i 这两种方案的较大值
dp[i][c] = myMax(dp[i - 1][c], dp[i - 1][c - wgt[i - 1]] + val[i - 1]);
}
}
}
int res = dp[n][cap];
// 释放内存
for (int i = 0; i <= n; i++) {
free(dp[i]);
}
return res;
}
/* 0-1 背包:空间优化后的动态规划 */
int knapsackDPComp(int wgt[], int val[], int cap, int wgtSize) {
int n = wgtSize;
// 初始化 dp 表
int *dp = calloc(cap + 1, sizeof(int));
// 状态转移
for (int i = 1; i <= n; i++) {
// 倒序遍历
for (int c = cap; c >= 1; c--) {
if (wgt[i - 1] <= c) {
// 不选和选物品 i 这两种方案的较大值
dp[c] = myMax(dp[c], dp[c - wgt[i - 1]] + val[i - 1]);
}
}
}
int res = dp[cap];
// 释放内存
free(dp);
return res;
}
/* Driver Code */
int main() {
int wgt[] = {10, 20, 30, 40, 50};
int val[] = {50, 120, 150, 210, 240};
int cap = 50;
int n = sizeof(wgt) / sizeof(wgt[0]);
int wgtSize = n;
// 暴力搜索
int res = knapsackDFS(wgt, val, n, cap);
printf("不超过背包容量的最大物品价值为 %d\n", res);
// 记忆化搜索
int **mem = malloc((n + 1) * sizeof(int *));
for (int i = 0; i <= n; i++) {
mem[i] = malloc((cap + 1) * sizeof(int));
memset(mem[i], -1, (cap + 1) * sizeof(int));
}
res = knapsackDFSMem(wgt, val, cap + 1, mem, n, cap);
printf("不超过背包容量的最大物品价值为 %d\n", res);
// 释放内存
for (int i = 0; i <= n; i++) {
free(mem[i]);
}
free(mem);
// 动态规划
res = knapsackDP(wgt, val, cap, wgtSize);
printf("不超过背包容量的最大物品价值为 %d\n", res);
// 空间优化后的动态规划
res = knapsackDPComp(wgt, val, cap, wgtSize);
printf("不超过背包容量的最大物品价值为 %d\n", res);
return 0;
}
================================================
FILE: codes/c/chapter_dynamic_programming/min_cost_climbing_stairs_dp.c
================================================
/**
* File: min_cost_climbing_stairs_dp.c
* Created Time: 2023-10-02
* Author: Zuoxun (845242523@qq.com)
*/
#include "../utils/common.h"
/* 求最小值 */
int myMin(int a, int b) {
return a < b ? a : b;
}
/* 爬楼梯最小代价:动态规划 */
int minCostClimbingStairsDP(int cost[], int costSize) {
int n = costSize - 1;
if (n == 1 || n == 2)
return cost[n];
// 初始化 dp 表,用于存储子问题的解
int *dp = calloc(n + 1, sizeof(int));
// 初始状态:预设最小子问题的解
dp[1] = cost[1];
dp[2] = cost[2];
// 状态转移:从较小子问题逐步求解较大子问题
for (int i = 3; i <= n; i++) {
dp[i] = myMin(dp[i - 1], dp[i - 2]) + cost[i];
}
int res = dp[n];
// 释放内存
free(dp);
return res;
}
/* 爬楼梯最小代价:空间优化后的动态规划 */
int minCostClimbingStairsDPComp(int cost[], int costSize) {
int n = costSize - 1;
if (n == 1 || n == 2)
return cost[n];
int a = cost[1], b = cost[2];
for (int i = 3; i <= n; i++) {
int tmp = b;
b = myMin(a, tmp) + cost[i];
a = tmp;
}
return b;
}
/* Driver Code */
int main() {
int cost[] = {0, 1, 10, 1, 1, 1, 10, 1, 1, 10, 1};
int costSize = sizeof(cost) / sizeof(cost[0]);
printf("输入楼梯的代价列表为:");
printArray(cost, costSize);
int res = minCostClimbingStairsDP(cost, costSize);
printf("爬完楼梯的最低代价为 %d\n", res);
res = minCostClimbingStairsDPComp(cost, costSize);
printf("爬完楼梯的最低代价为 %d\n", res);
return 0;
}
================================================
FILE: codes/c/chapter_dynamic_programming/min_path_sum.c
================================================
/**
* File: min_path_sum.c
* Created Time: 2023-10-02
* Author: Zuoxun (845242523@qq.com)
*/
#include "../utils/common.h"
// 假设矩阵最大行列数为 100
#define MAX_SIZE 100
/* 求最小值 */
int myMin(int a, int b) {
return a < b ? a : b;
}
/* 最小路径和:暴力搜索 */
int minPathSumDFS(int grid[MAX_SIZE][MAX_SIZE], int i, int j) {
// 若为左上角单元格,则终止搜索
if (i == 0 && j == 0) {
return grid[0][0];
}
// 若行列索引越界,则返回 +∞ 代价
if (i < 0 || j < 0) {
return INT_MAX;
}
// 计算从左上角到 (i-1, j) 和 (i, j-1) 的最小路径代价
int up = minPathSumDFS(grid, i - 1, j);
int left = minPathSumDFS(grid, i, j - 1);
// 返回从左上角到 (i, j) 的最小路径代价
return myMin(left, up) != INT_MAX ? myMin(left, up) + grid[i][j] : INT_MAX;
}
/* 最小路径和:记忆化搜索 */
int minPathSumDFSMem(int grid[MAX_SIZE][MAX_SIZE], int mem[MAX_SIZE][MAX_SIZE], int i, int j) {
// 若为左上角单元格,则终止搜索
if (i == 0 && j == 0) {
return grid[0][0];
}
// 若行列索引越界,则返回 +∞ 代价
if (i < 0 || j < 0) {
return INT_MAX;
}
// 若已有记录,则直接返回
if (mem[i][j] != -1) {
return mem[i][j];
}
// 左边和上边单元格的最小路径代价
int up = minPathSumDFSMem(grid, mem, i - 1, j);
int left = minPathSumDFSMem(grid, mem, i, j - 1);
// 记录并返回左上角到 (i, j) 的最小路径代价
mem[i][j] = myMin(left, up) != INT_MAX ? myMin(left, up) + grid[i][j] : INT_MAX;
return mem[i][j];
}
/* 最小路径和:动态规划 */
int minPathSumDP(int grid[MAX_SIZE][MAX_SIZE], int n, int m) {
// 初始化 dp 表
int **dp = malloc(n * sizeof(int *));
for (int i = 0; i < n; i++) {
dp[i] = calloc(m, sizeof(int));
}
dp[0][0] = grid[0][0];
// 状态转移:首行
for (int j = 1; j < m; j++) {
dp[0][j] = dp[0][j - 1] + grid[0][j];
}
// 状态转移:首列
for (int i = 1; i < n; i++) {
dp[i][0] = dp[i - 1][0] + grid[i][0];
}
// 状态转移:其余行和列
for (int i = 1; i < n; i++) {
for (int j = 1; j < m; j++) {
dp[i][j] = myMin(dp[i][j - 1], dp[i - 1][j]) + grid[i][j];
}
}
int res = dp[n - 1][m - 1];
// 释放内存
for (int i = 0; i < n; i++) {
free(dp[i]);
}
return res;
}
/* 最小路径和:空间优化后的动态规划 */
int minPathSumDPComp(int grid[MAX_SIZE][MAX_SIZE], int n, int m) {
// 初始化 dp 表
int *dp = calloc(m, sizeof(int));
// 状态转移:首行
dp[0] = grid[0][0];
for (int j = 1; j < m; j++) {
dp[j] = dp[j - 1] + grid[0][j];
}
// 状态转移:其余行
for (int i = 1; i < n; i++) {
// 状态转移:首列
dp[0] = dp[0] + grid[i][0];
// 状态转移:其余列
for (int j = 1; j < m; j++) {
dp[j] = myMin(dp[j - 1], dp[j]) + grid[i][j];
}
}
int res = dp[m - 1];
// 释放内存
free(dp);
return res;
}
/* Driver Code */
int main() {
int grid[MAX_SIZE][MAX_SIZE] = {{1, 3, 1, 5}, {2, 2, 4, 2}, {5, 3, 2, 1}, {4, 3, 5, 2}};
int n = 4, m = 4; // 矩阵容量为 MAX_SIZE * MAX_SIZE ,有效行列数为 n * m
// 暴力搜索
int res = minPathSumDFS(grid, n - 1, m - 1);
printf("从左上角到右下角的最小路径和为 %d\n", res);
// 记忆化搜索
int mem[MAX_SIZE][MAX_SIZE];
memset(mem, -1, sizeof(mem));
res = minPathSumDFSMem(grid, mem, n - 1, m - 1);
printf("从左上角到右下角的最小路径和为 %d\n", res);
// 动态规划
res = minPathSumDP(grid, n, m);
printf("从左上角到右下角的最小路径和为 %d\n", res);
// 空间优化后的动态规划
res = minPathSumDPComp(grid, n, m);
printf("从左上角到右下角的最小路径和为 %d\n", res);
return 0;
}
================================================
FILE: codes/c/chapter_dynamic_programming/unbounded_knapsack.c
================================================
/**
* File: unbounded_knapsack.c
* Created Time: 2023-10-02
* Author: Zuoxun (845242523@qq.com)
*/
#include "../utils/common.h"
/* 求最大值 */
int myMax(int a, int b) {
return a > b ? a : b;
}
/* 完全背包:动态规划 */
int unboundedKnapsackDP(int wgt[], int val[], int cap, int wgtSize) {
int n = wgtSize;
// 初始化 dp 表
int **dp = malloc((n + 1) * sizeof(int *));
for (int i = 0; i <= n; i++) {
dp[i] = calloc(cap + 1, sizeof(int));
}
// 状态转移
for (int i = 1; i <= n; i++) {
for (int c = 1; c <= cap; c++) {
if (wgt[i - 1] > c) {
// 若超过背包容量,则不选物品 i
dp[i][c] = dp[i - 1][c];
} else {
// 不选和选物品 i 这两种方案的较大值
dp[i][c] = myMax(dp[i - 1][c], dp[i][c - wgt[i - 1]] + val[i - 1]);
}
}
}
int res = dp[n][cap];
// 释放内存
for (int i = 0; i <= n; i++) {
free(dp[i]);
}
return res;
}
/* 完全背包:空间优化后的动态规划 */
int unboundedKnapsackDPComp(int wgt[], int val[], int cap, int wgtSize) {
int n = wgtSize;
// 初始化 dp 表
int *dp = calloc(cap + 1, sizeof(int));
// 状态转移
for (int i = 1; i <= n; i++) {
for (int c = 1; c <= cap; c++) {
if (wgt[i - 1] > c) {
// 若超过背包容量,则不选物品 i
dp[c] = dp[c];
} else {
// 不选和选物品 i 这两种方案的较大值
dp[c] = myMax(dp[c], dp[c - wgt[i - 1]] + val[i - 1]);
}
}
}
int res = dp[cap];
// 释放内存
free(dp);
return res;
}
/* Driver code */
int main() {
int wgt[] = {1, 2, 3};
int val[] = {5, 11, 15};
int wgtSize = sizeof(wgt) / sizeof(wgt[0]);
int cap = 4;
// 动态规划
int res = unboundedKnapsackDP(wgt, val, cap, wgtSize);
printf("不超过背包容量的最大物品价值为 %d\n", res);
// 空间优化后的动态规划
res = unboundedKnapsackDPComp(wgt, val, cap, wgtSize);
printf("不超过背包容量的最大物品价值为 %d\n", res);
return 0;
}
================================================
FILE: codes/c/chapter_graph/CMakeLists.txt
================================================
add_executable(graph_adjacency_matrix graph_adjacency_matrix.c)
add_executable(graph_adjacency_list_test graph_adjacency_list_test.c)
add_executable(graph_bfs graph_bfs.c)
add_executable(graph_dfs graph_dfs.c)
================================================
FILE: codes/c/chapter_graph/graph_adjacency_list.c
================================================
/**
* File: graph_adjacency_list.c
* Created Time: 2023-07-07
* Author: NI-SW (947743645@qq.com)
*/
#include "../utils/common.h"
// 假设节点最大数量为 100
#define MAX_SIZE 100
/* 节点结构体 */
typedef struct AdjListNode {
Vertex *vertex; // 顶点
struct AdjListNode *next; // 后继节点
} AdjListNode;
/* 基于邻接表实现的无向图类 */
typedef struct {
AdjListNode *heads[MAX_SIZE]; // 节点数组
int size; // 节点数量
} GraphAdjList;
/* 构造函数 */
GraphAdjList *newGraphAdjList() {
GraphAdjList *graph = (GraphAdjList *)malloc(sizeof(GraphAdjList));
if (!graph) {
return NULL;
}
graph->size = 0;
for (int i = 0; i < MAX_SIZE; i++) {
graph->heads[i] = NULL;
}
return graph;
}
/* 析构函数 */
void delGraphAdjList(GraphAdjList *graph) {
for (int i = 0; i < graph->size; i++) {
AdjListNode *cur = graph->heads[i];
while (cur != NULL) {
AdjListNode *next = cur->next;
if (cur != graph->heads[i]) {
free(cur);
}
cur = next;
}
free(graph->heads[i]->vertex);
free(graph->heads[i]);
}
free(graph);
}
/* 查找顶点对应的节点 */
AdjListNode *findNode(GraphAdjList *graph, Vertex *vet) {
for (int i = 0; i < graph->size; i++) {
if (graph->heads[i]->vertex == vet) {
return graph->heads[i];
}
}
return NULL;
}
/* 添加边辅助函数 */
void addEdgeHelper(AdjListNode *head, Vertex *vet) {
AdjListNode *node = (AdjListNode *)malloc(sizeof(AdjListNode));
node->vertex = vet;
// 头插法
node->next = head->next;
head->next = node;
}
/* 添加边 */
void addEdge(GraphAdjList *graph, Vertex *vet1, Vertex *vet2) {
AdjListNode *head1 = findNode(graph, vet1);
AdjListNode *head2 = findNode(graph, vet2);
assert(head1 != NULL && head2 != NULL && head1 != head2);
// 添加边 vet1 - vet2
addEdgeHelper(head1, vet2);
addEdgeHelper(head2, vet1);
}
/* 删除边辅助函数 */
void removeEdgeHelper(AdjListNode *head, Vertex *vet) {
AdjListNode *pre = head;
AdjListNode *cur = head->next;
// 在链表中搜索 vet 对应节点
while (cur != NULL && cur->vertex != vet) {
pre = cur;
cur = cur->next;
}
if (cur == NULL)
return;
// 将 vet 对应节点从链表中删除
pre->next = cur->next;
// 释放内存
free(cur);
}
/* 删除边 */
void removeEdge(GraphAdjList *graph, Vertex *vet1, Vertex *vet2) {
AdjListNode *head1 = findNode(graph, vet1);
AdjListNode *head2 = findNode(graph, vet2);
assert(head1 != NULL && head2 != NULL);
// 删除边 vet1 - vet2
removeEdgeHelper(head1, head2->vertex);
removeEdgeHelper(head2, head1->vertex);
}
/* 添加顶点 */
void addVertex(GraphAdjList *graph, Vertex *vet) {
assert(graph != NULL && graph->size < MAX_SIZE);
AdjListNode *head = (AdjListNode *)malloc(sizeof(AdjListNode));
head->vertex = vet;
head->next = NULL;
// 在邻接表中添加一个新链表
graph->heads[graph->size++] = head;
}
/* 删除顶点 */
void removeVertex(GraphAdjList *graph, Vertex *vet) {
AdjListNode *node = findNode(graph, vet);
assert(node != NULL);
// 在邻接表中删除顶点 vet 对应的链表
AdjListNode *cur = node, *pre = NULL;
while (cur) {
pre = cur;
cur = cur->next;
free(pre);
}
// 遍历其他顶点的链表,删除所有包含 vet 的边
for (int i = 0; i < graph->size; i++) {
cur = graph->heads[i];
pre = NULL;
while (cur) {
pre = cur;
cur = cur->next;
if (cur && cur->vertex == vet) {
pre->next = cur->next;
free(cur);
break;
}
}
}
// 将该顶点之后的顶点向前移动,以填补空缺
int i;
for (i = 0; i < graph->size; i++) {
if (graph->heads[i] == node)
break;
}
for (int j = i; j < graph->size - 1; j++) {
graph->heads[j] = graph->heads[j + 1];
}
graph->size--;
free(vet);
}
/* 打印邻接表 */
void printGraph(const GraphAdjList *graph) {
printf("邻接表 =\n");
for (int i = 0; i < graph->size; ++i) {
AdjListNode *node = graph->heads[i];
printf("%d: [", node->vertex->val);
node = node->next;
while (node) {
printf("%d, ", node->vertex->val);
node = node->next;
}
printf("]\n");
}
}
================================================
FILE: codes/c/chapter_graph/graph_adjacency_list_test.c
================================================
/**
* File: graph_adjacency_list_test.c
* Created Time: 2023-07-11
* Author: NI-SW (947743645@qq.com)
*/
#include "graph_adjacency_list.c"
/* Driver Code */
int main() {
int vals[] = {1, 3, 2, 5, 4};
int size = sizeof(vals) / sizeof(vals[0]);
Vertex **v = valsToVets(vals, size);
Vertex *edges[][2] = {{v[0], v[1]}, {v[0], v[3]}, {v[1], v[2]}, {v[2], v[3]}, {v[2], v[4]}, {v[3], v[4]}};
int egdeSize = sizeof(edges) / sizeof(edges[0]);
GraphAdjList *graph = newGraphAdjList();
// 添加所有顶点和边
for (int i = 0; i < size; i++) {
addVertex(graph, v[i]);
}
for (int i = 0; i < egdeSize; i++) {
addEdge(graph, edges[i][0], edges[i][1]);
}
printf("\n初始化后,图为\n");
printGraph(graph);
/* 添加边 */
// 顶点 1, 2 即 v[0], v[2]
addEdge(graph, v[0], v[2]);
printf("\n添加边 1-2 后,图为\n");
printGraph(graph);
/* 删除边 */
// 顶点 1, 3 即 v[0], v[1]
removeEdge(graph, v[0], v[1]);
printf("\n删除边 1-3 后,图为\n");
printGraph(graph);
/* 添加顶点 */
Vertex *v5 = newVertex(6);
addVertex(graph, v5);
printf("\n添加顶点 6 后,图为\n");
printGraph(graph);
/* 删除顶点 */
// 顶点 3 即 v[1]
removeVertex(graph, v[1]);
printf("\n删除顶点 3 后,图为:\n");
printGraph(graph);
// 释放内存
delGraphAdjList(graph);
free(v);
return 0;
}
================================================
FILE: codes/c/chapter_graph/graph_adjacency_matrix.c
================================================
/**
* File: graph_adjacency_matrix.c
* Created Time: 2023-07-06
* Author: NI-SW (947743645@qq.com)
*/
#include "../utils/common.h"
// 假设顶点数量最大为 100
#define MAX_SIZE 100
/* 基于邻接矩阵实现的无向图结构体 */
typedef struct {
int vertices[MAX_SIZE];
int adjMat[MAX_SIZE][MAX_SIZE];
int size;
} GraphAdjMat;
/* 构造函数 */
GraphAdjMat *newGraphAdjMat() {
GraphAdjMat *graph = (GraphAdjMat *)malloc(sizeof(GraphAdjMat));
graph->size = 0;
for (int i = 0; i < MAX_SIZE; i++) {
for (int j = 0; j < MAX_SIZE; j++) {
graph->adjMat[i][j] = 0;
}
}
return graph;
}
/* 析构函数 */
void delGraphAdjMat(GraphAdjMat *graph) {
free(graph);
}
/* 添加顶点 */
void addVertex(GraphAdjMat *graph, int val) {
if (graph->size == MAX_SIZE) {
fprintf(stderr, "图的顶点数量已达最大值\n");
return;
}
// 添加第 n 个顶点,并将第 n 行和列置零
int n = graph->size;
graph->vertices[n] = val;
for (int i = 0; i <= n; i++) {
graph->adjMat[n][i] = graph->adjMat[i][n] = 0;
}
graph->size++;
}
/* 删除顶点 */
void removeVertex(GraphAdjMat *graph, int index) {
if (index < 0 || index >= graph->size) {
fprintf(stderr, "顶点索引越界\n");
return;
}
// 在顶点列表中移除索引 index 的顶点
for (int i = index; i < graph->size - 1; i++) {
graph->vertices[i] = graph->vertices[i + 1];
}
// 在邻接矩阵中删除索引 index 的行
for (int i = index; i < graph->size - 1; i++) {
for (int j = 0; j < graph->size; j++) {
graph->adjMat[i][j] = graph->adjMat[i + 1][j];
}
}
// 在邻接矩阵中删除索引 index 的列
for (int i = 0; i < graph->size; i++) {
for (int j = index; j < graph->size - 1; j++) {
graph->adjMat[i][j] = graph->adjMat[i][j + 1];
}
}
graph->size--;
}
/* 添加边 */
// 参数 i, j 对应 vertices 元素索引
void addEdge(GraphAdjMat *graph, int i, int j) {
if (i < 0 || j < 0 || i >= graph->size || j >= graph->size || i == j) {
fprintf(stderr, "边索引越界或相等\n");
return;
}
graph->adjMat[i][j] = 1;
graph->adjMat[j][i] = 1;
}
/* 删除边 */
// 参数 i, j 对应 vertices 元素索引
void removeEdge(GraphAdjMat *graph, int i, int j) {
if (i < 0 || j < 0 || i >= graph->size || j >= graph->size || i == j) {
fprintf(stderr, "边索引越界或相等\n");
return;
}
graph->adjMat[i][j] = 0;
graph->adjMat[j][i] = 0;
}
/* 打印邻接矩阵 */
void printGraphAdjMat(GraphAdjMat *graph) {
printf("顶点列表 = ");
printArray(graph->vertices, graph->size);
printf("邻接矩阵 =\n");
for (int i = 0; i < graph->size; i++) {
printArray(graph->adjMat[i], graph->size);
}
}
/* Driver Code */
int main() {
// 初始化无向图
GraphAdjMat *graph = newGraphAdjMat();
int vertices[] = {1, 3, 2, 5, 4};
for (int i = 0; i < 5; i++) {
addVertex(graph, vertices[i]);
}
int edges[][2] = {{0, 1}, {0, 3}, {1, 2}, {2, 3}, {2, 4}, {3, 4}};
for (int i = 0; i < 6; i++) {
addEdge(graph, edges[i][0], edges[i][1]);
}
printf("\n初始化后,图为\n");
printGraphAdjMat(graph);
/* 添加边 */
// 顶点 1, 2 的索引分别为 0, 2
addEdge(graph, 0, 2);
printf("\n添加边 1-2 后,图为\n");
printGraphAdjMat(graph);
/* 删除边 */
// 顶点 1, 3 的索引分别为 0, 1
removeEdge(graph, 0, 1);
printf("\n删除边 1-3 后,图为\n");
printGraphAdjMat(graph);
/* 添加顶点 */
addVertex(graph, 6);
printf("\n添加顶点 6 后,图为\n");
printGraphAdjMat(graph);
/* 删除顶点 */
// 顶点 3 的索引为 1
removeVertex(graph, 1);
printf("\n删除顶点 3 后,图为\n");
printGraphAdjMat(graph);
// 释放内存
delGraphAdjMat(graph);
return 0;
}
================================================
FILE: codes/c/chapter_graph/graph_bfs.c
================================================
/**
* File: graph_bfs.c
* Created Time: 2023-07-11
* Author: NI-SW (947743645@qq.com)
*/
#include "graph_adjacency_list.c"
// 假设节点最大数量为 100
#define MAX_SIZE 100
/* 节点队列结构体 */
typedef struct {
Vertex *vertices[MAX_SIZE];
int front, rear, size;
} Queue;
/* 构造函数 */
Queue *newQueue() {
Queue *q = (Queue *)malloc(sizeof(Queue));
q->front = q->rear = q->size = 0;
return q;
}
/* 判断队列是否为空 */
int isEmpty(Queue *q) {
return q->size == 0;
}
/* 入队操作 */
void enqueue(Queue *q, Vertex *vet) {
q->vertices[q->rear] = vet;
q->rear = (q->rear + 1) % MAX_SIZE;
q->size++;
}
/* 出队操作 */
Vertex *dequeue(Queue *q) {
Vertex *vet = q->vertices[q->front];
q->front = (q->front + 1) % MAX_SIZE;
q->size--;
return vet;
}
/* 检查顶点是否已被访问 */
int isVisited(Vertex **visited, int size, Vertex *vet) {
// 遍历查找节点,使用 O(n) 时间
for (int i = 0; i < size; i++) {
if (visited[i] == vet)
return 1;
}
return 0;
}
/* 广度优先遍历 */
// 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点
void graphBFS(GraphAdjList *graph, Vertex *startVet, Vertex **res, int *resSize, Vertex **visited, int *visitedSize) {
// 队列用于实现 BFS
Queue *queue = newQueue();
enqueue(queue, startVet);
visited[(*visitedSize)++] = startVet;
// 以顶点 vet 为起点,循环直至访问完所有顶点
while (!isEmpty(queue)) {
Vertex *vet = dequeue(queue); // 队首顶点出队
res[(*resSize)++] = vet; // 记录访问顶点
// 遍历该顶点的所有邻接顶点
AdjListNode *node = findNode(graph, vet);
while (node != NULL) {
// 跳过已被访问的顶点
if (!isVisited(visited, *visitedSize, node->vertex)) {
enqueue(queue, node->vertex); // 只入队未访问的顶点
visited[(*visitedSize)++] = node->vertex; // 标记该顶点已被访问
}
node = node->next;
}
}
// 释放内存
free(queue);
}
/* Driver Code */
int main() {
// 初始化无向图
int vals[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int size = sizeof(vals) / sizeof(vals[0]);
Vertex **v = valsToVets(vals, size);
Vertex *edges[][2] = {{v[0], v[1]}, {v[0], v[3]}, {v[1], v[2]}, {v[1], v[4]}, {v[2], v[5]}, {v[3], v[4]},
{v[3], v[6]}, {v[4], v[5]}, {v[4], v[7]}, {v[5], v[8]}, {v[6], v[7]}, {v[7], v[8]}};
int egdeSize = sizeof(edges) / sizeof(edges[0]);
GraphAdjList *graph = newGraphAdjList();
// 添加所有顶点和边
for (int i = 0; i < size; i++) {
addVertex(graph, v[i]);
}
for (int i = 0; i < egdeSize; i++) {
addEdge(graph, edges[i][0], edges[i][1]);
}
printf("\n初始化后,图为\n");
printGraph(graph);
// 广度优先遍历
// 顶点遍历序列
Vertex *res[MAX_SIZE];
int resSize = 0;
// 用于记录已被访问过的顶点
Vertex *visited[MAX_SIZE];
int visitedSize = 0;
graphBFS(graph, v[0], res, &resSize, visited, &visitedSize);
printf("\n广度优先遍历(BFS)顶点序列为\n");
printArray(vetsToVals(res, resSize), resSize);
// 释放内存
delGraphAdjList(graph);
free(v);
return 0;
}
================================================
FILE: codes/c/chapter_graph/graph_dfs.c
================================================
/**
* File: graph_dfs.c
* Created Time: 2023-07-13
* Author: NI-SW (947743645@qq.com)
*/
#include "graph_adjacency_list.c"
// 假设节点最大数量为 100
#define MAX_SIZE 100
/* 检查顶点是否已被访问 */
int isVisited(Vertex **res, int size, Vertex *vet) {
// 遍历查找节点,使用 O(n) 时间
for (int i = 0; i < size; i++) {
if (res[i] == vet) {
return 1;
}
}
return 0;
}
/* 深度优先遍历辅助函数 */
void dfs(GraphAdjList *graph, Vertex **res, int *resSize, Vertex *vet) {
// 记录访问顶点
res[(*resSize)++] = vet;
// 遍历该顶点的所有邻接顶点
AdjListNode *node = findNode(graph, vet);
while (node != NULL) {
// 跳过已被访问的顶点
if (!isVisited(res, *resSize, node->vertex)) {
// 递归访问邻接顶点
dfs(graph, res, resSize, node->vertex);
}
node = node->next;
}
}
/* 深度优先遍历 */
// 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点
void graphDFS(GraphAdjList *graph, Vertex *startVet, Vertex **res, int *resSize) {
dfs(graph, res, resSize, startVet);
}
/* Driver Code */
int main() {
// 初始化无向图
int vals[] = {0, 1, 2, 3, 4, 5, 6};
int size = sizeof(vals) / sizeof(vals[0]);
Vertex **v = valsToVets(vals, size);
Vertex *edges[][2] = {{v[0], v[1]}, {v[0], v[3]}, {v[1], v[2]}, {v[2], v[5]}, {v[4], v[5]}, {v[5], v[6]}};
int egdeSize = sizeof(edges) / sizeof(edges[0]);
GraphAdjList *graph = newGraphAdjList();
// 添加所有顶点和边
for (int i = 0; i < size; i++) {
addVertex(graph, v[i]);
}
for (int i = 0; i < egdeSize; i++) {
addEdge(graph, edges[i][0], edges[i][1]);
}
printf("\n初始化后,图为\n");
printGraph(graph);
// 深度优先遍历
Vertex *res[MAX_SIZE];
int resSize = 0;
graphDFS(graph, v[0], res, &resSize);
printf("\n深度优先遍历(DFS)顶点序列为\n");
printArray(vetsToVals(res, resSize), resSize);
// 释放内存
delGraphAdjList(graph);
free(v);
return 0;
}
================================================
FILE: codes/c/chapter_greedy/CMakeLists.txt
================================================
add_executable(coin_change_greedy coin_change_greedy.c)
add_executable(fractional_knapsack fractional_knapsack.c)
add_executable(max_capacity max_capacity.c)
add_executable(max_product_cutting max_product_cutting.c)
if (NOT CMAKE_C_COMPILER_ID STREQUAL "MSVC")
target_link_libraries(max_product_cutting m)
endif()
================================================
FILE: codes/c/chapter_greedy/coin_change_greedy.c
================================================
/**
* File: coin_change_greedy.c
* Created Time: 2023-09-07
* Author: lwbaptx (lwbaptx@gmail.com)
*/
#include "../utils/common.h"
/* 零钱兑换:贪心 */
int coinChangeGreedy(int *coins, int size, int amt) {
// 假设 coins 列表有序
int i = size - 1;
int count = 0;
// 循环进行贪心选择,直到无剩余金额
while (amt > 0) {
// 找到小于且最接近剩余金额的硬币
while (i > 0 && coins[i] > amt) {
i--;
}
// 选择 coins[i]
amt -= coins[i];
count++;
}
// 若未找到可行方案,则返回 -1
return amt == 0 ? count : -1;
}
/* Driver Code */
int main() {
// 贪心:能够保证找到全局最优解
int coins1[6] = {1, 5, 10, 20, 50, 100};
int amt = 186;
int res = coinChangeGreedy(coins1, 6, amt);
printf("\ncoins = ");
printArray(coins1, 6);
printf("amt = %d\n", amt);
printf("凑到 %d 所需的最少硬币数量为 %d\n", amt, res);
// 贪心:无法保证找到全局最优解
int coins2[3] = {1, 20, 50};
amt = 60;
res = coinChangeGreedy(coins2, 3, amt);
printf("\ncoins = ");
printArray(coins2, 3);
printf("amt = %d\n", amt);
printf("凑到 %d 所需的最少硬币数量为 %d\n", amt, res);
printf("实际上需要的最少数量为 3 ,即 20 + 20 + 20\n");
// 贪心:无法保证找到全局最优解
int coins3[3] = {1, 49, 50};
amt = 98;
res = coinChangeGreedy(coins3, 3, amt);
printf("\ncoins = ");
printArray(coins3, 3);
printf("amt = %d\n", amt);
printf("凑到 %d 所需的最少硬币数量为 %d\n", amt, res);
printf("实际上需要的最少数量为 2 ,即 49 + 49\n");
return 0;
}
================================================
FILE: codes/c/chapter_greedy/fractional_knapsack.c
================================================
/**
* File: fractional_knapsack.c
* Created Time: 2023-09-14
* Author: xianii (xianyi.xia@outlook.com)
*/
#include "../utils/common.h"
/* 物品 */
typedef struct {
int w; // 物品重量
int v; // 物品价值
} Item;
/* 按照价值密度排序 */
int sortByValueDensity(const void *a, const void *b) {
Item *t1 = (Item *)a;
Item *t2 = (Item *)b;
return (float)(t1->v) / t1->w < (float)(t2->v) / t2->w;
}
/* 分数背包:贪心 */
float fractionalKnapsack(int wgt[], int val[], int itemCount, int cap) {
// 创建物品列表,包含两个属性:重量、价值
Item *items = malloc(sizeof(Item) * itemCount);
for (int i = 0; i < itemCount; i++) {
items[i] = (Item){.w = wgt[i], .v = val[i]};
}
// 按照单位价值 item.v / item.w 从高到低进行排序
qsort(items, (size_t)itemCount, sizeof(Item), sortByValueDensity);
// 循环贪心选择
float res = 0.0;
for (int i = 0; i < itemCount; i++) {
if (items[i].w <= cap) {
// 若剩余容量充足,则将当前物品整个装进背包
res += items[i].v;
cap -= items[i].w;
} else {
// 若剩余容量不足,则将当前物品的一部分装进背包
res += (float)cap / items[i].w * items[i].v;
cap = 0;
break;
}
}
free(items);
return res;
}
/* Driver Code */
int main(void) {
int wgt[] = {10, 20, 30, 40, 50};
int val[] = {50, 120, 150, 210, 240};
int capacity = 50;
// 贪心算法
float res = fractionalKnapsack(wgt, val, sizeof(wgt) / sizeof(int), capacity);
printf("不超过背包容量的最大物品价值为 %0.2f\n", res);
return 0;
}
================================================
FILE: codes/c/chapter_greedy/max_capacity.c
================================================
/**
* File: max_capacity.c
* Created Time: 2023-09-15
* Author: xianii (xianyi.xia@outlook.com)
*/
#include "../utils/common.h"
/* 求最小值 */
int myMin(int a, int b) {
return a < b ? a : b;
}
/* 求最大值 */
int myMax(int a, int b) {
return a > b ? a : b;
}
/* 最大容量:贪心 */
int maxCapacity(int ht[], int htLength) {
// 初始化 i, j,使其分列数组两端
int i = 0;
int j = htLength - 1;
// 初始最大容量为 0
int res = 0;
// 循环贪心选择,直至两板相遇
while (i < j) {
// 更新最大容量
int capacity = myMin(ht[i], ht[j]) * (j - i);
res = myMax(res, capacity);
// 向内移动短板
if (ht[i] < ht[j]) {
i++;
} else {
j--;
}
}
return res;
}
/* Driver Code */
int main(void) {
int ht[] = {3, 8, 5, 2, 7, 7, 3, 4};
// 贪心算法
int res = maxCapacity(ht, sizeof(ht) / sizeof(int));
printf("最大容量为 %d\n", res);
return 0;
}
================================================
FILE: codes/c/chapter_greedy/max_product_cutting.c
================================================
/**
* File: max_product_cutting.c
* Created Time: 2023-09-15
* Author: xianii (xianyi.xia@outlook.com)
*/
#include "../utils/common.h"
/* 最大切分乘积:贪心 */
int maxProductCutting(int n) {
// 当 n <= 3 时,必须切分出一个 1
if (n <= 3) {
return 1 * (n - 1);
}
// 贪心地切分出 3 ,a 为 3 的个数,b 为余数
int a = n / 3;
int b = n % 3;
if (b == 1) {
// 当余数为 1 时,将一对 1 * 3 转化为 2 * 2
return pow(3, a - 1) * 2 * 2;
}
if (b == 2) {
// 当余数为 2 时,不做处理
return pow(3, a) * 2;
}
// 当余数为 0 时,不做处理
return pow(3, a);
}
/* Driver Code */
int main(void) {
int n = 58;
// 贪心算法
int res = maxProductCutting(n);
printf("最大切分乘积为 %d\n", res);
return 0;
}
================================================
FILE: codes/c/chapter_hashing/CMakeLists.txt
================================================
add_executable(array_hash_map array_hash_map.c)
add_executable(hash_map_chaining hash_map_chaining.c)
add_executable(hash_map_open_addressing hash_map_open_addressing.c)
add_executable(simple_hash simple_hash.c)
================================================
FILE: codes/c/chapter_hashing/array_hash_map.c
================================================
/**
* File: array_hash_map.c
* Created Time: 2023-03-18
* Author: Guanngxu (446678850@qq.com)
*/
#include "../utils/common.h"
/* 哈希表默认大小 */
#define MAX_SIZE 100
/* 键值对 int->string */
typedef struct {
int key;
char *val;
} Pair;
/* 键值对的集合 */
typedef struct {
void *set;
int len;
} MapSet;
/* 基于数组实现的哈希表 */
typedef struct {
Pair *buckets[MAX_SIZE];
} ArrayHashMap;
/* 构造函数 */
ArrayHashMap *newArrayHashMap() {
ArrayHashMap *hmap = malloc(sizeof(ArrayHashMap));
for (int i=0; i < MAX_SIZE; i++) {
hmap->buckets[i] = NULL;
}
return hmap;
}
/* 析构函数 */
void delArrayHashMap(ArrayHashMap *hmap) {
for (int i = 0; i < MAX_SIZE; i++) {
if (hmap->buckets[i] != NULL) {
free(hmap->buckets[i]->val);
free(hmap->buckets[i]);
}
}
free(hmap);
}
/* 哈希函数 */
int hashFunc(int key) {
int index = key % MAX_SIZE;
return index;
}
/* 查询操作 */
const char *get(const ArrayHashMap *hmap, const int key) {
int index = hashFunc(key);
const Pair *Pair = hmap->buckets[index];
if (Pair == NULL)
return NULL;
return Pair->val;
}
/* 添加操作 */
void put(ArrayHashMap *hmap, const int key, const char *val) {
Pair *Pair = malloc(sizeof(Pair));
Pair->key = key;
Pair->val = malloc(strlen(val) + 1);
strcpy(Pair->val, val);
int index = hashFunc(key);
hmap->buckets[index] = Pair;
}
/* 删除操作 */
void removeItem(ArrayHashMap *hmap, const int key) {
int index = hashFunc(key);
free(hmap->buckets[index]->val);
free(hmap->buckets[index]);
hmap->buckets[index] = NULL;
}
/* 获取所有键值对 */
void pairSet(ArrayHashMap *hmap, MapSet *set) {
Pair *entries;
int i = 0, index = 0;
int total = 0;
/* 统计有效键值对数量 */
for (i = 0; i < MAX_SIZE; i++) {
if (hmap->buckets[i] != NULL) {
total++;
}
}
entries = malloc(sizeof(Pair) * total);
for (i = 0; i < MAX_SIZE; i++) {
if (hmap->buckets[i] != NULL) {
entries[index].key = hmap->buckets[i]->key;
entries[index].val = malloc(strlen(hmap->buckets[i]->val) + 1);
strcpy(entries[index].val, hmap->buckets[i]->val);
index++;
}
}
set->set = entries;
set->len = total;
}
/* 获取所有键 */
void keySet(ArrayHashMap *hmap, MapSet *set) {
int *keys;
int i = 0, index = 0;
int total = 0;
/* 统计有效键值对数量 */
for (i = 0; i < MAX_SIZE; i++) {
if (hmap->buckets[i] != NULL) {
total++;
}
}
keys = malloc(total * sizeof(int));
for (i = 0; i < MAX_SIZE; i++) {
if (hmap->buckets[i] != NULL) {
keys[index] = hmap->buckets[i]->key;
index++;
}
}
set->set = keys;
set->len = total;
}
/* 获取所有值 */
void valueSet(ArrayHashMap *hmap, MapSet *set) {
char **vals;
int i = 0, index = 0;
int total = 0;
/* 统计有效键值对数量 */
for (i = 0; i < MAX_SIZE; i++) {
if (hmap->buckets[i] != NULL) {
total++;
}
}
vals = malloc(total * sizeof(char *));
for (i = 0; i < MAX_SIZE; i++) {
if (hmap->buckets[i] != NULL) {
vals[index] = hmap->buckets[i]->val;
index++;
}
}
set->set = vals;
set->len = total;
}
/* 打印哈希表 */
void print(ArrayHashMap *hmap) {
int i;
MapSet set;
pairSet(hmap, &set);
Pair *entries = (Pair *)set.set;
for (i = 0; i < set.len; i++) {
printf("%d -> %s\n", entries[i].key, entries[i].val);
}
free(set.set);
}
/* Driver Code */
int main() {
/* 初始化哈希表 */
ArrayHashMap *hmap = newArrayHashMap();
/* 添加操作 */
// 在哈希表中添加键值对 (key, value)
put(hmap, 12836, "小哈");
put(hmap, 15937, "小啰");
put(hmap, 16750, "小算");
put(hmap, 13276, "小法");
put(hmap, 10583, "小鸭");
printf("\n添加完成后,哈希表为\nKey -> Value\n");
print(hmap);
/* 查询操作 */
// 向哈希表中输入键 key ,得到值 value
const char *name = get(hmap, 15937);
printf("\n输入学号 15937 ,查询到姓名 %s\n", name);
/* 删除操作 */
// 在哈希表中删除键值对 (key, value)
removeItem(hmap, 10583);
printf("\n删除 10583 后,哈希表为\nKey -> Value\n");
print(hmap);
/* 遍历哈希表 */
int i;
printf("\n遍历键值对 Key->Value\n");
print(hmap);
MapSet set;
keySet(hmap, &set);
int *keys = (int *)set.set;
printf("\n单独遍历键 Key\n");
for (i = 0; i < set.len; i++) {
printf("%d\n", keys[i]);
}
free(set.set);
valueSet(hmap, &set);
char **vals = (char **)set.set;
printf("\n单独遍历键 Value\n");
for (i = 0; i < set.len; i++) {
printf("%s\n", vals[i]);
}
free(set.set);
delArrayHashMap(hmap);
return 0;
}
================================================
FILE: codes/c/chapter_hashing/hash_map_chaining.c
================================================
/**
* File: hash_map_chaining.c
* Created Time: 2023-10-13
* Author: SenMing (1206575349@qq.com), krahets (krahets@163.com)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// 假设 val 最大长度为 100
#define MAX_SIZE 100
/* 键值对 */
typedef struct {
int key;
char val[MAX_SIZE];
} Pair;
/* 链表节点 */
typedef struct Node {
Pair *pair;
struct Node *next;
} Node;
/* 链式地址哈希表 */
typedef struct {
int size; // 键值对数量
int capacity; // 哈希表容量
double loadThres; // 触发扩容的负载因子阈值
int extendRatio; // 扩容倍数
Node **buckets; // 桶数组
} HashMapChaining;
/* 构造函数 */
HashMapChaining *newHashMapChaining() {
HashMapChaining *hashMap = (HashMapChaining *)malloc(sizeof(HashMapChaining));
hashMap->size = 0;
hashMap->capacity = 4;
hashMap->loadThres = 2.0 / 3.0;
hashMap->extendRatio = 2;
hashMap->buckets = (Node **)malloc(hashMap->capacity * sizeof(Node *));
for (int i = 0; i < hashMap->capacity; i++) {
hashMap->buckets[i] = NULL;
}
return hashMap;
}
/* 析构函数 */
void delHashMapChaining(HashMapChaining *hashMap) {
for (int i = 0; i < hashMap->capacity; i++) {
Node *cur = hashMap->buckets[i];
while (cur) {
Node *tmp = cur;
cur = cur->next;
free(tmp->pair);
free(tmp);
}
}
free(hashMap->buckets);
free(hashMap);
}
/* 哈希函数 */
int hashFunc(HashMapChaining *hashMap, int key) {
return key % hashMap->capacity;
}
/* 负载因子 */
double loadFactor(HashMapChaining *hashMap) {
return (double)hashMap->size / (double)hashMap->capacity;
}
/* 查询操作 */
char *get(HashMapChaining *hashMap, int key) {
int index = hashFunc(hashMap, key);
// 遍历桶,若找到 key ,则返回对应 val
Node *cur = hashMap->buckets[index];
while (cur) {
if (cur->pair->key == key) {
return cur->pair->val;
}
cur = cur->next;
}
return ""; // 若未找到 key ,则返回空字符串
}
/* 添加操作 */
void put(HashMapChaining *hashMap, int key, const char *val);
/* 扩容哈希表 */
void extend(HashMapChaining *hashMap) {
// 暂存原哈希表
int oldCapacity = hashMap->capacity;
Node **oldBuckets = hashMap->buckets;
// 初始化扩容后的新哈希表
hashMap->capacity *= hashMap->extendRatio;
hashMap->buckets = (Node **)malloc(hashMap->capacity * sizeof(Node *));
for (int i = 0; i < hashMap->capacity; i++) {
hashMap->buckets[i] = NULL;
}
hashMap->size = 0;
// 将键值对从原哈希表搬运至新哈希表
for (int i = 0; i < oldCapacity; i++) {
Node *cur = oldBuckets[i];
while (cur) {
put(hashMap, cur->pair->key, cur->pair->val);
Node *temp = cur;
cur = cur->next;
// 释放内存
free(temp->pair);
free(temp);
}
}
free(oldBuckets);
}
/* 添加操作 */
void put(HashMapChaining *hashMap, int key, const char *val) {
// 当负载因子超过阈值时,执行扩容
if (loadFactor(hashMap) > hashMap->loadThres) {
extend(hashMap);
}
int index = hashFunc(hashMap, key);
// 遍历桶,若遇到指定 key ,则更新对应 val 并返回
Node *cur = hashMap->buckets[index];
while (cur) {
if (cur->pair->key == key) {
strcpy(cur->pair->val, val); // 若遇到指定 key ,则更新对应 val 并返回
return;
}
cur = cur->next;
}
// 若无该 key ,则将键值对添加至链表头部
Pair *newPair = (Pair *)malloc(sizeof(Pair));
newPair->key = key;
strcpy(newPair->val, val);
Node *newNode = (Node *)malloc(sizeof(Node));
newNode->pair = newPair;
newNode->next = hashMap->buckets[index];
hashMap->buckets[index] = newNode;
hashMap->size++;
}
/* 删除操作 */
void removeItem(HashMapChaining *hashMap, int key) {
int index = hashFunc(hashMap, key);
Node *cur = hashMap->buckets[index];
Node *pre = NULL;
while (cur) {
if (cur->pair->key == key) {
// 从中删除键值对
if (pre) {
pre->next = cur->next;
} else {
hashMap->buckets[index] = cur->next;
}
// 释放内存
free(cur->pair);
free(cur);
hashMap->size--;
return;
}
pre = cur;
cur = cur->next;
}
}
/* 打印哈希表 */
void print(HashMapChaining *hashMap) {
for (int i = 0; i < hashMap->capacity; i++) {
Node *cur = hashMap->buckets[i];
printf("[");
while (cur) {
printf("%d -> %s, ", cur->pair->key, cur->pair->val);
cur = cur->next;
}
printf("]\n");
}
}
/* Driver Code */
int main() {
/* 初始化哈希表 */
HashMapChaining *hashMap = newHashMapChaining();
/* 添加操作 */
// 在哈希表中添加键值对 (key, value)
put(hashMap, 12836, "小哈");
put(hashMap, 15937, "小啰");
put(hashMap, 16750, "小算");
put(hashMap, 13276, "小法");
put(hashMap, 10583, "小鸭");
printf("\n添加完成后,哈希表为\nKey -> Value\n");
print(hashMap);
/* 查询操作 */
// 向哈希表中输入键 key ,得到值 value
char *name = get(hashMap, 13276);
printf("\n输入学号 13276 ,查询到姓名 %s\n", name);
/* 删除操作 */
// 在哈希表中删除键值对 (key, value)
removeItem(hashMap, 12836);
printf("\n删除学号 12836 后,哈希表为\nKey -> Value\n");
print(hashMap);
/* 释放哈希表空间 */
delHashMapChaining(hashMap);
return 0;
}
================================================
FILE: codes/c/chapter_hashing/hash_map_open_addressing.c
================================================
/**
* File: hash_map_open_addressing.c
* Created Time: 2023-10-6
* Author: lclc6 (w1929522410@163.com)
*/
#include "../utils/common.h"
/* 开放寻址哈希表 */
typedef struct {
int key;
char *val;
} Pair;
/* 开放寻址哈希表 */
typedef struct {
int size; // 键值对数量
int capacity; // 哈希表容量
double loadThres; // 触发扩容的负载因子阈值
int extendRatio; // 扩容倍数
Pair **buckets; // 桶数组
Pair *TOMBSTONE; // 删除标记
} HashMapOpenAddressing;
// 函数声明
void extend(HashMapOpenAddressing *hashMap);
/* 构造函数 */
HashMapOpenAddressing *newHashMapOpenAddressing() {
HashMapOpenAddressing *hashMap = (HashMapOpenAddressing *)malloc(sizeof(HashMapOpenAddressing));
hashMap->size = 0;
hashMap->capacity = 4;
hashMap->loadThres = 2.0 / 3.0;
hashMap->extendRatio = 2;
hashMap->buckets = (Pair **)calloc(hashMap->capacity, sizeof(Pair *));
hashMap->TOMBSTONE = (Pair *)malloc(sizeof(Pair));
hashMap->TOMBSTONE->key = -1;
hashMap->TOMBSTONE->val = "-1";
return hashMap;
}
/* 析构函数 */
void delHashMapOpenAddressing(HashMapOpenAddressing *hashMap) {
for (int i = 0; i < hashMap->capacity; i++) {
Pair *pair = hashMap->buckets[i];
if (pair != NULL && pair != hashMap->TOMBSTONE) {
free(pair->val);
free(pair);
}
}
free(hashMap->buckets);
free(hashMap->TOMBSTONE);
free(hashMap);
}
/* 哈希函数 */
int hashFunc(HashMapOpenAddressing *hashMap, int key) {
return key % hashMap->capacity;
}
/* 负载因子 */
double loadFactor(HashMapOpenAddressing *hashMap) {
return (double)hashMap->size / (double)hashMap->capacity;
}
/* 搜索 key 对应的桶索引 */
int findBucket(HashMapOpenAddressing *hashMap, int key) {
int index = hashFunc(hashMap, key);
int firstTombstone = -1;
// 线性探测,当遇到空桶时跳出
while (hashMap->buckets[index] != NULL) {
// 若遇到 key ,返回对应的桶索引
if (hashMap->buckets[index]->key == key) {
// 若之前遇到了删除标记,则将键值对移动至该索引处
if (firstTombstone != -1) {
hashMap->buckets[firstTombstone] = hashMap->buckets[index];
hashMap->buckets[index] = hashMap->TOMBSTONE;
return firstTombstone; // 返回移动后的桶索引
}
return index; // 返回桶索引
}
// 记录遇到的首个删除标记
if (firstTombstone == -1 && hashMap->buckets[index] == hashMap->TOMBSTONE) {
firstTombstone = index;
}
// 计算桶索引,越过尾部则返回头部
index = (index + 1) % hashMap->capacity;
}
// 若 key 不存在,则返回添加点的索引
return firstTombstone == -1 ? index : firstTombstone;
}
/* 查询操作 */
char *get(HashMapOpenAddressing *hashMap, int key) {
// 搜索 key 对应的桶索引
int index = findBucket(hashMap, key);
// 若找到键值对,则返回对应 val
if (hashMap->buckets[index] != NULL && hashMap->buckets[index] != hashMap->TOMBSTONE) {
return hashMap->buckets[index]->val;
}
// 若键值对不存在,则返回空字符串
return "";
}
/* 添加操作 */
void put(HashMapOpenAddressing *hashMap, int key, char *val) {
// 当负载因子超过阈值时,执行扩容
if (loadFactor(hashMap) > hashMap->loadThres) {
extend(hashMap);
}
// 搜索 key 对应的桶索引
int index = findBucket(hashMap, key);
// 若找到键值对,则覆盖 val 并返回
if (hashMap->buckets[index] != NULL && hashMap->buckets[index] != hashMap->TOMBSTONE) {
free(hashMap->buckets[index]->val);
hashMap->buckets[index]->val = (char *)malloc(sizeof(strlen(val) + 1));
strcpy(hashMap->buckets[index]->val, val);
hashMap->buckets[index]->val[strlen(val)] = '\0';
return;
}
// 若键值对不存在,则添加该键值对
Pair *pair = (Pair *)malloc(sizeof(Pair));
pair->key = key;
pair->val = (char *)malloc(sizeof(strlen(val) + 1));
strcpy(pair->val, val);
pair->val[strlen(val)] = '\0';
hashMap->buckets[index] = pair;
hashMap->size++;
}
/* 删除操作 */
void removeItem(HashMapOpenAddressing *hashMap, int key) {
// 搜索 key 对应的桶索引
int index = findBucket(hashMap, key);
// 若找到键值对,则用删除标记覆盖它
if (hashMap->buckets[index] != NULL && hashMap->buckets[index] != hashMap->TOMBSTONE) {
Pair *pair = hashMap->buckets[index];
free(pair->val);
free(pair);
hashMap->buckets[index] = hashMap->TOMBSTONE;
hashMap->size--;
}
}
/* 扩容哈希表 */
void extend(HashMapOpenAddressing *hashMap) {
// 暂存原哈希表
Pair **bucketsTmp = hashMap->buckets;
int oldCapacity = hashMap->capacity;
// 初始化扩容后的新哈希表
hashMap->capacity *= hashMap->extendRatio;
hashMap->buckets = (Pair **)calloc(hashMap->capacity, sizeof(Pair *));
hashMap->size = 0;
// 将键值对从原哈希表搬运至新哈希表
for (int i = 0; i < oldCapacity; i++) {
Pair *pair = bucketsTmp[i];
if (pair != NULL && pair != hashMap->TOMBSTONE) {
put(hashMap, pair->key, pair->val);
free(pair->val);
free(pair);
}
}
free(bucketsTmp);
}
/* 打印哈希表 */
void print(HashMapOpenAddressing *hashMap) {
for (int i = 0; i < hashMap->capacity; i++) {
Pair *pair = hashMap->buckets[i];
if (pair == NULL) {
printf("NULL\n");
} else if (pair == hashMap->TOMBSTONE) {
printf("TOMBSTONE\n");
} else {
printf("%d -> %s\n", pair->key, pair->val);
}
}
}
/* Driver Code */
int main() {
// 初始化哈希表
HashMapOpenAddressing *hashmap = newHashMapOpenAddressing();
// 添加操作
// 在哈希表中添加键值对 (key, val)
put(hashmap, 12836, "小哈");
put(hashmap, 15937, "小啰");
put(hashmap, 16750, "小算");
put(hashmap, 13276, "小法");
put(hashmap, 10583, "小鸭");
printf("\n添加完成后,哈希表为\nKey -> Value\n");
print(hashmap);
// 查询操作
// 向哈希表中输入键 key ,得到值 val
char *name = get(hashmap, 13276);
printf("\n输入学号 13276 ,查询到姓名 %s\n", name);
// 删除操作
// 在哈希表中删除键值对 (key, val)
removeItem(hashmap, 16750);
printf("\n删除 16750 后,哈希表为\nKey -> Value\n");
print(hashmap);
// 销毁哈希表
delHashMapOpenAddressing(hashmap);
return 0;
}
================================================
FILE: codes/c/chapter_hashing/simple_hash.c
================================================
/**
* File: simple_hash.c
* Created Time: 2023-09-09
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
/* 加法哈希 */
int addHash(char *key) {
long long hash = 0;
const int MODULUS = 1000000007;
for (int i = 0; i < strlen(key); i++) {
hash = (hash + (unsigned char)key[i]) % MODULUS;
}
return (int)hash;
}
/* 乘法哈希 */
int mulHash(char *key) {
long long hash = 0;
const int MODULUS = 1000000007;
for (int i = 0; i < strlen(key); i++) {
hash = (31 * hash + (unsigned char)key[i]) % MODULUS;
}
return (int)hash;
}
/* 异或哈希 */
int xorHash(char *key) {
int hash = 0;
const int MODULUS = 1000000007;
for (int i = 0; i < strlen(key); i++) {
hash ^= (unsigned char)key[i];
}
return hash & MODULUS;
}
/* 旋转哈希 */
int rotHash(char *key) {
long long hash = 0;
const int MODULUS = 1000000007;
for (int i = 0; i < strlen(key); i++) {
hash = ((hash << 4) ^ (hash >> 28) ^ (unsigned char)key[i]) % MODULUS;
}
return (int)hash;
}
/* Driver Code */
int main() {
char *key = "Hello 算法";
int hash = addHash(key);
printf("加法哈希值为 %d\n", hash);
hash = mulHash(key);
printf("乘法哈希值为 %d\n", hash);
hash = xorHash(key);
printf("异或哈希值为 %d\n", hash);
hash = rotHash(key);
printf("旋转哈希值为 %d\n", hash);
return 0;
}
================================================
FILE: codes/c/chapter_heap/CMakeLists.txt
================================================
add_executable(my_heap_test my_heap_test.c)
add_executable(top_k top_k.c)
================================================
FILE: codes/c/chapter_heap/my_heap.c
================================================
/**
* File: my_heap.c
* Created Time: 2023-01-15
* Author: Reanon (793584285@qq.com)
*/
#include "../utils/common.h"
#define MAX_SIZE 5000
/* 大顶堆 */
typedef struct {
// size 代表的是实际元素的个数
int size;
// 使用预先分配内存的数组,避免扩容
int data[MAX_SIZE];
} MaxHeap;
// 函数声明
void siftDown(MaxHeap *maxHeap, int i);
void siftUp(MaxHeap *maxHeap, int i);
int parent(MaxHeap *maxHeap, int i);
/* 构造函数,根据切片建堆 */
MaxHeap *newMaxHeap(int nums[], int size) {
// 所有元素入堆
MaxHeap *maxHeap = (MaxHeap *)malloc(sizeof(MaxHeap));
maxHeap->size = size;
memcpy(maxHeap->data, nums, size * sizeof(int));
for (int i = parent(maxHeap, size - 1); i >= 0; i--) {
// 堆化除叶节点以外的其他所有节点
siftDown(maxHeap, i);
}
return maxHeap;
}
/* 析构函数 */
void delMaxHeap(MaxHeap *maxHeap) {
// 释放内存
free(maxHeap);
}
/* 获取左子节点的索引 */
int left(MaxHeap *maxHeap, int i) {
return 2 * i + 1;
}
/* 获取右子节点的索引 */
int right(MaxHeap *maxHeap, int i) {
return 2 * i + 2;
}
/* 获取父节点的索引 */
int parent(MaxHeap *maxHeap, int i) {
return (i - 1) / 2; // 向下取整
}
/* 交换元素 */
void swap(MaxHeap *maxHeap, int i, int j) {
int temp = maxHeap->data[i];
maxHeap->data[i] = maxHeap->data[j];
maxHeap->data[j] = temp;
}
/* 获取堆大小 */
int size(MaxHeap *maxHeap) {
return maxHeap->size;
}
/* 判断堆是否为空 */
int isEmpty(MaxHeap *maxHeap) {
return maxHeap->size == 0;
}
/* 访问堆顶元素 */
int peek(MaxHeap *maxHeap) {
return maxHeap->data[0];
}
/* 元素入堆 */
void push(MaxHeap *maxHeap, int val) {
// 默认情况下,不应该添加这么多节点
if (maxHeap->size == MAX_SIZE) {
printf("heap is full!");
return;
}
// 添加节点
maxHeap->data[maxHeap->size] = val;
maxHeap->size++;
// 从底至顶堆化
siftUp(maxHeap, maxHeap->size - 1);
}
/* 元素出堆 */
int pop(MaxHeap *maxHeap) {
// 判空处理
if (isEmpty(maxHeap)) {
printf("heap is empty!");
return INT_MAX;
}
// 交换根节点与最右叶节点(交换首元素与尾元素)
swap(maxHeap, 0, size(maxHeap) - 1);
// 删除节点
int val = maxHeap->data[maxHeap->size - 1];
maxHeap->size--;
// 从顶至底堆化
siftDown(maxHeap, 0);
// 返回堆顶元素
return val;
}
/* 从节点 i 开始,从顶至底堆化 */
void siftDown(MaxHeap *maxHeap, int i) {
while (true) {
// 判断节点 i, l, r 中值最大的节点,记为 max
int l = left(maxHeap, i);
int r = right(maxHeap, i);
int max = i;
if (l < size(maxHeap) && maxHeap->data[l] > maxHeap->data[max]) {
max = l;
}
if (r < size(maxHeap) && maxHeap->data[r] > maxHeap->data[max]) {
max = r;
}
// 若节点 i 最大或索引 l, r 越界,则无须继续堆化,跳出
if (max == i) {
break;
}
// 交换两节点
swap(maxHeap, i, max);
// 循环向下堆化
i = max;
}
}
/* 从节点 i 开始,从底至顶堆化 */
void siftUp(MaxHeap *maxHeap, int i) {
while (true) {
// 获取节点 i 的父节点
int p = parent(maxHeap, i);
// 当“越过根节点”或“节点无须修复”时,结束堆化
if (p < 0 || maxHeap->data[i] <= maxHeap->data[p]) {
break;
}
// 交换两节点
swap(maxHeap, i, p);
// 循环向上堆化
i = p;
}
}
================================================
FILE: codes/c/chapter_heap/my_heap_test.c
================================================
/**
* File: my_heap_test.c
* Created Time: 2023-01-15
* Author: Reanon (793584285@qq.com)
*/
#include "my_heap.c"
/* Driver Code */
int main() {
/* 初始化堆 */
// 初始化大顶堆
int nums[] = {9, 8, 6, 6, 7, 5, 2, 1, 4, 3, 6, 2};
MaxHeap *maxHeap = newMaxHeap(nums, sizeof(nums) / sizeof(int));
printf("输入数组并建堆后\n");
printHeap(maxHeap->data, maxHeap->size);
/* 获取堆顶元素 */
printf("\n堆顶元素为 %d\n", peek(maxHeap));
/* 元素入堆 */
push(maxHeap, 7);
printf("\n元素 7 入堆后\n");
printHeap(maxHeap->data, maxHeap->size);
/* 堆顶元素出堆 */
int top = pop(maxHeap);
printf("\n堆顶元素 %d 出堆后\n", top);
printHeap(maxHeap->data, maxHeap->size);
/* 获取堆大小 */
printf("\n堆元素数量为 %d\n", size(maxHeap));
/* 判断堆是否为空 */
printf("\n堆是否为空 %d\n", isEmpty(maxHeap));
// 释放内存
delMaxHeap(maxHeap);
return 0;
}
================================================
FILE: codes/c/chapter_heap/top_k.c
================================================
/**
* File: top_k.c
* Created Time: 2023-10-26
* Author: krahets (krahets163.com)
*/
#include "my_heap.c"
/* 元素入堆 */
void pushMinHeap(MaxHeap *maxHeap, int val) {
// 元素取反
push(maxHeap, -val);
}
/* 元素出堆 */
int popMinHeap(MaxHeap *maxHeap) {
// 元素取反
return -pop(maxHeap);
}
/* 访问堆顶元素 */
int peekMinHeap(MaxHeap *maxHeap) {
// 元素取反
return -peek(maxHeap);
}
/* 取出堆中元素 */
int *getMinHeap(MaxHeap *maxHeap) {
// 将堆中所有元素取反并存入 res 数组
int *res = (int *)malloc(maxHeap->size * sizeof(int));
for (int i = 0; i < maxHeap->size; i++) {
res[i] = -maxHeap->data[i];
}
return res;
}
// 基于堆查找数组中最大的 k 个元素的函数
int *topKHeap(int *nums, int sizeNums, int k) {
// 初始化小顶堆
// 请注意:我们将堆中所有元素取反,从而用大顶堆来模拟小顶堆
int *empty = (int *)malloc(0);
MaxHeap *maxHeap = newMaxHeap(empty, 0);
// 将数组的前 k 个元素入堆
for (int i = 0; i < k; i++) {
pushMinHeap(maxHeap, nums[i]);
}
// 从第 k+1 个元素开始,保持堆的长度为 k
for (int i = k; i < sizeNums; i++) {
// 若当前元素大于堆顶元素,则将堆顶元素出堆、当前元素入堆
if (nums[i] > peekMinHeap(maxHeap)) {
popMinHeap(maxHeap);
pushMinHeap(maxHeap, nums[i]);
}
}
int *res = getMinHeap(maxHeap);
// 释放内存
delMaxHeap(maxHeap);
return res;
}
/* Driver Code */
int main() {
int nums[] = {1, 7, 6, 3, 2};
int k = 3;
int sizeNums = sizeof(nums) / sizeof(nums[0]);
int *res = topKHeap(nums, sizeNums, k);
printf("最大的 %d 个元素为: ", k);
printArray(res, k);
free(res);
return 0;
}
================================================
FILE: codes/c/chapter_searching/CMakeLists.txt
================================================
add_executable(binary_search binary_search.c)
add_executable(two_sum two_sum.c)
add_executable(binary_search_edge binary_search_edge.c)
add_executable(binary_search_insertion binary_search_insertion.c)
================================================
FILE: codes/c/chapter_searching/binary_search.c
================================================
/**
* File: binary_search.c
* Created Time: 2023-03-18
* Author: Guanngxu (446678850@qq.com)
*/
#include "../utils/common.h"
/* 二分查找(双闭区间) */
int binarySearch(int *nums, int len, int target) {
// 初始化双闭区间 [0, n-1] ,即 i, j 分别指向数组首元素、尾元素
int i = 0, j = len - 1;
// 循环,当搜索区间为空时跳出(当 i > j 时为空)
while (i <= j) {
int m = i + (j - i) / 2; // 计算中点索引 m
if (nums[m] < target) // 此情况说明 target 在区间 [m+1, j] 中
i = m + 1;
else if (nums[m] > target) // 此情况说明 target 在区间 [i, m-1] 中
j = m - 1;
else // 找到目标元素,返回其索引
return m;
}
// 未找到目标元素,返回 -1
return -1;
}
/* 二分查找(左闭右开区间) */
int binarySearchLCRO(int *nums, int len, int target) {
// 初始化左闭右开区间 [0, n) ,即 i, j 分别指向数组首元素、尾元素+1
int i = 0, j = len;
// 循环,当搜索区间为空时跳出(当 i = j 时为空)
while (i < j) {
int m = i + (j - i) / 2; // 计算中点索引 m
if (nums[m] < target) // 此情况说明 target 在区间 [m+1, j) 中
i = m + 1;
else if (nums[m] > target) // 此情况说明 target 在区间 [i, m) 中
j = m;
else // 找到目标元素,返回其索引
return m;
}
// 未找到目标元素,返回 -1
return -1;
}
/* Driver Code */
int main() {
int target = 6;
int nums[10] = {1, 3, 6, 8, 12, 15, 23, 26, 31, 35};
/* 二分查找(双闭区间) */
int index = binarySearch(nums, 10, target);
printf("目标元素 6 的索引 = %d\n", index);
/* 二分查找(左闭右开区间) */
index = binarySearchLCRO(nums, 10, target);
printf("目标元素 6 的索引 = %d\n", index);
return 0;
}
================================================
FILE: codes/c/chapter_searching/binary_search_edge.c
================================================
/**
* File: binary_search_edge.c
* Created Time: 2023-09-09
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
/* 二分查找插入点(存在重复元素) */
int binarySearchInsertion(int *nums, int numSize, int target) {
int i = 0, j = numSize - 1; // 初始化双闭区间 [0, n-1]
while (i <= j) {
int m = i + (j - i) / 2; // 计算中点索引 m
if (nums[m] < target) {
i = m + 1; // target 在区间 [m+1, j] 中
} else {
j = m - 1; // 首个小于 target 的元素在区间 [i, m-1] 中
}
}
// 返回插入点 i
return i;
}
/* 二分查找最左一个 target */
int binarySearchLeftEdge(int *nums, int numSize, int target) {
// 等价于查找 target 的插入点
int i = binarySearchInsertion(nums, numSize, target);
// 未找到 target ,返回 -1
if (i == numSize || nums[i] != target) {
return -1;
}
// 找到 target ,返回索引 i
return i;
}
/* 二分查找最右一个 target */
int binarySearchRightEdge(int *nums, int numSize, int target) {
// 转化为查找最左一个 target + 1
int i = binarySearchInsertion(nums, numSize, target + 1);
// j 指向最右一个 target ,i 指向首个大于 target 的元素
int j = i - 1;
// 未找到 target ,返回 -1
if (j == -1 || nums[j] != target) {
return -1;
}
// 找到 target ,返回索引 j
return j;
}
/* Driver Code */
int main() {
// 包含重复元素的数组
int nums[] = {1, 3, 6, 6, 6, 6, 6, 10, 12, 15};
printf("\n数组 nums = ");
printArray(nums, sizeof(nums) / sizeof(nums[0]));
// 二分查找左边界和右边界
int targets[] = {6, 7};
for (int i = 0; i < sizeof(targets) / sizeof(targets[0]); i++) {
int index = binarySearchLeftEdge(nums, sizeof(nums) / sizeof(nums[0]), targets[i]);
printf("最左一个元素 %d 的索引为 %d\n", targets[i], index);
index = binarySearchRightEdge(nums, sizeof(nums) / sizeof(nums[0]), targets[i]);
printf("最右一个元素 %d 的索引为 %d\n", targets[i], index);
}
return 0;
}
================================================
FILE: codes/c/chapter_searching/binary_search_insertion.c
================================================
/**
* File: binary_search_insertion.c
* Created Time: 2023-09-09
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
/* 二分查找插入点(无重复元素) */
int binarySearchInsertionSimple(int *nums, int numSize, int target) {
int i = 0, j = numSize - 1; // 初始化双闭区间 [0, n-1]
while (i <= j) {
int m = i + (j - i) / 2; // 计算中点索引 m
if (nums[m] < target) {
i = m + 1; // target 在区间 [m+1, j] 中
} else if (nums[m] > target) {
j = m - 1; // target 在区间 [i, m-1] 中
} else {
return m; // 找到 target ,返回插入点 m
}
}
// 未找到 target ,返回插入点 i
return i;
}
/* 二分查找插入点(存在重复元素) */
int binarySearchInsertion(int *nums, int numSize, int target) {
int i = 0, j = numSize - 1; // 初始化双闭区间 [0, n-1]
while (i <= j) {
int m = i + (j - i) / 2; // 计算中点索引 m
if (nums[m] < target) {
i = m + 1; // target 在区间 [m+1, j] 中
} else if (nums[m] > target) {
j = m - 1; // target 在区间 [i, m-1] 中
} else {
j = m - 1; // 首个小于 target 的元素在区间 [i, m-1] 中
}
}
// 返回插入点 i
return i;
}
/* Driver Code */
int main() {
// 无重复元素的数组
int nums1[] = {1, 3, 6, 8, 12, 15, 23, 26, 31, 35};
printf("\n数组 nums = ");
printArray(nums1, sizeof(nums1) / sizeof(nums1[0]));
// 二分查找插入点
int targets1[] = {6, 9};
for (int i = 0; i < sizeof(targets1) / sizeof(targets1[0]); i++) {
int index = binarySearchInsertionSimple(nums1, sizeof(nums1) / sizeof(nums1[0]), targets1[i]);
printf("元素 %d 的插入点的索引为 %d\n", targets1[i], index);
}
// 包含重复元素的数组
int nums2[] = {1, 3, 6, 6, 6, 6, 6, 10, 12, 15};
printf("\n数组 nums = ");
printArray(nums2, sizeof(nums2) / sizeof(nums2[0]));
// 二分查找插入点
int targets2[] = {2, 6, 20};
for (int i = 0; i < sizeof(targets2) / sizeof(int); i++) {
int index = binarySearchInsertion(nums2, sizeof(nums2) / sizeof(nums2[0]), targets2[i]);
printf("元素 %d 的插入点的索引为 %d\n", targets2[i], index);
}
return 0;
}
================================================
FILE: codes/c/chapter_searching/two_sum.c
================================================
/**
* File: two_sum.c
* Created Time: 2023-01-19
* Author: Reanon (793584285@qq.com)
*/
#include "../utils/common.h"
/* 方法一:暴力枚举 */
int *twoSumBruteForce(int *nums, int numsSize, int target, int *returnSize) {
for (int i = 0; i < numsSize; ++i) {
for (int j = i + 1; j < numsSize; ++j) {
if (nums[i] + nums[j] == target) {
int *res = malloc(sizeof(int) * 2);
res[0] = i, res[1] = j;
*returnSize = 2;
return res;
}
}
}
*returnSize = 0;
return NULL;
}
/* 哈希表 */
typedef struct {
int key;
int val;
UT_hash_handle hh; // 基于 uthash.h 实现
} HashTable;
/* 哈希表查询 */
HashTable *find(HashTable *h, int key) {
HashTable *tmp;
HASH_FIND_INT(h, &key, tmp);
return tmp;
}
/* 哈希表元素插入 */
void insert(HashTable **h, int key, int val) {
HashTable *t = find(*h, key);
if (t == NULL) {
HashTable *tmp = malloc(sizeof(HashTable));
tmp->key = key, tmp->val = val;
HASH_ADD_INT(*h, key, tmp);
} else {
t->val = val;
}
}
/* 方法二:辅助哈希表 */
int *twoSumHashTable(int *nums, int numsSize, int target, int *returnSize) {
HashTable *hashtable = NULL;
for (int i = 0; i < numsSize; i++) {
HashTable *t = find(hashtable, target - nums[i]);
if (t != NULL) {
int *res = malloc(sizeof(int) * 2);
res[0] = t->val, res[1] = i;
*returnSize = 2;
return res;
}
insert(&hashtable, nums[i], i);
}
*returnSize = 0;
return NULL;
}
/* Driver Code */
int main() {
// ======= Test Case =======
int nums[] = {2, 7, 11, 15};
int target = 13;
// ====== Driver Code ======
int returnSize;
int *res = twoSumBruteForce(nums, sizeof(nums) / sizeof(int), target, &returnSize);
// 方法一
printf("方法一 res = ");
printArray(res, returnSize);
// 方法二
res = twoSumHashTable(nums, sizeof(nums) / sizeof(int), target, &returnSize);
printf("方法二 res = ");
printArray(res, returnSize);
return 0;
}
================================================
FILE: codes/c/chapter_sorting/CMakeLists.txt
================================================
add_executable(bubble_sort bubble_sort.c)
add_executable(insertion_sort insertion_sort.c)
add_executable(quick_sort quick_sort.c)
add_executable(counting_sort counting_sort.c)
add_executable(radix_sort radix_sort.c)
add_executable(merge_sort merge_sort.c)
add_executable(heap_sort heap_sort.c)
add_executable(bucket_sort bucket_sort.c)
add_executable(selection_sort selection_sort.c)
================================================
FILE: codes/c/chapter_sorting/bubble_sort.c
================================================
/**
* File: bubble_sort.c
* Created Time: 2022-12-26
* Author: Listening (https://github.com/L-Super)
*/
#include "../utils/common.h"
/* 冒泡排序 */
void bubbleSort(int nums[], int size) {
// 外循环:未排序区间为 [0, i]
for (int i = size - 1; i > 0; i--) {
// 内循环:将未排序区间 [0, i] 中的最大元素交换至该区间的最右端
for (int j = 0; j < i; j++) {
if (nums[j] > nums[j + 1]) {
int temp = nums[j];
nums[j] = nums[j + 1];
nums[j + 1] = temp;
}
}
}
}
/* 冒泡排序(标志优化)*/
void bubbleSortWithFlag(int nums[], int size) {
// 外循环:未排序区间为 [0, i]
for (int i = size - 1; i > 0; i--) {
bool flag = false;
// 内循环:将未排序区间 [0, i] 中的最大元素交换至该区间的最右端
for (int j = 0; j < i; j++) {
if (nums[j] > nums[j + 1]) {
int temp = nums[j];
nums[j] = nums[j + 1];
nums[j + 1] = temp;
flag = true;
}
}
if (!flag)
break;
}
}
/* Driver Code */
int main() {
int nums[6] = {4, 1, 3, 1, 5, 2};
printf("冒泡排序后: ");
bubbleSort(nums, 6);
for (int i = 0; i < 6; i++) {
printf("%d ", nums[i]);
}
int nums1[6] = {4, 1, 3, 1, 5, 2};
printf("\n优化版冒泡排序后: ");
bubbleSortWithFlag(nums1, 6);
for (int i = 0; i < 6; i++) {
printf("%d ", nums1[i]);
}
printf("\n");
return 0;
}
================================================
FILE: codes/c/chapter_sorting/bucket_sort.c
================================================
/**
* File: bucket_sort.c
* Created Time: 2023-05-30
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
#define SIZE 10
/* 用于 qsort 的比较函数 */
int compare(const void *a, const void *b) {
float fa = *(const float *)a;
float fb = *(const float *)b;
return (fa > fb) - (fa < fb);
}
/* 桶排序 */
void bucketSort(float nums[], int n) {
int k = n / 2; // 初始化 k = n/2 个桶
int *sizes = malloc(k * sizeof(int)); // 记录每个桶的大小
float **buckets = malloc(k * sizeof(float *)); // 动态数组的数组(桶)
// 为每个桶预分配足够的空间
for (int i = 0; i < k; ++i) {
buckets[i] = (float *)malloc(n * sizeof(float));
sizes[i] = 0;
}
// 1. 将数组元素分配到各个桶中
for (int i = 0; i < n; ++i) {
int idx = (int)(nums[i] * k);
buckets[idx][sizes[idx]++] = nums[i];
}
// 2. 对各个桶执行排序
for (int i = 0; i < k; ++i) {
qsort(buckets[i], sizes[i], sizeof(float), compare);
}
// 3. 合并排序后的桶
int idx = 0;
for (int i = 0; i < k; ++i) {
for (int j = 0; j < sizes[i]; ++j) {
nums[idx++] = buckets[i][j];
}
// 释放内存
free(buckets[i]);
}
}
/* Driver Code */
int main() {
// 设输入数据为浮点数,范围为 [0, 1)
float nums[SIZE] = {0.49f, 0.96f, 0.82f, 0.09f, 0.57f, 0.43f, 0.91f, 0.75f, 0.15f, 0.37f};
bucketSort(nums, SIZE);
printf("桶排序完成后 nums = ");
printArrayFloat(nums, SIZE);
return 0;
}
================================================
FILE: codes/c/chapter_sorting/counting_sort.c
================================================
/**
* File: counting_sort.c
* Created Time: 2023-03-20
* Author: Reanon (793584285@qq.com), Guanngxu (446678850@qq.com)
*/
#include "../utils/common.h"
/* 计数排序 */
// 简单实现,无法用于排序对象
void countingSortNaive(int nums[], int size) {
// 1. 统计数组最大元素 m
int m = 0;
for (int i = 0; i < size; i++) {
if (nums[i] > m) {
m = nums[i];
}
}
// 2. 统计各数字的出现次数
// counter[num] 代表 num 的出现次数
int *counter = calloc(m + 1, sizeof(int));
for (int i = 0; i < size; i++) {
counter[nums[i]]++;
}
// 3. 遍历 counter ,将各元素填入原数组 nums
int i = 0;
for (int num = 0; num < m + 1; num++) {
for (int j = 0; j < counter[num]; j++, i++) {
nums[i] = num;
}
}
// 4. 释放内存
free(counter);
}
/* 计数排序 */
// 完整实现,可排序对象,并且是稳定排序
void countingSort(int nums[], int size) {
// 1. 统计数组最大元素 m
int m = 0;
for (int i = 0; i < size; i++) {
if (nums[i] > m) {
m = nums[i];
}
}
// 2. 统计各数字的出现次数
// counter[num] 代表 num 的出现次数
int *counter = calloc(m, sizeof(int));
for (int i = 0; i < size; i++) {
counter[nums[i]]++;
}
// 3. 求 counter 的前缀和,将“出现次数”转换为“尾索引”
// 即 counter[num]-1 是 num 在 res 中最后一次出现的索引
for (int i = 0; i < m; i++) {
counter[i + 1] += counter[i];
}
// 4. 倒序遍历 nums ,将各元素填入结果数组 res
// 初始化数组 res 用于记录结果
int *res = malloc(sizeof(int) * size);
for (int i = size - 1; i >= 0; i--) {
int num = nums[i];
res[counter[num] - 1] = num; // 将 num 放置到对应索引处
counter[num]--; // 令前缀和自减 1 ,得到下次放置 num 的索引
}
// 使用结果数组 res 覆盖原数组 nums
memcpy(nums, res, size * sizeof(int));
// 5. 释放内存
free(res);
free(counter);
}
/* Driver Code */
int main() {
int nums[] = {1, 0, 1, 2, 0, 4, 0, 2, 2, 4};
int size = sizeof(nums) / sizeof(int);
countingSortNaive(nums, size);
printf("计数排序(无法排序对象)完成后 nums = ");
printArray(nums, size);
int nums1[] = {1, 0, 1, 2, 0, 4, 0, 2, 2, 4};
int size1 = sizeof(nums1) / sizeof(int);
countingSort(nums1, size1);
printf("计数排序完成后 nums1 = ");
printArray(nums1, size1);
return 0;
}
================================================
FILE: codes/c/chapter_sorting/heap_sort.c
================================================
/**
* File: heap_sort.c
* Created Time: 2023-05-30
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
/* 堆的长度为 n ,从节点 i 开始,从顶至底堆化 */
void siftDown(int nums[], int n, int i) {
while (1) {
// 判断节点 i, l, r 中值最大的节点,记为 ma
int l = 2 * i + 1;
int r = 2 * i + 2;
int ma = i;
if (l < n && nums[l] > nums[ma])
ma = l;
if (r < n && nums[r] > nums[ma])
ma = r;
// 若节点 i 最大或索引 l, r 越界,则无须继续堆化,跳出
if (ma == i) {
break;
}
// 交换两节点
int temp = nums[i];
nums[i] = nums[ma];
nums[ma] = temp;
// 循环向下堆化
i = ma;
}
}
/* 堆排序 */
void heapSort(int nums[], int n) {
// 建堆操作:堆化除叶节点以外的其他所有节点
for (int i = n / 2 - 1; i >= 0; --i) {
siftDown(nums, n, i);
}
// 从堆中提取最大元素,循环 n-1 轮
for (int i = n - 1; i > 0; --i) {
// 交换根节点与最右叶节点(交换首元素与尾元素)
int tmp = nums[0];
nums[0] = nums[i];
nums[i] = tmp;
// 以根节点为起点,从顶至底进行堆化
siftDown(nums, i, 0);
}
}
/* Driver Code */
int main() {
int nums[] = {4, 1, 3, 1, 5, 2};
int n = sizeof(nums) / sizeof(nums[0]);
heapSort(nums, n);
printf("堆排序完成后 nums = ");
printArray(nums, n);
return 0;
}
================================================
FILE: codes/c/chapter_sorting/insertion_sort.c
================================================
/**
* File: insertion_sort.c
* Created Time: 2022-12-29
* Author: Listening (https://github.com/L-Super)
*/
#include "../utils/common.h"
/* 插入排序 */
void insertionSort(int nums[], int size) {
// 外循环:已排序区间为 [0, i-1]
for (int i = 1; i < size; i++) {
int base = nums[i], j = i - 1;
// 内循环:将 base 插入到已排序区间 [0, i-1] 中的正确位置
while (j >= 0 && nums[j] > base) {
// 将 nums[j] 向右移动一位
nums[j + 1] = nums[j];
j--;
}
// 将 base 赋值到正确位置
nums[j + 1] = base;
}
}
/* Driver Code */
int main() {
int nums[] = {4, 1, 3, 1, 5, 2};
insertionSort(nums, 6);
printf("插入排序完成后 nums = ");
for (int i = 0; i < 6; i++) {
printf("%d ", nums[i]);
}
printf("\n");
return 0;
}
================================================
FILE: codes/c/chapter_sorting/merge_sort.c
================================================
/**
* File: merge_sort.c
* Created Time: 2022-03-21
* Author: Guanngxu (446678850@qq.com)
*/
#include "../utils/common.h"
/* 合并左子数组和右子数组 */
void merge(int *nums, int left, int mid, int right) {
// 左子数组区间为 [left, mid], 右子数组区间为 [mid+1, right]
// 创建一个临时数组 tmp ,用于存放合并后的结果
int tmpSize = right - left + 1;
int *tmp = (int *)malloc(tmpSize * sizeof(int));
// 初始化左子数组和右子数组的起始索引
int i = left, j = mid + 1, k = 0;
// 当左右子数组都还有元素时,进行比较并将较小的元素复制到临时数组中
while (i <= mid && j <= right) {
if (nums[i] <= nums[j]) {
tmp[k++] = nums[i++];
} else {
tmp[k++] = nums[j++];
}
}
// 将左子数组和右子数组的剩余元素复制到临时数组中
while (i <= mid) {
tmp[k++] = nums[i++];
}
while (j <= right) {
tmp[k++] = nums[j++];
}
// 将临时数组 tmp 中的元素复制回原数组 nums 的对应区间
for (k = 0; k < tmpSize; ++k) {
nums[left + k] = tmp[k];
}
// 释放内存
free(tmp);
}
/* 归并排序 */
void mergeSort(int *nums, int left, int right) {
// 终止条件
if (left >= right)
return; // 当子数组长度为 1 时终止递归
// 划分阶段
int mid = left + (right - left) / 2; // 计算中点
mergeSort(nums, left, mid); // 递归左子数组
mergeSort(nums, mid + 1, right); // 递归右子数组
// 合并阶段
merge(nums, left, mid, right);
}
/* Driver Code */
int main() {
/* 归并排序 */
int nums[] = {7, 3, 2, 6, 0, 1, 5, 4};
int size = sizeof(nums) / sizeof(int);
mergeSort(nums, 0, size - 1);
printf("归并排序完成后 nums = ");
printArray(nums, size);
return 0;
}
================================================
FILE: codes/c/chapter_sorting/quick_sort.c
================================================
/**
* File: quick_sort.c
* Created Time: 2023-01-18
* Author: Reanon (793584285@qq.com)
*/
#include "../utils/common.h"
/* 元素交换 */
void swap(int nums[], int i, int j) {
int tmp = nums[i];
nums[i] = nums[j];
nums[j] = tmp;
}
/* 哨兵划分 */
int partition(int nums[], int left, int right) {
// 以 nums[left] 为基准数
int i = left, j = right;
while (i < j) {
while (i < j && nums[j] >= nums[left]) {
j--; // 从右向左找首个小于基准数的元素
}
while (i < j && nums[i] <= nums[left]) {
i++; // 从左向右找首个大于基准数的元素
}
// 交换这两个元素
swap(nums, i, j);
}
// 将基准数交换至两子数组的分界线
swap(nums, i, left);
// 返回基准数的索引
return i;
}
/* 快速排序 */
void quickSort(int nums[], int left, int right) {
// 子数组长度为 1 时终止递归
if (left >= right) {
return;
}
// 哨兵划分
int pivot = partition(nums, left, right);
// 递归左子数组、右子数组
quickSort(nums, left, pivot - 1);
quickSort(nums, pivot + 1, right);
}
// 以下为中位数优化的快速排序
/* 选取三个候选元素的中位数 */
int medianThree(int nums[], int left, int mid, int right) {
int l = nums[left], m = nums[mid], r = nums[right];
if ((l <= m && m <= r) || (r <= m && m <= l))
return mid; // m 在 l 和 r 之间
if ((m <= l && l <= r) || (r <= l && l <= m))
return left; // l 在 m 和 r 之间
return right;
}
/* 哨兵划分(三数取中值) */
int partitionMedian(int nums[], int left, int right) {
// 选取三个候选元素的中位数
int med = medianThree(nums, left, (left + right) / 2, right);
// 将中位数交换至数组最左端
swap(nums, left, med);
// 以 nums[left] 为基准数
int i = left, j = right;
while (i < j) {
while (i < j && nums[j] >= nums[left])
j--; // 从右向左找首个小于基准数的元素
while (i < j && nums[i] <= nums[left])
i++; // 从左向右找首个大于基准数的元素
swap(nums, i, j); // 交换这两个元素
}
swap(nums, i, left); // 将基准数交换至两子数组的分界线
return i; // 返回基准数的索引
}
/* 快速排序(三数取中值) */
void quickSortMedian(int nums[], int left, int right) {
// 子数组长度为 1 时终止递归
if (left >= right)
return;
// 哨兵划分
int pivot = partitionMedian(nums, left, right);
// 递归左子数组、右子数组
quickSortMedian(nums, left, pivot - 1);
quickSortMedian(nums, pivot + 1, right);
}
// 以下为递归深度优化的快速排序
/* 快速排序(递归深度优化) */
void quickSortTailCall(int nums[], int left, int right) {
// 子数组长度为 1 时终止
while (left < right) {
// 哨兵划分操作
int pivot = partition(nums, left, right);
// 对两个子数组中较短的那个执行快速排序
if (pivot - left < right - pivot) {
// 递归排序左子数组
quickSortTailCall(nums, left, pivot - 1);
// 剩余未排序区间为 [pivot + 1, right]
left = pivot + 1;
} else {
// 递归排序右子数组
quickSortTailCall(nums, pivot + 1, right);
// 剩余未排序区间为 [left, pivot - 1]
right = pivot - 1;
}
}
}
/* Driver Code */
int main() {
/* 快速排序 */
int nums[] = {2, 4, 1, 0, 3, 5};
int size = sizeof(nums) / sizeof(int);
quickSort(nums, 0, size - 1);
printf("快速排序完成后 nums = ");
printArray(nums, size);
/* 快速排序(中位基准数优化) */
int nums1[] = {2, 4, 1, 0, 3, 5};
quickSortMedian(nums1, 0, size - 1);
printf("快速排序(中位基准数优化)完成后 nums = ");
printArray(nums1, size);
/* 快速排序(递归深度优化) */
int nums2[] = {2, 4, 1, 0, 3, 5};
quickSortTailCall(nums2, 0, size - 1);
printf("快速排序(递归深度优化)完成后 nums = ");
printArray(nums1, size);
return 0;
}
================================================
FILE: codes/c/chapter_sorting/radix_sort.c
================================================
/**
* File: radix_sort.c
* Created Time: 2023-01-18
* Author: Reanon (793584285@qq.com)
*/
#include "../utils/common.h"
/* 获取元素 num 的第 k 位,其中 exp = 10^(k-1) */
int digit(int num, int exp) {
// 传入 exp 而非 k 可以避免在此重复执行昂贵的次方计算
return (num / exp) % 10;
}
/* 计数排序(根据 nums 第 k 位排序) */
void countingSortDigit(int nums[], int size, int exp) {
// 十进制的位范围为 0~9 ,因此需要长度为 10 的桶数组
int *counter = (int *)malloc((sizeof(int) * 10));
memset(counter, 0, sizeof(int) * 10); // 初始化为 0 以支持后续内存释放
// 统计 0~9 各数字的出现次数
for (int i = 0; i < size; i++) {
// 获取 nums[i] 第 k 位,记为 d
int d = digit(nums[i], exp);
// 统计数字 d 的出现次数
counter[d]++;
}
// 求前缀和,将“出现个数”转换为“数组索引”
for (int i = 1; i < 10; i++) {
counter[i] += counter[i - 1];
}
// 倒序遍历,根据桶内统计结果,将各元素填入 res
int *res = (int *)malloc(sizeof(int) * size);
for (int i = size - 1; i >= 0; i--) {
int d = digit(nums[i], exp);
int j = counter[d] - 1; // 获取 d 在数组中的索引 j
res[j] = nums[i]; // 将当前元素填入索引 j
counter[d]--; // 将 d 的数量减 1
}
// 使用结果覆盖原数组 nums
for (int i = 0; i < size; i++) {
nums[i] = res[i];
}
// 释放内存
free(res);
free(counter);
}
/* 基数排序 */
void radixSort(int nums[], int size) {
// 获取数组的最大元素,用于判断最大位数
int max = INT32_MIN;
for (int i = 0; i < size; i++) {
if (nums[i] > max) {
max = nums[i];
}
}
// 按照从低位到高位的顺序遍历
for (int exp = 1; max >= exp; exp *= 10)
// 对数组元素的第 k 位执行计数排序
// k = 1 -> exp = 1
// k = 2 -> exp = 10
// 即 exp = 10^(k-1)
countingSortDigit(nums, size, exp);
}
/* Driver Code */
int main() {
// 基数排序
int nums[] = {10546151, 35663510, 42865989, 34862445, 81883077,
88906420, 72429244, 30524779, 82060337, 63832996};
int size = sizeof(nums) / sizeof(int);
radixSort(nums, size);
printf("基数排序完成后 nums = ");
printArray(nums, size);
}
================================================
FILE: codes/c/chapter_sorting/selection_sort.c
================================================
/**
* File: selection_sort.c
* Created Time: 2023-05-31
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
/* 选择排序 */
void selectionSort(int nums[], int n) {
// 外循环:未排序区间为 [i, n-1]
for (int i = 0; i < n - 1; i++) {
// 内循环:找到未排序区间内的最小元素
int k = i;
for (int j = i + 1; j < n; j++) {
if (nums[j] < nums[k])
k = j; // 记录最小元素的索引
}
// 将该最小元素与未排序区间的首个元素交换
int temp = nums[i];
nums[i] = nums[k];
nums[k] = temp;
}
}
/* Driver Code */
int main() {
int nums[] = {4, 1, 3, 1, 5, 2};
int n = sizeof(nums) / sizeof(nums[0]);
selectionSort(nums, n);
printf("选择排序完成后 nums = ");
printArray(nums, n);
return 0;
}
================================================
FILE: codes/c/chapter_stack_and_queue/CMakeLists.txt
================================================
add_executable(array_stack array_stack.c)
add_executable(linkedlist_stack linkedlist_stack.c)
add_executable(array_queue array_queue.c)
add_executable(linkedlist_queue linkedlist_queue.c)
add_executable(array_deque array_deque.c)
add_executable(linkedlist_deque linkedlist_deque.c)
================================================
FILE: codes/c/chapter_stack_and_queue/array_deque.c
================================================
/**
* File: array_deque.c
* Created Time: 2023-03-13
* Author: Gonglja (glj0@outlook.com)
*/
#include "../utils/common.h"
/* 基于环形数组实现的双向队列 */
typedef struct {
int *nums; // 用于存储队列元素的数组
int front; // 队首指针,指向队首元素
int queSize; // 尾指针,指向队尾 + 1
int queCapacity; // 队列容量
} ArrayDeque;
/* 构造函数 */
ArrayDeque *newArrayDeque(int capacity) {
ArrayDeque *deque = (ArrayDeque *)malloc(sizeof(ArrayDeque));
// 初始化数组
deque->queCapacity = capacity;
deque->nums = (int *)malloc(sizeof(int) * deque->queCapacity);
deque->front = deque->queSize = 0;
return deque;
}
/* 析构函数 */
void delArrayDeque(ArrayDeque *deque) {
free(deque->nums);
free(deque);
}
/* 获取双向队列的容量 */
int capacity(ArrayDeque *deque) {
return deque->queCapacity;
}
/* 获取双向队列的长度 */
int size(ArrayDeque *deque) {
return deque->queSize;
}
/* 判断双向队列是否为空 */
bool empty(ArrayDeque *deque) {
return deque->queSize == 0;
}
/* 计算环形数组索引 */
int dequeIndex(ArrayDeque *deque, int i) {
// 通过取余操作实现数组首尾相连
// 当 i 越过数组尾部时,回到头部
// 当 i 越过数组头部后,回到尾部
return ((i + capacity(deque)) % capacity(deque));
}
/* 队首入队 */
void pushFirst(ArrayDeque *deque, int num) {
if (deque->queSize == capacity(deque)) {
printf("双向队列已满\r\n");
return;
}
// 队首指针向左移动一位
// 通过取余操作实现 front 越过数组头部回到尾部
deque->front = dequeIndex(deque, deque->front - 1);
// 将 num 添加到队首
deque->nums[deque->front] = num;
deque->queSize++;
}
/* 队尾入队 */
void pushLast(ArrayDeque *deque, int num) {
if (deque->queSize == capacity(deque)) {
printf("双向队列已满\r\n");
return;
}
// 计算队尾指针,指向队尾索引 + 1
int rear = dequeIndex(deque, deque->front + deque->queSize);
// 将 num 添加至队尾
deque->nums[rear] = num;
deque->queSize++;
}
/* 访问队首元素 */
int peekFirst(ArrayDeque *deque) {
// 访问异常:双向队列为空
assert(empty(deque) == 0);
return deque->nums[deque->front];
}
/* 访问队尾元素 */
int peekLast(ArrayDeque *deque) {
// 访问异常:双向队列为空
assert(empty(deque) == 0);
int last = dequeIndex(deque, deque->front + deque->queSize - 1);
return deque->nums[last];
}
/* 队首出队 */
int popFirst(ArrayDeque *deque) {
int num = peekFirst(deque);
// 队首指针向后移动一位
deque->front = dequeIndex(deque, deque->front + 1);
deque->queSize--;
return num;
}
/* 队尾出队 */
int popLast(ArrayDeque *deque) {
int num = peekLast(deque);
deque->queSize--;
return num;
}
/* 返回数组用于打印 */
int *toArray(ArrayDeque *deque, int *queSize) {
*queSize = deque->queSize;
int *res = (int *)calloc(deque->queSize, sizeof(int));
int j = deque->front;
for (int i = 0; i < deque->queSize; i++) {
res[i] = deque->nums[j % deque->queCapacity];
j++;
}
return res;
}
/* Driver Code */
int main() {
/* 初始化队列 */
int capacity = 10;
int queSize;
ArrayDeque *deque = newArrayDeque(capacity);
pushLast(deque, 3);
pushLast(deque, 2);
pushLast(deque, 5);
printf("双向队列 deque = ");
printArray(toArray(deque, &queSize), queSize);
/* 访问元素 */
int peekFirstNum = peekFirst(deque);
printf("队首元素 peekFirst = %d\r\n", peekFirstNum);
int peekLastNum = peekLast(deque);
printf("队尾元素 peekLast = %d\r\n", peekLastNum);
/* 元素入队 */
pushLast(deque, 4);
printf("元素 4 队尾入队后 deque = ");
printArray(toArray(deque, &queSize), queSize);
pushFirst(deque, 1);
printf("元素 1 队首入队后 deque = ");
printArray(toArray(deque, &queSize), queSize);
/* 元素出队 */
int popLastNum = popLast(deque);
printf("队尾出队元素 = %d ,队尾出队后 deque= ", popLastNum);
printArray(toArray(deque, &queSize), queSize);
int popFirstNum = popFirst(deque);
printf("队首出队元素 = %d ,队首出队后 deque= ", popFirstNum);
printArray(toArray(deque, &queSize), queSize);
/* 获取队列的长度 */
int dequeSize = size(deque);
printf("双向队列长度 size = %d\r\n", dequeSize);
/* 判断队列是否为空 */
bool isEmpty = empty(deque);
printf("队列是否为空 = %s\r\n", isEmpty ? "true" : "false");
// 释放内存
delArrayDeque(deque);
return 0;
}
================================================
FILE: codes/c/chapter_stack_and_queue/array_queue.c
================================================
/**
* File: array_queue.c
* Created Time: 2023-01-28
* Author: Zero (glj0@outlook.com)
*/
#include "../utils/common.h"
/* 基于环形数组实现的队列 */
typedef struct {
int *nums; // 用于存储队列元素的数组
int front; // 队首指针,指向队首元素
int queSize; // 当前队列的元素数量
int queCapacity; // 队列容量
} ArrayQueue;
/* 构造函数 */
ArrayQueue *newArrayQueue(int capacity) {
ArrayQueue *queue = (ArrayQueue *)malloc(sizeof(ArrayQueue));
// 初始化数组
queue->queCapacity = capacity;
queue->nums = (int *)malloc(sizeof(int) * queue->queCapacity);
queue->front = queue->queSize = 0;
return queue;
}
/* 析构函数 */
void delArrayQueue(ArrayQueue *queue) {
free(queue->nums);
free(queue);
}
/* 获取队列的容量 */
int capacity(ArrayQueue *queue) {
return queue->queCapacity;
}
/* 获取队列的长度 */
int size(ArrayQueue *queue) {
return queue->queSize;
}
/* 判断队列是否为空 */
bool empty(ArrayQueue *queue) {
return queue->queSize == 0;
}
/* 访问队首元素 */
int peek(ArrayQueue *queue) {
assert(size(queue) != 0);
return queue->nums[queue->front];
}
/* 入队 */
void push(ArrayQueue *queue, int num) {
if (size(queue) == capacity(queue)) {
printf("队列已满\r\n");
return;
}
// 计算队尾指针,指向队尾索引 + 1
// 通过取余操作实现 rear 越过数组尾部后回到头部
int rear = (queue->front + queue->queSize) % queue->queCapacity;
// 将 num 添加至队尾
queue->nums[rear] = num;
queue->queSize++;
}
/* 出队 */
int pop(ArrayQueue *queue) {
int num = peek(queue);
// 队首指针向后移动一位,若越过尾部,则返回到数组头部
queue->front = (queue->front + 1) % queue->queCapacity;
queue->queSize--;
return num;
}
/* 返回数组用于打印 */
int *toArray(ArrayQueue *queue, int *queSize) {
*queSize = queue->queSize;
int *res = (int *)calloc(queue->queSize, sizeof(int));
int j = queue->front;
for (int i = 0; i < queue->queSize; i++) {
res[i] = queue->nums[j % queue->queCapacity];
j++;
}
return res;
}
/* Driver Code */
int main() {
/* 初始化队列 */
int capacity = 10;
int queSize;
ArrayQueue *queue = newArrayQueue(capacity);
/* 元素入队 */
push(queue, 1);
push(queue, 3);
push(queue, 2);
push(queue, 5);
push(queue, 4);
printf("队列 queue = ");
printArray(toArray(queue, &queSize), queSize);
/* 访问队首元素 */
int peekNum = peek(queue);
printf("队首元素 peek = %d\r\n", peekNum);
/* 元素出队 */
peekNum = pop(queue);
printf("出队元素 pop = %d ,出队后 queue = ", peekNum);
printArray(toArray(queue, &queSize), queSize);
/* 获取队列的长度 */
int queueSize = size(queue);
printf("队列长度 size = %d\r\n", queueSize);
/* 判断队列是否为空 */
bool isEmpty = empty(queue);
printf("队列是否为空 = %s\r\n", isEmpty ? "true" : "false");
/* 测试环形数组 */
for (int i = 0; i < 10; i++) {
push(queue, i);
pop(queue);
printf("第 %d 轮入队 + 出队后 queue = ", i);
printArray(toArray(queue, &queSize), queSize);
}
// 释放内存
delArrayQueue(queue);
return 0;
}
================================================
FILE: codes/c/chapter_stack_and_queue/array_stack.c
================================================
/**
* File: array_stack.c
* Created Time: 2023-01-12
* Author: Zero (glj0@outlook.com)
*/
#include "../utils/common.h"
#define MAX_SIZE 5000
/* 基于数组实现的栈 */
typedef struct {
int *data;
int size;
} ArrayStack;
/* 构造函数 */
ArrayStack *newArrayStack() {
ArrayStack *stack = malloc(sizeof(ArrayStack));
// 初始化一个大容量,避免扩容
stack->data = malloc(sizeof(int) * MAX_SIZE);
stack->size = 0;
return stack;
}
/* 析构函数 */
void delArrayStack(ArrayStack *stack) {
free(stack->data);
free(stack);
}
/* 获取栈的长度 */
int size(ArrayStack *stack) {
return stack->size;
}
/* 判断栈是否为空 */
bool isEmpty(ArrayStack *stack) {
return stack->size == 0;
}
/* 入栈 */
void push(ArrayStack *stack, int num) {
if (stack->size == MAX_SIZE) {
printf("栈已满\n");
return;
}
stack->data[stack->size] = num;
stack->size++;
}
/* 访问栈顶元素 */
int peek(ArrayStack *stack) {
if (stack->size == 0) {
printf("栈为空\n");
return INT_MAX;
}
return stack->data[stack->size - 1];
}
/* 出栈 */
int pop(ArrayStack *stack) {
int val = peek(stack);
stack->size--;
return val;
}
/* Driver Code */
int main() {
/* 初始化栈 */
ArrayStack *stack = newArrayStack();
/* 元素入栈 */
push(stack, 1);
push(stack, 3);
push(stack, 2);
push(stack, 5);
push(stack, 4);
printf("栈 stack = ");
printArray(stack->data, stack->size);
/* 访问栈顶元素 */
int val = peek(stack);
printf("栈顶元素 top = %d\n", val);
/* 元素出栈 */
val = pop(stack);
printf("出栈元素 pop = %d ,出栈后 stack = ", val);
printArray(stack->data
Showing preview only (409K chars total). Download the full file or copy to clipboard to get everything.
gitextract_4c8t4fps/ ├── .gitattributes ├── .github/ │ ├── pull_request_template.md │ └── workflows/ │ ├── c.yml │ ├── cpp.yml │ ├── dart.yml │ ├── dotnet.yml │ ├── go.yml │ ├── java.yml │ ├── javascript.yml │ ├── kotlin.yml │ ├── python.yml │ ├── ruby.yml │ ├── rust.yml │ ├── swift.yml │ └── typescript.yml ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── codes/ │ ├── Dockerfile │ ├── c/ │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── CMakeLists.txt │ │ │ ├── array.c │ │ │ ├── linked_list.c │ │ │ └── my_list.c │ │ ├── chapter_backtracking/ │ │ │ ├── CMakeLists.txt │ │ │ ├── n_queens.c │ │ │ ├── permutations_i.c │ │ │ ├── permutations_ii.c │ │ │ ├── preorder_traversal_i_compact.c │ │ │ ├── preorder_traversal_ii_compact.c │ │ │ ├── preorder_traversal_iii_compact.c │ │ │ ├── preorder_traversal_iii_template.c │ │ │ ├── subset_sum_i.c │ │ │ ├── subset_sum_i_naive.c │ │ │ └── subset_sum_ii.c │ │ ├── chapter_computational_complexity/ │ │ │ ├── CMakeLists.txt │ │ │ ├── iteration.c │ │ │ ├── recursion.c │ │ │ ├── space_complexity.c │ │ │ ├── time_complexity.c │ │ │ └── worst_best_time_complexity.c │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── CMakeLists.txt │ │ │ ├── binary_search_recur.c │ │ │ ├── build_tree.c │ │ │ └── hanota.c │ │ ├── chapter_dynamic_programming/ │ │ │ ├── CMakeLists.txt │ │ │ ├── climbing_stairs_backtrack.c │ │ │ ├── climbing_stairs_constraint_dp.c │ │ │ ├── climbing_stairs_dfs.c │ │ │ ├── climbing_stairs_dfs_mem.c │ │ │ ├── climbing_stairs_dp.c │ │ │ ├── coin_change.c │ │ │ ├── coin_change_ii.c │ │ │ ├── edit_distance.c │ │ │ ├── knapsack.c │ │ │ ├── min_cost_climbing_stairs_dp.c │ │ │ ├── min_path_sum.c │ │ │ └── unbounded_knapsack.c │ │ ├── chapter_graph/ │ │ │ ├── CMakeLists.txt │ │ │ ├── graph_adjacency_list.c │ │ │ ├── graph_adjacency_list_test.c │ │ │ ├── graph_adjacency_matrix.c │ │ │ ├── graph_bfs.c │ │ │ └── graph_dfs.c │ │ ├── chapter_greedy/ │ │ │ ├── CMakeLists.txt │ │ │ ├── coin_change_greedy.c │ │ │ ├── fractional_knapsack.c │ │ │ ├── max_capacity.c │ │ │ └── max_product_cutting.c │ │ ├── chapter_hashing/ │ │ │ ├── CMakeLists.txt │ │ │ ├── array_hash_map.c │ │ │ ├── hash_map_chaining.c │ │ │ ├── hash_map_open_addressing.c │ │ │ └── simple_hash.c │ │ ├── chapter_heap/ │ │ │ ├── CMakeLists.txt │ │ │ ├── my_heap.c │ │ │ ├── my_heap_test.c │ │ │ └── top_k.c │ │ ├── chapter_searching/ │ │ │ ├── CMakeLists.txt │ │ │ ├── binary_search.c │ │ │ ├── binary_search_edge.c │ │ │ ├── binary_search_insertion.c │ │ │ └── two_sum.c │ │ ├── chapter_sorting/ │ │ │ ├── CMakeLists.txt │ │ │ ├── bubble_sort.c │ │ │ ├── bucket_sort.c │ │ │ ├── counting_sort.c │ │ │ ├── heap_sort.c │ │ │ ├── insertion_sort.c │ │ │ ├── merge_sort.c │ │ │ ├── quick_sort.c │ │ │ ├── radix_sort.c │ │ │ └── selection_sort.c │ │ ├── chapter_stack_and_queue/ │ │ │ ├── CMakeLists.txt │ │ │ ├── array_deque.c │ │ │ ├── array_queue.c │ │ │ ├── array_stack.c │ │ │ ├── linkedlist_deque.c │ │ │ ├── linkedlist_queue.c │ │ │ └── linkedlist_stack.c │ │ ├── chapter_tree/ │ │ │ ├── CMakeLists.txt │ │ │ ├── array_binary_tree.c │ │ │ ├── avl_tree.c │ │ │ ├── binary_search_tree.c │ │ │ ├── binary_tree.c │ │ │ ├── binary_tree_bfs.c │ │ │ └── binary_tree_dfs.c │ │ └── utils/ │ │ ├── CMakeLists.txt │ │ ├── common.h │ │ ├── common_test.c │ │ ├── list_node.h │ │ ├── print_util.h │ │ ├── tree_node.h │ │ ├── uthash.h │ │ ├── vector.h │ │ └── vertex.h │ ├── cpp/ │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── CMakeLists.txt │ │ │ ├── array.cpp │ │ │ ├── linked_list.cpp │ │ │ ├── list.cpp │ │ │ └── my_list.cpp │ │ ├── chapter_backtracking/ │ │ │ ├── CMakeLists.txt │ │ │ ├── n_queens.cpp │ │ │ ├── permutations_i.cpp │ │ │ ├── permutations_ii.cpp │ │ │ ├── preorder_traversal_i_compact.cpp │ │ │ ├── preorder_traversal_ii_compact.cpp │ │ │ ├── preorder_traversal_iii_compact.cpp │ │ │ ├── preorder_traversal_iii_template.cpp │ │ │ ├── subset_sum_i.cpp │ │ │ ├── subset_sum_i_naive.cpp │ │ │ └── subset_sum_ii.cpp │ │ ├── chapter_computational_complexity/ │ │ │ ├── CMakeLists.txt │ │ │ ├── iteration.cpp │ │ │ ├── recursion.cpp │ │ │ ├── space_complexity.cpp │ │ │ ├── time_complexity.cpp │ │ │ └── worst_best_time_complexity.cpp │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── CMakeLists.txt │ │ │ ├── binary_search_recur.cpp │ │ │ ├── build_tree.cpp │ │ │ └── hanota.cpp │ │ ├── chapter_dynamic_programming/ │ │ │ ├── CMakeLists.txt │ │ │ ├── climbing_stairs_backtrack.cpp │ │ │ ├── climbing_stairs_constraint_dp.cpp │ │ │ ├── climbing_stairs_dfs.cpp │ │ │ ├── climbing_stairs_dfs_mem.cpp │ │ │ ├── climbing_stairs_dp.cpp │ │ │ ├── coin_change.cpp │ │ │ ├── coin_change_ii.cpp │ │ │ ├── edit_distance.cpp │ │ │ ├── knapsack.cpp │ │ │ ├── min_cost_climbing_stairs_dp.cpp │ │ │ ├── min_path_sum.cpp │ │ │ └── unbounded_knapsack.cpp │ │ ├── chapter_graph/ │ │ │ ├── CMakeLists.txt │ │ │ ├── graph_adjacency_list.cpp │ │ │ ├── graph_adjacency_list_test.cpp │ │ │ ├── graph_adjacency_matrix.cpp │ │ │ ├── graph_bfs.cpp │ │ │ └── graph_dfs.cpp │ │ ├── chapter_greedy/ │ │ │ ├── CMakeLists.txt │ │ │ ├── coin_change_greedy.cpp │ │ │ ├── fractional_knapsack.cpp │ │ │ ├── max_capacity.cpp │ │ │ └── max_product_cutting.cpp │ │ ├── chapter_hashing/ │ │ │ ├── CMakeLists.txt │ │ │ ├── array_hash_map.cpp │ │ │ ├── array_hash_map_test.cpp │ │ │ ├── built_in_hash.cpp │ │ │ ├── hash_map.cpp │ │ │ ├── hash_map_chaining.cpp │ │ │ ├── hash_map_open_addressing.cpp │ │ │ └── simple_hash.cpp │ │ ├── chapter_heap/ │ │ │ ├── CMakeLists.txt │ │ │ ├── heap.cpp │ │ │ ├── my_heap.cpp │ │ │ └── top_k.cpp │ │ ├── chapter_searching/ │ │ │ ├── CMakeLists.txt │ │ │ ├── binary_search.cpp │ │ │ ├── binary_search_edge.cpp │ │ │ ├── binary_search_insertion.cpp │ │ │ ├── hashing_search.cpp │ │ │ ├── linear_search.cpp │ │ │ └── two_sum.cpp │ │ ├── chapter_sorting/ │ │ │ ├── CMakeLists.txt │ │ │ ├── bubble_sort.cpp │ │ │ ├── bucket_sort.cpp │ │ │ ├── counting_sort.cpp │ │ │ ├── heap_sort.cpp │ │ │ ├── insertion_sort.cpp │ │ │ ├── merge_sort.cpp │ │ │ ├── quick_sort.cpp │ │ │ ├── radix_sort.cpp │ │ │ └── selection_sort.cpp │ │ ├── chapter_stack_and_queue/ │ │ │ ├── CMakeLists.txt │ │ │ ├── array_deque.cpp │ │ │ ├── array_queue.cpp │ │ │ ├── array_stack.cpp │ │ │ ├── deque.cpp │ │ │ ├── linkedlist_deque.cpp │ │ │ ├── linkedlist_queue.cpp │ │ │ ├── linkedlist_stack.cpp │ │ │ ├── queue.cpp │ │ │ └── stack.cpp │ │ ├── chapter_tree/ │ │ │ ├── CMakeLists.txt │ │ │ ├── array_binary_tree.cpp │ │ │ ├── avl_tree.cpp │ │ │ ├── binary_search_tree.cpp │ │ │ ├── binary_tree.cpp │ │ │ ├── binary_tree_bfs.cpp │ │ │ └── binary_tree_dfs.cpp │ │ └── utils/ │ │ ├── CMakeLists.txt │ │ ├── common.hpp │ │ ├── list_node.hpp │ │ ├── print_utils.hpp │ │ ├── tree_node.hpp │ │ └── vertex.hpp │ ├── csharp/ │ │ ├── .editorconfig │ │ ├── .gitignore │ │ ├── GlobalUsing.cs │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.cs │ │ │ ├── linked_list.cs │ │ │ ├── list.cs │ │ │ └── my_list.cs │ │ ├── chapter_backtracking/ │ │ │ ├── n_queens.cs │ │ │ ├── permutations_i.cs │ │ │ ├── permutations_ii.cs │ │ │ ├── preorder_traversal_i_compact.cs │ │ │ ├── preorder_traversal_ii_compact.cs │ │ │ ├── preorder_traversal_iii_compact.cs │ │ │ ├── preorder_traversal_iii_template.cs │ │ │ ├── subset_sum_i.cs │ │ │ ├── subset_sum_i_naive.cs │ │ │ └── subset_sum_ii.cs │ │ ├── chapter_computational_complexity/ │ │ │ ├── iteration.cs │ │ │ ├── recursion.cs │ │ │ ├── space_complexity.cs │ │ │ ├── time_complexity.cs │ │ │ └── worst_best_time_complexity.cs │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── binary_search_recur.cs │ │ │ ├── build_tree.cs │ │ │ └── hanota.cs │ │ ├── chapter_dynamic_programming/ │ │ │ ├── climbing_stairs_backtrack.cs │ │ │ ├── climbing_stairs_constraint_dp.cs │ │ │ ├── climbing_stairs_dfs.cs │ │ │ ├── climbing_stairs_dfs_mem.cs │ │ │ ├── climbing_stairs_dp.cs │ │ │ ├── coin_change.cs │ │ │ ├── coin_change_ii.cs │ │ │ ├── edit_distance.cs │ │ │ ├── knapsack.cs │ │ │ ├── min_cost_climbing_stairs_dp.cs │ │ │ ├── min_path_sum.cs │ │ │ └── unbounded_knapsack.cs │ │ ├── chapter_graph/ │ │ │ ├── graph_adjacency_list.cs │ │ │ ├── graph_adjacency_matrix.cs │ │ │ ├── graph_bfs.cs │ │ │ └── graph_dfs.cs │ │ ├── chapter_greedy/ │ │ │ ├── coin_change_greedy.cs │ │ │ ├── fractional_knapsack.cs │ │ │ ├── max_capacity.cs │ │ │ └── max_product_cutting.cs │ │ ├── chapter_hashing/ │ │ │ ├── array_hash_map.cs │ │ │ ├── built_in_hash.cs │ │ │ ├── hash_map.cs │ │ │ ├── hash_map_chaining.cs │ │ │ ├── hash_map_open_addressing.cs │ │ │ └── simple_hash.cs │ │ ├── chapter_heap/ │ │ │ ├── heap.cs │ │ │ ├── my_heap.cs │ │ │ └── top_k.cs │ │ ├── chapter_searching/ │ │ │ ├── binary_search.cs │ │ │ ├── binary_search_edge.cs │ │ │ ├── binary_search_insertion.cs │ │ │ ├── hashing_search.cs │ │ │ ├── linear_search.cs │ │ │ └── two_sum.cs │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.cs │ │ │ ├── bucket_sort.cs │ │ │ ├── counting_sort.cs │ │ │ ├── heap_sort.cs │ │ │ ├── insertion_sort.cs │ │ │ ├── merge_sort.cs │ │ │ ├── quick_sort.cs │ │ │ ├── radix_sort.cs │ │ │ └── selection_sort.cs │ │ ├── chapter_stack_and_queue/ │ │ │ ├── array_deque.cs │ │ │ ├── array_queue.cs │ │ │ ├── array_stack.cs │ │ │ ├── deque.cs │ │ │ ├── linkedlist_deque.cs │ │ │ ├── linkedlist_queue.cs │ │ │ ├── linkedlist_stack.cs │ │ │ ├── queue.cs │ │ │ └── stack.cs │ │ ├── chapter_tree/ │ │ │ ├── array_binary_tree.cs │ │ │ ├── avl_tree.cs │ │ │ ├── binary_search_tree.cs │ │ │ ├── binary_tree.cs │ │ │ ├── binary_tree_bfs.cs │ │ │ └── binary_tree_dfs.cs │ │ ├── csharp.sln │ │ ├── hello-algo.csproj │ │ └── utils/ │ │ ├── ListNode.cs │ │ ├── PrintUtil.cs │ │ ├── TreeNode.cs │ │ └── Vertex.cs │ ├── dart/ │ │ ├── build.dart │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.dart │ │ │ ├── linked_list.dart │ │ │ ├── list.dart │ │ │ └── my_list.dart │ │ ├── chapter_backtracking/ │ │ │ ├── n_queens.dart │ │ │ ├── permutations_i.dart │ │ │ ├── permutations_ii.dart │ │ │ ├── preorder_traversal_i_compact.dart │ │ │ ├── preorder_traversal_ii_compact.dart │ │ │ ├── preorder_traversal_iii_compact.dart │ │ │ ├── preorder_traversal_iii_template.dart │ │ │ ├── subset_sum_i.dart │ │ │ ├── subset_sum_i_naive.dart │ │ │ └── subset_sum_ii.dart │ │ ├── chapter_computational_complexity/ │ │ │ ├── iteration.dart │ │ │ ├── recursion.dart │ │ │ ├── space_complexity.dart │ │ │ ├── time_complexity.dart │ │ │ └── worst_best_time_complexity.dart │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── binary_search_recur.dart │ │ │ ├── build_tree.dart │ │ │ └── hanota.dart │ │ ├── chapter_dynamic_programming/ │ │ │ ├── climbing_stairs_backtrack.dart │ │ │ ├── climbing_stairs_constraint_dp.dart │ │ │ ├── climbing_stairs_dfs.dart │ │ │ ├── climbing_stairs_dfs_mem.dart │ │ │ ├── climbing_stairs_dp.dart │ │ │ ├── coin_change.dart │ │ │ ├── coin_change_ii.dart │ │ │ ├── edit_distance.dart │ │ │ ├── knapsack.dart │ │ │ ├── min_cost_climbing_stairs_dp.dart │ │ │ ├── min_path_sum.dart │ │ │ └── unbounded_knapsack.dart │ │ ├── chapter_graph/ │ │ │ ├── graph_adjacency_list.dart │ │ │ ├── graph_adjacency_matrix.dart │ │ │ ├── graph_bfs.dart │ │ │ └── graph_dfs.dart │ │ ├── chapter_greedy/ │ │ │ ├── coin_change_greedy.dart │ │ │ ├── fractional_knapsack.dart │ │ │ ├── max_capacity.dart │ │ │ └── max_product_cutting.dart │ │ ├── chapter_hashing/ │ │ │ ├── array_hash_map.dart │ │ │ ├── built_in_hash.dart │ │ │ ├── hash_map.dart │ │ │ ├── hash_map_chaining.dart │ │ │ ├── hash_map_open_addressing.dart │ │ │ └── simple_hash.dart │ │ ├── chapter_heap/ │ │ │ ├── my_heap.dart │ │ │ └── top_k.dart │ │ ├── chapter_searching/ │ │ │ ├── binary_search.dart │ │ │ ├── binary_search_edge.dart │ │ │ ├── binary_search_insertion.dart │ │ │ ├── hashing_search.dart │ │ │ ├── linear_search.dart │ │ │ └── two_sum.dart │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.dart │ │ │ ├── bucket_sort.dart │ │ │ ├── counting_sort.dart │ │ │ ├── heap_sort.dart │ │ │ ├── insertion_sort.dart │ │ │ ├── merge_sort.dart │ │ │ ├── quick_sort.dart │ │ │ ├── radix_sort.dart │ │ │ └── selection_sort.dart │ │ ├── chapter_stack_and_queue/ │ │ │ ├── array_deque.dart │ │ │ ├── array_queue.dart │ │ │ ├── array_stack.dart │ │ │ ├── deque.dart │ │ │ ├── linkedlist_deque.dart │ │ │ ├── linkedlist_queue.dart │ │ │ ├── linkedlist_stack.dart │ │ │ ├── queue.dart │ │ │ └── stack.dart │ │ ├── chapter_tree/ │ │ │ ├── array_binary_tree.dart │ │ │ ├── avl_tree.dart │ │ │ ├── binary_search_tree.dart │ │ │ ├── binary_tree.dart │ │ │ ├── binary_tree_bfs.dart │ │ │ └── binary_tree_dfs.dart │ │ └── utils/ │ │ ├── list_node.dart │ │ ├── print_util.dart │ │ ├── tree_node.dart │ │ └── vertex.dart │ ├── docker-compose.yml │ ├── go/ │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.go │ │ │ ├── array_test.go │ │ │ ├── linked_list.go │ │ │ ├── linked_list_test.go │ │ │ ├── list_test.go │ │ │ ├── my_list.go │ │ │ └── my_list_test.go │ │ ├── chapter_backtracking/ │ │ │ ├── n_queens.go │ │ │ ├── n_queens_test.go │ │ │ ├── permutation_test.go │ │ │ ├── permutations_i.go │ │ │ ├── permutations_ii.go │ │ │ ├── preorder_traversal_i_compact.go │ │ │ ├── preorder_traversal_ii_compact.go │ │ │ ├── preorder_traversal_iii_compact.go │ │ │ ├── preorder_traversal_iii_template.go │ │ │ ├── preorder_traversal_test.go │ │ │ ├── subset_sum_i.go │ │ │ ├── subset_sum_i_naive.go │ │ │ ├── subset_sum_ii.go │ │ │ └── subset_sum_test.go │ │ ├── chapter_computational_complexity/ │ │ │ ├── iteration.go │ │ │ ├── iteration_test.go │ │ │ ├── recursion.go │ │ │ ├── recursion_test.go │ │ │ ├── space_complexity.go │ │ │ ├── space_complexity_test.go │ │ │ ├── time_complexity.go │ │ │ ├── time_complexity_test.go │ │ │ ├── worst_best_time_complexity.go │ │ │ └── worst_best_time_complexity_test.go │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── binary_search_recur.go │ │ │ ├── binary_search_recur_test.go │ │ │ ├── build_tree.go │ │ │ ├── build_tree_test.go │ │ │ ├── hanota.go │ │ │ └── hanota_test.go │ │ ├── chapter_dynamic_programming/ │ │ │ ├── climbing_stairs_backtrack.go │ │ │ ├── climbing_stairs_constraint_dp.go │ │ │ ├── climbing_stairs_dfs.go │ │ │ ├── climbing_stairs_dfs_mem.go │ │ │ ├── climbing_stairs_dp.go │ │ │ ├── climbing_stairs_test.go │ │ │ ├── coin_change.go │ │ │ ├── coin_change_ii.go │ │ │ ├── coin_change_test.go │ │ │ ├── edit_distance.go │ │ │ ├── edit_distance_test.go │ │ │ ├── knapsack.go │ │ │ ├── knapsack_test.go │ │ │ ├── min_cost_climbing_stairs_dp.go │ │ │ ├── min_path_sum.go │ │ │ ├── min_path_sum_test.go │ │ │ └── unbounded_knapsack.go │ │ ├── chapter_graph/ │ │ │ ├── graph_adjacency_list.go │ │ │ ├── graph_adjacency_list_test.go │ │ │ ├── graph_adjacency_matrix.go │ │ │ ├── graph_adjacency_matrix_test.go │ │ │ ├── graph_bfs.go │ │ │ ├── graph_bfs_test.go │ │ │ ├── graph_dfs.go │ │ │ └── graph_dfs_test.go │ │ ├── chapter_greedy/ │ │ │ ├── coin_change_greedy.go │ │ │ ├── coin_change_greedy_test.go │ │ │ ├── fractional_knapsack.go │ │ │ ├── fractional_knapsack_test.go │ │ │ ├── max_capacity.go │ │ │ ├── max_capacity_test.go │ │ │ ├── max_product_cutting.go │ │ │ └── max_product_cutting_test.go │ │ ├── chapter_hashing/ │ │ │ ├── array_hash_map.go │ │ │ ├── array_hash_map_test.go │ │ │ ├── hash_collision_test.go │ │ │ ├── hash_map_chaining.go │ │ │ ├── hash_map_open_addressing.go │ │ │ ├── hash_map_test.go │ │ │ └── simple_hash.go │ │ ├── chapter_heap/ │ │ │ ├── heap.go │ │ │ ├── heap_test.go │ │ │ ├── my_heap.go │ │ │ └── top_k.go │ │ ├── chapter_searching/ │ │ │ ├── binary_search.go │ │ │ ├── binary_search_edge.go │ │ │ ├── binary_search_insertion.go │ │ │ ├── binary_search_test.go │ │ │ ├── hashing_search.go │ │ │ ├── hashing_search_test.go │ │ │ ├── linear_search.go │ │ │ ├── linear_search_test.go │ │ │ ├── two_sum.go │ │ │ └── two_sum_test.go │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.go │ │ │ ├── bubble_sort_test.go │ │ │ ├── bucket_sort.go │ │ │ ├── bucket_sort_test.go │ │ │ ├── counting_sort.go │ │ │ ├── counting_sort_test.go │ │ │ ├── heap_sort.go │ │ │ ├── heap_sort_test.go │ │ │ ├── insertion_sort.go │ │ │ ├── insertion_sort_test.go │ │ │ ├── merge_sort.go │ │ │ ├── merge_sort_test.go │ │ │ ├── quick_sort.go │ │ │ ├── quick_sort_test.go │ │ │ ├── radix_sort.go │ │ │ ├── radix_sort_test.go │ │ │ ├── selection_sort.go │ │ │ └── selection_sort_test.go │ │ ├── chapter_stack_and_queue/ │ │ │ ├── array_deque.go │ │ │ ├── array_queue.go │ │ │ ├── array_stack.go │ │ │ ├── deque_test.go │ │ │ ├── linkedlist_deque.go │ │ │ ├── linkedlist_queue.go │ │ │ ├── linkedlist_stack.go │ │ │ ├── queue_test.go │ │ │ └── stack_test.go │ │ ├── chapter_tree/ │ │ │ ├── array_binary_tree.go │ │ │ ├── array_binary_tree_test.go │ │ │ ├── avl_tree.go │ │ │ ├── avl_tree_test.go │ │ │ ├── binary_search_tree.go │ │ │ ├── binary_search_tree_test.go │ │ │ ├── binary_tree_bfs.go │ │ │ ├── binary_tree_bfs_test.go │ │ │ ├── binary_tree_dfs.go │ │ │ ├── binary_tree_dfs_test.go │ │ │ └── binary_tree_test.go │ │ ├── go.mod │ │ └── pkg/ │ │ ├── list_node.go │ │ ├── list_node_test.go │ │ ├── print_utils.go │ │ ├── tree_node.go │ │ ├── tree_node_test.go │ │ └── vertex.go │ ├── java/ │ │ ├── .gitignore │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.java │ │ │ ├── linked_list.java │ │ │ ├── list.java │ │ │ └── my_list.java │ │ ├── chapter_backtracking/ │ │ │ ├── n_queens.java │ │ │ ├── permutations_i.java │ │ │ ├── permutations_ii.java │ │ │ ├── preorder_traversal_i_compact.java │ │ │ ├── preorder_traversal_ii_compact.java │ │ │ ├── preorder_traversal_iii_compact.java │ │ │ ├── preorder_traversal_iii_template.java │ │ │ ├── subset_sum_i.java │ │ │ ├── subset_sum_i_naive.java │ │ │ └── subset_sum_ii.java │ │ ├── chapter_computational_complexity/ │ │ │ ├── iteration.java │ │ │ ├── recursion.java │ │ │ ├── space_complexity.java │ │ │ ├── time_complexity.java │ │ │ └── worst_best_time_complexity.java │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── binary_search_recur.java │ │ │ ├── build_tree.java │ │ │ └── hanota.java │ │ ├── chapter_dynamic_programming/ │ │ │ ├── climbing_stairs_backtrack.java │ │ │ ├── climbing_stairs_constraint_dp.java │ │ │ ├── climbing_stairs_dfs.java │ │ │ ├── climbing_stairs_dfs_mem.java │ │ │ ├── climbing_stairs_dp.java │ │ │ ├── coin_change.java │ │ │ ├── coin_change_ii.java │ │ │ ├── edit_distance.java │ │ │ ├── knapsack.java │ │ │ ├── min_cost_climbing_stairs_dp.java │ │ │ ├── min_path_sum.java │ │ │ └── unbounded_knapsack.java │ │ ├── chapter_graph/ │ │ │ ├── graph_adjacency_list.java │ │ │ ├── graph_adjacency_matrix.java │ │ │ ├── graph_bfs.java │ │ │ └── graph_dfs.java │ │ ├── chapter_greedy/ │ │ │ ├── coin_change_greedy.java │ │ │ ├── fractional_knapsack.java │ │ │ ├── max_capacity.java │ │ │ └── max_product_cutting.java │ │ ├── chapter_hashing/ │ │ │ ├── array_hash_map.java │ │ │ ├── built_in_hash.java │ │ │ ├── hash_map.java │ │ │ ├── hash_map_chaining.java │ │ │ ├── hash_map_open_addressing.java │ │ │ └── simple_hash.java │ │ ├── chapter_heap/ │ │ │ ├── heap.java │ │ │ ├── my_heap.java │ │ │ └── top_k.java │ │ ├── chapter_searching/ │ │ │ ├── binary_search.java │ │ │ ├── binary_search_edge.java │ │ │ ├── binary_search_insertion.java │ │ │ ├── hashing_search.java │ │ │ ├── linear_search.java │ │ │ └── two_sum.java │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.java │ │ │ ├── bucket_sort.java │ │ │ ├── counting_sort.java │ │ │ ├── heap_sort.java │ │ │ ├── insertion_sort.java │ │ │ ├── merge_sort.java │ │ │ ├── quick_sort.java │ │ │ ├── radix_sort.java │ │ │ └── selection_sort.java │ │ ├── chapter_stack_and_queue/ │ │ │ ├── array_deque.java │ │ │ ├── array_queue.java │ │ │ ├── array_stack.java │ │ │ ├── deque.java │ │ │ ├── linkedlist_deque.java │ │ │ ├── linkedlist_queue.java │ │ │ ├── linkedlist_stack.java │ │ │ ├── queue.java │ │ │ └── stack.java │ │ ├── chapter_tree/ │ │ │ ├── array_binary_tree.java │ │ │ ├── avl_tree.java │ │ │ ├── binary_search_tree.java │ │ │ ├── binary_tree.java │ │ │ ├── binary_tree_bfs.java │ │ │ └── binary_tree_dfs.java │ │ └── utils/ │ │ ├── ListNode.java │ │ ├── PrintUtil.java │ │ ├── TreeNode.java │ │ └── Vertex.java │ ├── javascript/ │ │ ├── .prettierrc │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.js │ │ │ ├── linked_list.js │ │ │ ├── list.js │ │ │ └── my_list.js │ │ ├── chapter_backtracking/ │ │ │ ├── n_queens.js │ │ │ ├── permutations_i.js │ │ │ ├── permutations_ii.js │ │ │ ├── preorder_traversal_i_compact.js │ │ │ ├── preorder_traversal_ii_compact.js │ │ │ ├── preorder_traversal_iii_compact.js │ │ │ ├── preorder_traversal_iii_template.js │ │ │ ├── subset_sum_i.js │ │ │ ├── subset_sum_i_naive.js │ │ │ └── subset_sum_ii.js │ │ ├── chapter_computational_complexity/ │ │ │ ├── iteration.js │ │ │ ├── recursion.js │ │ │ ├── space_complexity.js │ │ │ ├── time_complexity.js │ │ │ └── worst_best_time_complexity.js │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── binary_search_recur.js │ │ │ ├── build_tree.js │ │ │ └── hanota.js │ │ ├── chapter_dynamic_programming/ │ │ │ ├── climbing_stairs_backtrack.js │ │ │ ├── climbing_stairs_constraint_dp.js │ │ │ ├── climbing_stairs_dfs.js │ │ │ ├── climbing_stairs_dfs_mem.js │ │ │ ├── climbing_stairs_dp.js │ │ │ ├── coin_change.js │ │ │ ├── coin_change_ii.js │ │ │ ├── edit_distance.js │ │ │ ├── knapsack.js │ │ │ ├── min_cost_climbing_stairs_dp.js │ │ │ ├── min_path_sum.js │ │ │ └── unbounded_knapsack.js │ │ ├── chapter_graph/ │ │ │ ├── graph_adjacency_list.js │ │ │ ├── graph_adjacency_matrix.js │ │ │ ├── graph_bfs.js │ │ │ └── graph_dfs.js │ │ ├── chapter_greedy/ │ │ │ ├── coin_change_greedy.js │ │ │ ├── fractional_knapsack.js │ │ │ ├── max_capacity.js │ │ │ └── max_product_cutting.js │ │ ├── chapter_hashing/ │ │ │ ├── array_hash_map.js │ │ │ ├── hash_map.js │ │ │ ├── hash_map_chaining.js │ │ │ ├── hash_map_open_addressing.js │ │ │ └── simple_hash.js │ │ ├── chapter_heap/ │ │ │ ├── my_heap.js │ │ │ └── top_k.js │ │ ├── chapter_searching/ │ │ │ ├── binary_search.js │ │ │ ├── binary_search_edge.js │ │ │ ├── binary_search_insertion.js │ │ │ ├── hashing_search.js │ │ │ ├── linear_search.js │ │ │ └── two_sum.js │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.js │ │ │ ├── bucket_sort.js │ │ │ ├── counting_sort.js │ │ │ ├── heap_sort.js │ │ │ ├── insertion_sort.js │ │ │ ├── merge_sort.js │ │ │ ├── quick_sort.js │ │ │ ├── radix_sort.js │ │ │ └── selection_sort.js │ │ ├── chapter_stack_and_queue/ │ │ │ ├── array_deque.js │ │ │ ├── array_queue.js │ │ │ ├── array_stack.js │ │ │ ├── deque.js │ │ │ ├── linkedlist_deque.js │ │ │ ├── linkedlist_queue.js │ │ │ ├── linkedlist_stack.js │ │ │ ├── queue.js │ │ │ └── stack.js │ │ ├── chapter_tree/ │ │ │ ├── array_binary_tree.js │ │ │ ├── avl_tree.js │ │ │ ├── binary_search_tree.js │ │ │ ├── binary_tree.js │ │ │ ├── binary_tree_bfs.js │ │ │ └── binary_tree_dfs.js │ │ ├── modules/ │ │ │ ├── ListNode.js │ │ │ ├── PrintUtil.js │ │ │ ├── TreeNode.js │ │ │ └── Vertex.js │ │ └── test_all.js │ ├── kotlin/ │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.kt │ │ │ ├── linked_list.kt │ │ │ ├── list.kt │ │ │ └── my_list.kt │ │ ├── chapter_backtracking/ │ │ │ ├── n_queens.kt │ │ │ ├── permutations_i.kt │ │ │ ├── permutations_ii.kt │ │ │ ├── preorder_traversal_i_compact.kt │ │ │ ├── preorder_traversal_ii_compact.kt │ │ │ ├── preorder_traversal_iii_compact.kt │ │ │ ├── preorder_traversal_iii_template.kt │ │ │ ├── subset_sum_i.kt │ │ │ ├── subset_sum_i_naive.kt │ │ │ └── subset_sum_ii.kt │ │ ├── chapter_computational_complexity/ │ │ │ ├── iteration.kt │ │ │ ├── recursion.kt │ │ │ ├── space_complexity.kt │ │ │ ├── time_complexity.kt │ │ │ └── worst_best_time_complexity.kt │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── binary_search_recur.kt │ │ │ ├── build_tree.kt │ │ │ └── hanota.kt │ │ ├── chapter_dynamic_programming/ │ │ │ ├── climbing_stairs_backtrack.kt │ │ │ ├── climbing_stairs_constraint_dp.kt │ │ │ ├── climbing_stairs_dfs.kt │ │ │ ├── climbing_stairs_dfs_mem.kt │ │ │ ├── climbing_stairs_dp.kt │ │ │ ├── coin_change.kt │ │ │ ├── coin_change_ii.kt │ │ │ ├── edit_distance.kt │ │ │ ├── knapsack.kt │ │ │ ├── min_cost_climbing_stairs_dp.kt │ │ │ ├── min_path_sum.kt │ │ │ └── unbounded_knapsack.kt │ │ ├── chapter_graph/ │ │ │ ├── graph_adjacency_list.kt │ │ │ ├── graph_adjacency_matrix.kt │ │ │ ├── graph_bfs.kt │ │ │ └── graph_dfs.kt │ │ ├── chapter_greedy/ │ │ │ ├── coin_change_greedy.kt │ │ │ ├── fractional_knapsack.kt │ │ │ ├── max_capacity.kt │ │ │ └── max_product_cutting.kt │ │ ├── chapter_hashing/ │ │ │ ├── array_hash_map.kt │ │ │ ├── built_in_hash.kt │ │ │ ├── hash_map.kt │ │ │ ├── hash_map_chaining.kt │ │ │ ├── hash_map_open_addressing.kt │ │ │ └── simple_hash.kt │ │ ├── chapter_heap/ │ │ │ ├── heap.kt │ │ │ ├── my_heap.kt │ │ │ └── top_k.kt │ │ ├── chapter_searching/ │ │ │ ├── binary_search.kt │ │ │ ├── binary_search_edge.kt │ │ │ ├── binary_search_insertion.kt │ │ │ ├── hashing_search.kt │ │ │ ├── linear_search.kt │ │ │ └── two_sum.kt │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.kt │ │ │ ├── bucket_sort.kt │ │ │ ├── counting_sort.kt │ │ │ ├── heap_sort.kt │ │ │ ├── insertion_sort.kt │ │ │ ├── merge_sort.kt │ │ │ ├── quick_sort.kt │ │ │ ├── radix_sort.kt │ │ │ └── selection_sort.kt │ │ ├── chapter_stack_and_queue/ │ │ │ ├── array_deque.kt │ │ │ ├── array_queue.kt │ │ │ ├── array_stack.kt │ │ │ ├── deque.kt │ │ │ ├── linkedlist_deque.kt │ │ │ ├── linkedlist_queue.kt │ │ │ ├── linkedlist_stack.kt │ │ │ ├── queue.kt │ │ │ └── stack.kt │ │ ├── chapter_tree/ │ │ │ ├── array_binary_tree.kt │ │ │ ├── avl_tree.kt │ │ │ ├── binary_search_tree.kt │ │ │ ├── binary_tree.kt │ │ │ ├── binary_tree_bfs.kt │ │ │ └── binary_tree_dfs.kt │ │ └── utils/ │ │ ├── ListNode.kt │ │ ├── PrintUtil.kt │ │ ├── TreeNode.kt │ │ └── Vertex.kt │ ├── python/ │ │ ├── .gitignore │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.py │ │ │ ├── linked_list.py │ │ │ ├── list.py │ │ │ └── my_list.py │ │ ├── chapter_backtracking/ │ │ │ ├── n_queens.py │ │ │ ├── permutations_i.py │ │ │ ├── permutations_ii.py │ │ │ ├── preorder_traversal_i_compact.py │ │ │ ├── preorder_traversal_ii_compact.py │ │ │ ├── preorder_traversal_iii_compact.py │ │ │ ├── preorder_traversal_iii_template.py │ │ │ ├── subset_sum_i.py │ │ │ ├── subset_sum_i_naive.py │ │ │ └── subset_sum_ii.py │ │ ├── chapter_computational_complexity/ │ │ │ ├── iteration.py │ │ │ ├── recursion.py │ │ │ ├── space_complexity.py │ │ │ ├── time_complexity.py │ │ │ └── worst_best_time_complexity.py │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── binary_search_recur.py │ │ │ ├── build_tree.py │ │ │ └── hanota.py │ │ ├── chapter_dynamic_programming/ │ │ │ ├── climbing_stairs_backtrack.py │ │ │ ├── climbing_stairs_constraint_dp.py │ │ │ ├── climbing_stairs_dfs.py │ │ │ ├── climbing_stairs_dfs_mem.py │ │ │ ├── climbing_stairs_dp.py │ │ │ ├── coin_change.py │ │ │ ├── coin_change_ii.py │ │ │ ├── edit_distance.py │ │ │ ├── knapsack.py │ │ │ ├── min_cost_climbing_stairs_dp.py │ │ │ ├── min_path_sum.py │ │ │ └── unbounded_knapsack.py │ │ ├── chapter_graph/ │ │ │ ├── graph_adjacency_list.py │ │ │ ├── graph_adjacency_matrix.py │ │ │ ├── graph_bfs.py │ │ │ └── graph_dfs.py │ │ ├── chapter_greedy/ │ │ │ ├── coin_change_greedy.py │ │ │ ├── fractional_knapsack.py │ │ │ ├── max_capacity.py │ │ │ └── max_product_cutting.py │ │ ├── chapter_hashing/ │ │ │ ├── array_hash_map.py │ │ │ ├── built_in_hash.py │ │ │ ├── hash_map.py │ │ │ ├── hash_map_chaining.py │ │ │ ├── hash_map_open_addressing.py │ │ │ └── simple_hash.py │ │ ├── chapter_heap/ │ │ │ ├── heap.py │ │ │ ├── my_heap.py │ │ │ └── top_k.py │ │ ├── chapter_searching/ │ │ │ ├── binary_search.py │ │ │ ├── binary_search_edge.py │ │ │ ├── binary_search_insertion.py │ │ │ ├── hashing_search.py │ │ │ ├── linear_search.py │ │ │ └── two_sum.py │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.py │ │ │ ├── bucket_sort.py │ │ │ ├── counting_sort.py │ │ │ ├── heap_sort.py │ │ │ ├── insertion_sort.py │ │ │ ├── merge_sort.py │ │ │ ├── quick_sort.py │ │ │ ├── radix_sort.py │ │ │ └── selection_sort.py │ │ ├── chapter_stack_and_queue/ │ │ │ ├── array_deque.py │ │ │ ├── array_queue.py │ │ │ ├── array_stack.py │ │ │ ├── deque.py │ │ │ ├── linkedlist_deque.py │ │ │ ├── linkedlist_queue.py │ │ │ ├── linkedlist_stack.py │ │ │ ├── queue.py │ │ │ └── stack.py │ │ ├── chapter_tree/ │ │ │ ├── array_binary_tree.py │ │ │ ├── avl_tree.py │ │ │ ├── binary_search_tree.py │ │ │ ├── binary_tree.py │ │ │ ├── binary_tree_bfs.py │ │ │ └── binary_tree_dfs.py │ │ ├── modules/ │ │ │ ├── __init__.py │ │ │ ├── list_node.py │ │ │ ├── print_util.py │ │ │ ├── tree_node.py │ │ │ └── vertex.py │ │ └── test_all.py │ ├── pythontutor/ │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.md │ │ │ ├── linked_list.md │ │ │ └── my_list.md │ │ ├── chapter_backtracking/ │ │ │ ├── n_queens.md │ │ │ ├── permutations_i.md │ │ │ ├── permutations_ii.md │ │ │ ├── preorder_traversal_i_compact.md │ │ │ ├── preorder_traversal_ii_compact.md │ │ │ ├── preorder_traversal_iii_compact.md │ │ │ ├── preorder_traversal_iii_template.md │ │ │ ├── subset_sum_i.md │ │ │ ├── subset_sum_i_naive.md │ │ │ └── subset_sum_ii.md │ │ ├── chapter_computational_complexity/ │ │ │ ├── iteration.md │ │ │ ├── recursion.md │ │ │ ├── space_complexity.md │ │ │ ├── time_complexity.md │ │ │ └── worst_best_time_complexity.md │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── binary_search_recur.md │ │ │ ├── build_tree.md │ │ │ └── hanota.md │ │ ├── chapter_dynamic_programming/ │ │ │ ├── climbing_stairs_backtrack.md │ │ │ ├── climbing_stairs_constraint_dp.md │ │ │ ├── climbing_stairs_dfs.md │ │ │ ├── climbing_stairs_dfs_mem.md │ │ │ ├── climbing_stairs_dp.md │ │ │ ├── coin_change.md │ │ │ ├── coin_change_ii.md │ │ │ ├── edit_distance.md │ │ │ ├── knapsack.md │ │ │ ├── min_cost_climbing_stairs_dp.md │ │ │ ├── min_path_sum.md │ │ │ └── unbounded_knapsack.md │ │ ├── chapter_graph/ │ │ │ ├── graph_adjacency_list.md │ │ │ ├── graph_adjacency_matrix.md │ │ │ ├── graph_bfs.md │ │ │ └── graph_dfs.md │ │ ├── chapter_greedy/ │ │ │ ├── coin_change_greedy.md │ │ │ ├── fractional_knapsack.md │ │ │ ├── max_capacity.md │ │ │ └── max_product_cutting.md │ │ ├── chapter_hashing/ │ │ │ ├── array_hash_map.md │ │ │ ├── hash_map_chaining.md │ │ │ └── simple_hash.md │ │ ├── chapter_heap/ │ │ │ ├── my_heap.md │ │ │ └── top_k.md │ │ ├── chapter_searching/ │ │ │ ├── binary_search.md │ │ │ ├── binary_search_edge.md │ │ │ ├── binary_search_insertion.md │ │ │ └── two_sum.md │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.md │ │ │ ├── bucket_sort.md │ │ │ ├── counting_sort.md │ │ │ ├── heap_sort.md │ │ │ ├── insertion_sort.md │ │ │ ├── merge_sort.md │ │ │ ├── quick_sort.md │ │ │ ├── radix_sort.md │ │ │ └── selection_sort.md │ │ ├── chapter_stack_and_queue/ │ │ │ ├── array_queue.md │ │ │ ├── array_stack.md │ │ │ ├── linkedlist_queue.md │ │ │ └── linkedlist_stack.md │ │ └── chapter_tree/ │ │ ├── array_binary_tree.md │ │ ├── binary_search_tree.md │ │ ├── binary_tree_bfs.md │ │ └── binary_tree_dfs.md │ ├── ruby/ │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.rb │ │ │ ├── linked_list.rb │ │ │ ├── list.rb │ │ │ └── my_list.rb │ │ ├── chapter_backtracking/ │ │ │ ├── n_queens.rb │ │ │ ├── permutations_i.rb │ │ │ ├── permutations_ii.rb │ │ │ ├── preorder_traversal_i_compact.rb │ │ │ ├── preorder_traversal_ii_compact.rb │ │ │ ├── preorder_traversal_iii_compact.rb │ │ │ ├── preorder_traversal_iii_template.rb │ │ │ ├── subset_sum_i.rb │ │ │ ├── subset_sum_i_naive.rb │ │ │ └── subset_sum_ii.rb │ │ ├── chapter_computational_complexity/ │ │ │ ├── iteration.rb │ │ │ ├── recursion.rb │ │ │ ├── space_complexity.rb │ │ │ ├── time_complexity.rb │ │ │ └── worst_best_time_complexity.rb │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── binary_search_recur.rb │ │ │ ├── build_tree.rb │ │ │ └── hanota.rb │ │ ├── chapter_dynamic_programming/ │ │ │ ├── climbing_stairs_backtrack.rb │ │ │ ├── climbing_stairs_constraint_dp.rb │ │ │ ├── climbing_stairs_dfs.rb │ │ │ ├── climbing_stairs_dfs_mem.rb │ │ │ ├── climbing_stairs_dp.rb │ │ │ ├── coin_change.rb │ │ │ ├── coin_change_ii.rb │ │ │ ├── edit_distance.rb │ │ │ ├── knapsack.rb │ │ │ ├── min_cost_climbing_stairs_dp.rb │ │ │ ├── min_path_sum.rb │ │ │ └── unbounded_knapsack.rb │ │ ├── chapter_graph/ │ │ │ ├── graph_adjacency_list.rb │ │ │ ├── graph_adjacency_matrix.rb │ │ │ ├── graph_bfs.rb │ │ │ └── graph_dfs.rb │ │ ├── chapter_greedy/ │ │ │ ├── coin_change_greedy.rb │ │ │ ├── fractional_knapsack.rb │ │ │ ├── max_capacity.rb │ │ │ └── max_product_cutting.rb │ │ ├── chapter_hashing/ │ │ │ ├── array_hash_map.rb │ │ │ ├── built_in_hash.rb │ │ │ ├── hash_map.rb │ │ │ ├── hash_map_chaining.rb │ │ │ ├── hash_map_open_addressing.rb │ │ │ └── simple_hash.rb │ │ ├── chapter_heap/ │ │ │ ├── my_heap.rb │ │ │ └── top_k.rb │ │ ├── chapter_searching/ │ │ │ ├── binary_search.rb │ │ │ ├── binary_search_edge.rb │ │ │ ├── binary_search_insertion.rb │ │ │ ├── hashing_search.rb │ │ │ ├── linear_search.rb │ │ │ └── two_sum.rb │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.rb │ │ │ ├── bucket_sort.rb │ │ │ ├── counting_sort.rb │ │ │ ├── heap_sort.rb │ │ │ ├── insertion_sort.rb │ │ │ ├── merge_sort.rb │ │ │ ├── quick_sort.rb │ │ │ ├── radix_sort.rb │ │ │ └── selection_sort.rb │ │ ├── chapter_stack_and_queue/ │ │ │ ├── array_deque.rb │ │ │ ├── array_queue.rb │ │ │ ├── array_stack.rb │ │ │ ├── deque.rb │ │ │ ├── linkedlist_deque.rb │ │ │ ├── linkedlist_queue.rb │ │ │ ├── linkedlist_stack.rb │ │ │ ├── queue.rb │ │ │ └── stack.rb │ │ ├── chapter_tree/ │ │ │ ├── array_binary_tree.rb │ │ │ ├── avl_tree.rb │ │ │ ├── binary_search_tree.rb │ │ │ ├── binary_tree.rb │ │ │ ├── binary_tree_bfs.rb │ │ │ └── binary_tree_dfs.rb │ │ ├── test_all.rb │ │ └── utils/ │ │ ├── list_node.rb │ │ ├── print_util.rb │ │ ├── tree_node.rb │ │ └── vertex.rb │ ├── rust/ │ │ ├── .gitignore │ │ ├── Cargo.toml │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.rs │ │ │ ├── linked_list.rs │ │ │ ├── list.rs │ │ │ └── my_list.rs │ │ ├── chapter_backtracking/ │ │ │ ├── n_queens.rs │ │ │ ├── permutations_i.rs │ │ │ ├── permutations_ii.rs │ │ │ ├── preorder_traversal_i_compact.rs │ │ │ ├── preorder_traversal_ii_compact.rs │ │ │ ├── preorder_traversal_iii_compact.rs │ │ │ ├── preorder_traversal_iii_template.rs │ │ │ ├── subset_sum_i.rs │ │ │ ├── subset_sum_i_naive.rs │ │ │ └── subset_sum_ii.rs │ │ ├── chapter_computational_complexity/ │ │ │ ├── iteration.rs │ │ │ ├── recursion.rs │ │ │ ├── space_complexity.rs │ │ │ ├── time_complexity.rs │ │ │ └── worst_best_time_complexity.rs │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── binary_search_recur.rs │ │ │ ├── build_tree.rs │ │ │ └── hanota.rs │ │ ├── chapter_dynamic_programming/ │ │ │ ├── climbing_stairs_backtrack.rs │ │ │ ├── climbing_stairs_constraint_dp.rs │ │ │ ├── climbing_stairs_dfs.rs │ │ │ ├── climbing_stairs_dfs_mem.rs │ │ │ ├── climbing_stairs_dp.rs │ │ │ ├── coin_change.rs │ │ │ ├── coin_change_ii.rs │ │ │ ├── edit_distance.rs │ │ │ ├── knapsack.rs │ │ │ ├── min_cost_climbing_stairs_dp.rs │ │ │ ├── min_path_sum.rs │ │ │ └── unbounded_knapsack.rs │ │ ├── chapter_graph/ │ │ │ ├── graph_adjacency_list.rs │ │ │ ├── graph_adjacency_matrix.rs │ │ │ ├── graph_bfs.rs │ │ │ └── graph_dfs.rs │ │ ├── chapter_greedy/ │ │ │ ├── coin_change_greedy.rs │ │ │ ├── fractional_knapsack.rs │ │ │ ├── max_capacity.rs │ │ │ └── max_product_cutting.rs │ │ ├── chapter_hashing/ │ │ │ ├── array_hash_map.rs │ │ │ ├── build_in_hash.rs │ │ │ ├── hash_map.rs │ │ │ ├── hash_map_chaining.rs │ │ │ ├── hash_map_open_addressing.rs │ │ │ └── simple_hash.rs │ │ ├── chapter_heap/ │ │ │ ├── heap.rs │ │ │ ├── my_heap.rs │ │ │ └── top_k.rs │ │ ├── chapter_searching/ │ │ │ ├── binary_search.rs │ │ │ ├── binary_search_edge.rs │ │ │ ├── binary_search_insertion.rs │ │ │ ├── hashing_search.rs │ │ │ ├── linear_search.rs │ │ │ └── two_sum.rs │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.rs │ │ │ ├── bucket_sort.rs │ │ │ ├── counting_sort.rs │ │ │ ├── heap_sort.rs │ │ │ ├── insertion_sort.rs │ │ │ ├── merge_sort.rs │ │ │ ├── quick_sort.rs │ │ │ ├── radix_sort.rs │ │ │ └── selection_sort.rs │ │ ├── chapter_stack_and_queue/ │ │ │ ├── array_deque.rs │ │ │ ├── array_queue.rs │ │ │ ├── array_stack.rs │ │ │ ├── deque.rs │ │ │ ├── linkedlist_deque.rs │ │ │ ├── linkedlist_queue.rs │ │ │ ├── linkedlist_stack.rs │ │ │ ├── queue.rs │ │ │ └── stack.rs │ │ ├── chapter_tree/ │ │ │ ├── array_binary_tree.rs │ │ │ ├── avl_tree.rs │ │ │ ├── binary_search_tree.rs │ │ │ ├── binary_tree.rs │ │ │ ├── binary_tree_bfs.rs │ │ │ └── binary_tree_dfs.rs │ │ └── src/ │ │ ├── include/ │ │ │ ├── list_node.rs │ │ │ ├── mod.rs │ │ │ ├── print_util.rs │ │ │ ├── tree_node.rs │ │ │ └── vertex.rs │ │ └── lib.rs │ ├── swift/ │ │ ├── .gitignore │ │ ├── Package.resolved │ │ ├── Package.swift │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.swift │ │ │ ├── linked_list.swift │ │ │ ├── list.swift │ │ │ └── my_list.swift │ │ ├── chapter_backtracking/ │ │ │ ├── n_queens.swift │ │ │ ├── permutations_i.swift │ │ │ ├── permutations_ii.swift │ │ │ ├── preorder_traversal_i_compact.swift │ │ │ ├── preorder_traversal_ii_compact.swift │ │ │ ├── preorder_traversal_iii_compact.swift │ │ │ ├── preorder_traversal_iii_template.swift │ │ │ ├── subset_sum_i.swift │ │ │ ├── subset_sum_i_naive.swift │ │ │ └── subset_sum_ii.swift │ │ ├── chapter_computational_complexity/ │ │ │ ├── iteration.swift │ │ │ ├── recursion.swift │ │ │ ├── space_complexity.swift │ │ │ ├── time_complexity.swift │ │ │ └── worst_best_time_complexity.swift │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── binary_search_recur.swift │ │ │ ├── build_tree.swift │ │ │ └── hanota.swift │ │ ├── chapter_dynamic_programming/ │ │ │ ├── climbing_stairs_backtrack.swift │ │ │ ├── climbing_stairs_constraint_dp.swift │ │ │ ├── climbing_stairs_dfs.swift │ │ │ ├── climbing_stairs_dfs_mem.swift │ │ │ ├── climbing_stairs_dp.swift │ │ │ ├── coin_change.swift │ │ │ ├── coin_change_ii.swift │ │ │ ├── edit_distance.swift │ │ │ ├── knapsack.swift │ │ │ ├── min_cost_climbing_stairs_dp.swift │ │ │ ├── min_path_sum.swift │ │ │ └── unbounded_knapsack.swift │ │ ├── chapter_graph/ │ │ │ ├── graph_adjacency_list.swift │ │ │ ├── graph_adjacency_matrix.swift │ │ │ ├── graph_bfs.swift │ │ │ └── graph_dfs.swift │ │ ├── chapter_greedy/ │ │ │ ├── coin_change_greedy.swift │ │ │ ├── fractional_knapsack.swift │ │ │ ├── max_capacity.swift │ │ │ └── max_product_cutting.swift │ │ ├── chapter_hashing/ │ │ │ ├── array_hash_map.swift │ │ │ ├── built_in_hash.swift │ │ │ ├── hash_map.swift │ │ │ ├── hash_map_chaining.swift │ │ │ ├── hash_map_open_addressing.swift │ │ │ └── simple_hash.swift │ │ ├── chapter_heap/ │ │ │ ├── heap.swift │ │ │ ├── my_heap.swift │ │ │ └── top_k.swift │ │ ├── chapter_searching/ │ │ │ ├── binary_search.swift │ │ │ ├── binary_search_edge.swift │ │ │ ├── binary_search_insertion.swift │ │ │ ├── hashing_search.swift │ │ │ ├── linear_search.swift │ │ │ └── two_sum.swift │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.swift │ │ │ ├── bucket_sort.swift │ │ │ ├── counting_sort.swift │ │ │ ├── heap_sort.swift │ │ │ ├── insertion_sort.swift │ │ │ ├── merge_sort.swift │ │ │ ├── quick_sort.swift │ │ │ ├── radix_sort.swift │ │ │ └── selection_sort.swift │ │ ├── chapter_stack_and_queue/ │ │ │ ├── array_deque.swift │ │ │ ├── array_queue.swift │ │ │ ├── array_stack.swift │ │ │ ├── deque.swift │ │ │ ├── linkedlist_deque.swift │ │ │ ├── linkedlist_queue.swift │ │ │ ├── linkedlist_stack.swift │ │ │ ├── queue.swift │ │ │ └── stack.swift │ │ ├── chapter_tree/ │ │ │ ├── array_binary_tree.swift │ │ │ ├── avl_tree.swift │ │ │ ├── binary_search_tree.swift │ │ │ ├── binary_tree.swift │ │ │ ├── binary_tree_bfs.swift │ │ │ └── binary_tree_dfs.swift │ │ └── utils/ │ │ ├── ListNode.swift │ │ ├── Pair.swift │ │ ├── PrintUtil.swift │ │ ├── TreeNode.swift │ │ └── Vertex.swift │ ├── typescript/ │ │ ├── .gitignore │ │ ├── .prettierrc │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.ts │ │ │ ├── linked_list.ts │ │ │ ├── list.ts │ │ │ └── my_list.ts │ │ ├── chapter_backtracking/ │ │ │ ├── n_queens.ts │ │ │ ├── permutations_i.ts │ │ │ ├── permutations_ii.ts │ │ │ ├── preorder_traversal_i_compact.ts │ │ │ ├── preorder_traversal_ii_compact.ts │ │ │ ├── preorder_traversal_iii_compact.ts │ │ │ ├── preorder_traversal_iii_template.ts │ │ │ ├── subset_sum_i.ts │ │ │ ├── subset_sum_i_naive.ts │ │ │ └── subset_sum_ii.ts │ │ ├── chapter_computational_complexity/ │ │ │ ├── iteration.ts │ │ │ ├── recursion.ts │ │ │ ├── space_complexity.ts │ │ │ ├── time_complexity.ts │ │ │ └── worst_best_time_complexity.ts │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── binary_search_recur.ts │ │ │ ├── build_tree.ts │ │ │ └── hanota.ts │ │ ├── chapter_dynamic_programming/ │ │ │ ├── climbing_stairs_backtrack.ts │ │ │ ├── climbing_stairs_constraint_dp.ts │ │ │ ├── climbing_stairs_dfs.ts │ │ │ ├── climbing_stairs_dfs_mem.ts │ │ │ ├── climbing_stairs_dp.ts │ │ │ ├── coin_change.ts │ │ │ ├── coin_change_ii.ts │ │ │ ├── edit_distance.ts │ │ │ ├── knapsack.ts │ │ │ ├── min_cost_climbing_stairs_dp.ts │ │ │ ├── min_path_sum.ts │ │ │ └── unbounded_knapsack.ts │ │ ├── chapter_graph/ │ │ │ ├── graph_adjacency_list.ts │ │ │ ├── graph_adjacency_matrix.ts │ │ │ ├── graph_bfs.ts │ │ │ └── graph_dfs.ts │ │ ├── chapter_greedy/ │ │ │ ├── coin_change_greedy.ts │ │ │ ├── fractional_knapsack.ts │ │ │ ├── max_capacity.ts │ │ │ └── max_product_cutting.ts │ │ ├── chapter_hashing/ │ │ │ ├── array_hash_map.ts │ │ │ ├── hash_map.ts │ │ │ ├── hash_map_chaining.ts │ │ │ ├── hash_map_open_addressing.ts │ │ │ └── simple_hash.ts │ │ ├── chapter_heap/ │ │ │ ├── my_heap.ts │ │ │ └── top_k.ts │ │ ├── chapter_searching/ │ │ │ ├── binary_search.ts │ │ │ ├── binary_search_edge.ts │ │ │ ├── binary_search_insertion.ts │ │ │ ├── hashing_search.ts │ │ │ ├── linear_search.ts │ │ │ └── two_sum.ts │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.ts │ │ │ ├── bucket_sort.ts │ │ │ ├── counting_sort.ts │ │ │ ├── heap_sort.ts │ │ │ ├── insertion_sort.ts │ │ │ ├── merge_sort.ts │ │ │ ├── quick_sort.ts │ │ │ ├── radix_sort.ts │ │ │ └── selection_sort.ts │ │ ├── chapter_stack_and_queue/ │ │ │ ├── array_deque.ts │ │ │ ├── array_queue.ts │ │ │ ├── array_stack.ts │ │ │ ├── deque.ts │ │ │ ├── linkedlist_deque.ts │ │ │ ├── linkedlist_queue.ts │ │ │ ├── linkedlist_stack.ts │ │ │ ├── queue.ts │ │ │ └── stack.ts │ │ ├── chapter_tree/ │ │ │ ├── array_binary_tree.ts │ │ │ ├── avl_tree.ts │ │ │ ├── binary_search_tree.ts │ │ │ ├── binary_tree.ts │ │ │ ├── binary_tree_bfs.ts │ │ │ └── binary_tree_dfs.ts │ │ ├── modules/ │ │ │ ├── ListNode.ts │ │ │ ├── PrintUtil.ts │ │ │ ├── TreeNode.ts │ │ │ └── Vertex.ts │ │ ├── package.json │ │ └── tsconfig.json │ └── zig/ │ ├── .gitignore │ ├── build.zig │ ├── chapter_array_and_linkedlist/ │ │ ├── array.zig │ │ ├── linked_list.zig │ │ ├── list.zig │ │ └── my_list.zig │ ├── chapter_computational_complexity/ │ │ ├── iteration.zig │ │ ├── recursion.zig │ │ ├── space_complexity.zig │ │ ├── time_complexity.zig │ │ └── worst_best_time_complexity.zig │ ├── chapter_dynamic_programming/ │ │ ├── climbing_stairs_backtrack.zig │ │ ├── climbing_stairs_constraint_dp.zig │ │ ├── climbing_stairs_dfs.zig │ │ ├── climbing_stairs_dfs_mem.zig │ │ ├── climbing_stairs_dp.zig │ │ ├── coin_change.zig │ │ ├── coin_change_ii.zig │ │ ├── edit_distance.zig │ │ ├── knapsack.zig │ │ ├── min_cost_climbing_stairs_dp.zig │ │ ├── min_path_sum.zig │ │ └── unbounded_knapsack.zig │ ├── chapter_hashing/ │ │ ├── array_hash_map.zig │ │ └── hash_map.zig │ ├── chapter_heap/ │ │ ├── heap.zig │ │ └── my_heap.zig │ ├── chapter_searching/ │ │ ├── binary_search.zig │ │ ├── hashing_search.zig │ │ ├── linear_search.zig │ │ └── two_sum.zig │ ├── chapter_sorting/ │ │ ├── bubble_sort.zig │ │ ├── insertion_sort.zig │ │ ├── merge_sort.zig │ │ ├── quick_sort.zig │ │ └── radix_sort.zig │ ├── chapter_stack_and_queue/ │ │ ├── array_queue.zig │ │ ├── array_stack.zig │ │ ├── deque.zig │ │ ├── linkedlist_deque.zig │ │ ├── linkedlist_queue.zig │ │ ├── linkedlist_stack.zig │ │ ├── queue.zig │ │ └── stack.zig │ ├── chapter_tree/ │ │ ├── avl_tree.zig │ │ ├── binary_search_tree.zig │ │ ├── binary_tree.zig │ │ ├── binary_tree_bfs.zig │ │ └── binary_tree_dfs.zig │ ├── include/ │ │ ├── PrintUtil.zig │ │ └── include.zig │ ├── main.zig │ └── utils/ │ ├── ListNode.zig │ ├── TreeNode.zig │ ├── format.zig │ └── utils.zig ├── docker-compose.yml ├── docs/ │ ├── chapter_appendix/ │ │ ├── contribution.md │ │ ├── index.md │ │ ├── installation.md │ │ └── terminology.md │ ├── chapter_array_and_linkedlist/ │ │ ├── array.md │ │ ├── index.md │ │ ├── linked_list.md │ │ ├── list.md │ │ ├── ram_and_cache.md │ │ └── summary.md │ ├── chapter_backtracking/ │ │ ├── backtracking_algorithm.md │ │ ├── index.md │ │ ├── n_queens_problem.md │ │ ├── permutations_problem.md │ │ ├── subset_sum_problem.md │ │ └── summary.md │ ├── chapter_computational_complexity/ │ │ ├── index.md │ │ ├── iteration_and_recursion.md │ │ ├── performance_evaluation.md │ │ ├── space_complexity.md │ │ ├── summary.md │ │ └── time_complexity.md │ ├── chapter_data_structure/ │ │ ├── basic_data_types.md │ │ ├── character_encoding.md │ │ ├── classification_of_data_structure.md │ │ ├── index.md │ │ ├── number_encoding.md │ │ └── summary.md │ ├── chapter_divide_and_conquer/ │ │ ├── binary_search_recur.md │ │ ├── build_binary_tree_problem.md │ │ ├── divide_and_conquer.md │ │ ├── hanota_problem.md │ │ ├── index.md │ │ └── summary.md │ ├── chapter_dynamic_programming/ │ │ ├── dp_problem_features.md │ │ ├── dp_solution_pipeline.md │ │ ├── edit_distance_problem.md │ │ ├── index.md │ │ ├── intro_to_dynamic_programming.md │ │ ├── knapsack_problem.md │ │ ├── summary.md │ │ └── unbounded_knapsack_problem.md │ ├── chapter_graph/ │ │ ├── graph.md │ │ ├── graph_operations.md │ │ ├── graph_traversal.md │ │ ├── index.md │ │ └── summary.md │ ├── chapter_greedy/ │ │ ├── fractional_knapsack_problem.md │ │ ├── greedy_algorithm.md │ │ ├── index.md │ │ ├── max_capacity_problem.md │ │ ├── max_product_cutting_problem.md │ │ └── summary.md │ ├── chapter_hashing/ │ │ ├── hash_algorithm.md │ │ ├── hash_collision.md │ │ ├── hash_map.md │ │ ├── index.md │ │ └── summary.md │ ├── chapter_heap/ │ │ ├── build_heap.md │ │ ├── heap.md │ │ ├── index.md │ │ ├── summary.md │ │ └── top_k.md │ ├── chapter_hello_algo/ │ │ └── index.md │ ├── chapter_introduction/ │ │ ├── algorithms_are_everywhere.md │ │ ├── index.md │ │ ├── summary.md │ │ └── what_is_dsa.md │ ├── chapter_paperbook/ │ │ └── index.md │ ├── chapter_preface/ │ │ ├── about_the_book.md │ │ ├── index.md │ │ ├── suggestions.md │ │ └── summary.md │ ├── chapter_reference/ │ │ └── index.md │ ├── chapter_searching/ │ │ ├── binary_search.md │ │ ├── binary_search_edge.md │ │ ├── binary_search_insertion.md │ │ ├── index.md │ │ ├── replace_linear_by_hashing.md │ │ ├── searching_algorithm_revisited.md │ │ └── summary.md │ ├── chapter_sorting/ │ │ ├── bubble_sort.md │ │ ├── bucket_sort.md │ │ ├── counting_sort.md │ │ ├── heap_sort.md │ │ ├── index.md │ │ ├── insertion_sort.md │ │ ├── merge_sort.md │ │ ├── quick_sort.md │ │ ├── radix_sort.md │ │ ├── selection_sort.md │ │ ├── sorting_algorithm.md │ │ └── summary.md │ ├── chapter_stack_and_queue/ │ │ ├── deque.md │ │ ├── index.md │ │ ├── queue.md │ │ ├── stack.md │ │ └── summary.md │ ├── chapter_tree/ │ │ ├── array_representation_of_tree.md │ │ ├── avl_tree.md │ │ ├── binary_search_tree.md │ │ ├── binary_tree.md │ │ ├── binary_tree_traversal.md │ │ ├── index.md │ │ └── summary.md │ ├── index.html │ └── index.md ├── en/ │ ├── CONTRIBUTING.md │ ├── README.md │ ├── codes/ │ │ ├── c/ │ │ │ ├── .gitignore │ │ │ ├── CMakeLists.txt │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array.c │ │ │ │ ├── linked_list.c │ │ │ │ └── my_list.c │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── n_queens.c │ │ │ │ ├── permutations_i.c │ │ │ │ ├── permutations_ii.c │ │ │ │ ├── preorder_traversal_i_compact.c │ │ │ │ ├── preorder_traversal_ii_compact.c │ │ │ │ ├── preorder_traversal_iii_compact.c │ │ │ │ ├── preorder_traversal_iii_template.c │ │ │ │ ├── subset_sum_i.c │ │ │ │ ├── subset_sum_i_naive.c │ │ │ │ └── subset_sum_ii.c │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── iteration.c │ │ │ │ ├── recursion.c │ │ │ │ ├── space_complexity.c │ │ │ │ ├── time_complexity.c │ │ │ │ └── worst_best_time_complexity.c │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── binary_search_recur.c │ │ │ │ ├── build_tree.c │ │ │ │ └── hanota.c │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── climbing_stairs_backtrack.c │ │ │ │ ├── climbing_stairs_constraint_dp.c │ │ │ │ ├── climbing_stairs_dfs.c │ │ │ │ ├── climbing_stairs_dfs_mem.c │ │ │ │ ├── climbing_stairs_dp.c │ │ │ │ ├── coin_change.c │ │ │ │ ├── coin_change_ii.c │ │ │ │ ├── edit_distance.c │ │ │ │ ├── knapsack.c │ │ │ │ ├── min_cost_climbing_stairs_dp.c │ │ │ │ ├── min_path_sum.c │ │ │ │ └── unbounded_knapsack.c │ │ │ ├── chapter_graph/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── graph_adjacency_list.c │ │ │ │ ├── graph_adjacency_list_test.c │ │ │ │ ├── graph_adjacency_matrix.c │ │ │ │ ├── graph_bfs.c │ │ │ │ └── graph_dfs.c │ │ │ ├── chapter_greedy/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── coin_change_greedy.c │ │ │ │ ├── fractional_knapsack.c │ │ │ │ ├── max_capacity.c │ │ │ │ └── max_product_cutting.c │ │ │ ├── chapter_hashing/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_hash_map.c │ │ │ │ ├── hash_map_chaining.c │ │ │ │ ├── hash_map_open_addressing.c │ │ │ │ └── simple_hash.c │ │ │ ├── chapter_heap/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── my_heap.c │ │ │ │ ├── my_heap_test.c │ │ │ │ └── top_k.c │ │ │ ├── chapter_searching/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── binary_search.c │ │ │ │ ├── binary_search_edge.c │ │ │ │ ├── binary_search_insertion.c │ │ │ │ └── two_sum.c │ │ │ ├── chapter_sorting/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── bubble_sort.c │ │ │ │ ├── bucket_sort.c │ │ │ │ ├── counting_sort.c │ │ │ │ ├── heap_sort.c │ │ │ │ ├── insertion_sort.c │ │ │ │ ├── merge_sort.c │ │ │ │ ├── quick_sort.c │ │ │ │ ├── radix_sort.c │ │ │ │ └── selection_sort.c │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_deque.c │ │ │ │ ├── array_queue.c │ │ │ │ ├── array_stack.c │ │ │ │ ├── linkedlist_deque.c │ │ │ │ ├── linkedlist_queue.c │ │ │ │ └── linkedlist_stack.c │ │ │ ├── chapter_tree/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_binary_tree.c │ │ │ │ ├── avl_tree.c │ │ │ │ ├── binary_search_tree.c │ │ │ │ ├── binary_tree.c │ │ │ │ ├── binary_tree_bfs.c │ │ │ │ └── binary_tree_dfs.c │ │ │ └── utils/ │ │ │ ├── CMakeLists.txt │ │ │ ├── common.h │ │ │ ├── common_test.c │ │ │ ├── list_node.h │ │ │ ├── print_util.h │ │ │ ├── tree_node.h │ │ │ ├── uthash.h │ │ │ ├── vector.h │ │ │ └── vertex.h │ │ ├── cpp/ │ │ │ ├── .gitignore │ │ │ ├── CMakeLists.txt │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array.cpp │ │ │ │ ├── linked_list.cpp │ │ │ │ ├── list.cpp │ │ │ │ └── my_list.cpp │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── n_queens.cpp │ │ │ │ ├── permutations_i.cpp │ │ │ │ ├── permutations_ii.cpp │ │ │ │ ├── preorder_traversal_i_compact.cpp │ │ │ │ ├── preorder_traversal_ii_compact.cpp │ │ │ │ ├── preorder_traversal_iii_compact.cpp │ │ │ │ ├── preorder_traversal_iii_template.cpp │ │ │ │ ├── subset_sum_i.cpp │ │ │ │ ├── subset_sum_i_naive.cpp │ │ │ │ └── subset_sum_ii.cpp │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── iteration.cpp │ │ │ │ ├── recursion.cpp │ │ │ │ ├── space_complexity.cpp │ │ │ │ ├── time_complexity.cpp │ │ │ │ └── worst_best_time_complexity.cpp │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── binary_search_recur.cpp │ │ │ │ ├── build_tree.cpp │ │ │ │ └── hanota.cpp │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── climbing_stairs_backtrack.cpp │ │ │ │ ├── climbing_stairs_constraint_dp.cpp │ │ │ │ ├── climbing_stairs_dfs.cpp │ │ │ │ ├── climbing_stairs_dfs_mem.cpp │ │ │ │ ├── climbing_stairs_dp.cpp │ │ │ │ ├── coin_change.cpp │ │ │ │ ├── coin_change_ii.cpp │ │ │ │ ├── edit_distance.cpp │ │ │ │ ├── knapsack.cpp │ │ │ │ ├── min_cost_climbing_stairs_dp.cpp │ │ │ │ ├── min_path_sum.cpp │ │ │ │ └── unbounded_knapsack.cpp │ │ │ ├── chapter_graph/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── graph_adjacency_list.cpp │ │ │ │ ├── graph_adjacency_list_test.cpp │ │ │ │ ├── graph_adjacency_matrix.cpp │ │ │ │ ├── graph_bfs.cpp │ │ │ │ └── graph_dfs.cpp │ │ │ ├── chapter_greedy/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── coin_change_greedy.cpp │ │ │ │ ├── fractional_knapsack.cpp │ │ │ │ ├── max_capacity.cpp │ │ │ │ └── max_product_cutting.cpp │ │ │ ├── chapter_hashing/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_hash_map.cpp │ │ │ │ ├── array_hash_map_test.cpp │ │ │ │ ├── built_in_hash.cpp │ │ │ │ ├── hash_map.cpp │ │ │ │ ├── hash_map_chaining.cpp │ │ │ │ ├── hash_map_open_addressing.cpp │ │ │ │ └── simple_hash.cpp │ │ │ ├── chapter_heap/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── heap.cpp │ │ │ │ ├── my_heap.cpp │ │ │ │ └── top_k.cpp │ │ │ ├── chapter_searching/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── binary_search.cpp │ │ │ │ ├── binary_search_edge.cpp │ │ │ │ ├── binary_search_insertion.cpp │ │ │ │ ├── hashing_search.cpp │ │ │ │ ├── linear_search.cpp │ │ │ │ └── two_sum.cpp │ │ │ ├── chapter_sorting/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── bubble_sort.cpp │ │ │ │ ├── bucket_sort.cpp │ │ │ │ ├── counting_sort.cpp │ │ │ │ ├── heap_sort.cpp │ │ │ │ ├── insertion_sort.cpp │ │ │ │ ├── merge_sort.cpp │ │ │ │ ├── quick_sort.cpp │ │ │ │ ├── radix_sort.cpp │ │ │ │ └── selection_sort.cpp │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_deque.cpp │ │ │ │ ├── array_queue.cpp │ │ │ │ ├── array_stack.cpp │ │ │ │ ├── deque.cpp │ │ │ │ ├── linkedlist_deque.cpp │ │ │ │ ├── linkedlist_queue.cpp │ │ │ │ ├── linkedlist_stack.cpp │ │ │ │ ├── queue.cpp │ │ │ │ └── stack.cpp │ │ │ ├── chapter_tree/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_binary_tree.cpp │ │ │ │ ├── avl_tree.cpp │ │ │ │ ├── binary_search_tree.cpp │ │ │ │ ├── binary_tree.cpp │ │ │ │ ├── binary_tree_bfs.cpp │ │ │ │ └── binary_tree_dfs.cpp │ │ │ └── utils/ │ │ │ ├── CMakeLists.txt │ │ │ ├── common.hpp │ │ │ ├── list_node.hpp │ │ │ ├── print_utils.hpp │ │ │ ├── tree_node.hpp │ │ │ └── vertex.hpp │ │ ├── csharp/ │ │ │ ├── .editorconfig │ │ │ ├── .gitignore │ │ │ ├── GlobalUsing.cs │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.cs │ │ │ │ ├── linked_list.cs │ │ │ │ ├── list.cs │ │ │ │ └── my_list.cs │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.cs │ │ │ │ ├── permutations_i.cs │ │ │ │ ├── permutations_ii.cs │ │ │ │ ├── preorder_traversal_i_compact.cs │ │ │ │ ├── preorder_traversal_ii_compact.cs │ │ │ │ ├── preorder_traversal_iii_compact.cs │ │ │ │ ├── preorder_traversal_iii_template.cs │ │ │ │ ├── subset_sum_i.cs │ │ │ │ ├── subset_sum_i_naive.cs │ │ │ │ └── subset_sum_ii.cs │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.cs │ │ │ │ ├── recursion.cs │ │ │ │ ├── space_complexity.cs │ │ │ │ ├── time_complexity.cs │ │ │ │ └── worst_best_time_complexity.cs │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.cs │ │ │ │ ├── build_tree.cs │ │ │ │ └── hanota.cs │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.cs │ │ │ │ ├── climbing_stairs_constraint_dp.cs │ │ │ │ ├── climbing_stairs_dfs.cs │ │ │ │ ├── climbing_stairs_dfs_mem.cs │ │ │ │ ├── climbing_stairs_dp.cs │ │ │ │ ├── coin_change.cs │ │ │ │ ├── coin_change_ii.cs │ │ │ │ ├── edit_distance.cs │ │ │ │ ├── knapsack.cs │ │ │ │ ├── min_cost_climbing_stairs_dp.cs │ │ │ │ ├── min_path_sum.cs │ │ │ │ └── unbounded_knapsack.cs │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.cs │ │ │ │ ├── graph_adjacency_matrix.cs │ │ │ │ ├── graph_bfs.cs │ │ │ │ └── graph_dfs.cs │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.cs │ │ │ │ ├── fractional_knapsack.cs │ │ │ │ ├── max_capacity.cs │ │ │ │ └── max_product_cutting.cs │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.cs │ │ │ │ ├── built_in_hash.cs │ │ │ │ ├── hash_map.cs │ │ │ │ ├── hash_map_chaining.cs │ │ │ │ ├── hash_map_open_addressing.cs │ │ │ │ └── simple_hash.cs │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.cs │ │ │ │ ├── my_heap.cs │ │ │ │ └── top_k.cs │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.cs │ │ │ │ ├── binary_search_edge.cs │ │ │ │ ├── binary_search_insertion.cs │ │ │ │ ├── hashing_search.cs │ │ │ │ ├── linear_search.cs │ │ │ │ └── two_sum.cs │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.cs │ │ │ │ ├── bucket_sort.cs │ │ │ │ ├── counting_sort.cs │ │ │ │ ├── heap_sort.cs │ │ │ │ ├── insertion_sort.cs │ │ │ │ ├── merge_sort.cs │ │ │ │ ├── quick_sort.cs │ │ │ │ ├── radix_sort.cs │ │ │ │ └── selection_sort.cs │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.cs │ │ │ │ ├── array_queue.cs │ │ │ │ ├── array_stack.cs │ │ │ │ ├── deque.cs │ │ │ │ ├── linkedlist_deque.cs │ │ │ │ ├── linkedlist_queue.cs │ │ │ │ ├── linkedlist_stack.cs │ │ │ │ ├── queue.cs │ │ │ │ └── stack.cs │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.cs │ │ │ │ ├── avl_tree.cs │ │ │ │ ├── binary_search_tree.cs │ │ │ │ ├── binary_tree.cs │ │ │ │ ├── binary_tree_bfs.cs │ │ │ │ └── binary_tree_dfs.cs │ │ │ ├── csharp.sln │ │ │ ├── hello-algo.csproj │ │ │ └── utils/ │ │ │ ├── ListNode.cs │ │ │ ├── PrintUtil.cs │ │ │ ├── TreeNode.cs │ │ │ └── Vertex.cs │ │ ├── dart/ │ │ │ ├── build.dart │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.dart │ │ │ │ ├── linked_list.dart │ │ │ │ ├── list.dart │ │ │ │ └── my_list.dart │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.dart │ │ │ │ ├── permutations_i.dart │ │ │ │ ├── permutations_ii.dart │ │ │ │ ├── preorder_traversal_i_compact.dart │ │ │ │ ├── preorder_traversal_ii_compact.dart │ │ │ │ ├── preorder_traversal_iii_compact.dart │ │ │ │ ├── preorder_traversal_iii_template.dart │ │ │ │ ├── subset_sum_i.dart │ │ │ │ ├── subset_sum_i_naive.dart │ │ │ │ └── subset_sum_ii.dart │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.dart │ │ │ │ ├── recursion.dart │ │ │ │ ├── space_complexity.dart │ │ │ │ ├── time_complexity.dart │ │ │ │ └── worst_best_time_complexity.dart │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.dart │ │ │ │ ├── build_tree.dart │ │ │ │ └── hanota.dart │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.dart │ │ │ │ ├── climbing_stairs_constraint_dp.dart │ │ │ │ ├── climbing_stairs_dfs.dart │ │ │ │ ├── climbing_stairs_dfs_mem.dart │ │ │ │ ├── climbing_stairs_dp.dart │ │ │ │ ├── coin_change.dart │ │ │ │ ├── coin_change_ii.dart │ │ │ │ ├── edit_distance.dart │ │ │ │ ├── knapsack.dart │ │ │ │ ├── min_cost_climbing_stairs_dp.dart │ │ │ │ ├── min_path_sum.dart │ │ │ │ └── unbounded_knapsack.dart │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.dart │ │ │ │ ├── graph_adjacency_matrix.dart │ │ │ │ ├── graph_bfs.dart │ │ │ │ └── graph_dfs.dart │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.dart │ │ │ │ ├── fractional_knapsack.dart │ │ │ │ ├── max_capacity.dart │ │ │ │ └── max_product_cutting.dart │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.dart │ │ │ │ ├── built_in_hash.dart │ │ │ │ ├── hash_map.dart │ │ │ │ ├── hash_map_chaining.dart │ │ │ │ ├── hash_map_open_addressing.dart │ │ │ │ └── simple_hash.dart │ │ │ ├── chapter_heap/ │ │ │ │ ├── my_heap.dart │ │ │ │ └── top_k.dart │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.dart │ │ │ │ ├── binary_search_edge.dart │ │ │ │ ├── binary_search_insertion.dart │ │ │ │ ├── hashing_search.dart │ │ │ │ ├── linear_search.dart │ │ │ │ └── two_sum.dart │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.dart │ │ │ │ ├── bucket_sort.dart │ │ │ │ ├── counting_sort.dart │ │ │ │ ├── heap_sort.dart │ │ │ │ ├── insertion_sort.dart │ │ │ │ ├── merge_sort.dart │ │ │ │ ├── quick_sort.dart │ │ │ │ ├── radix_sort.dart │ │ │ │ └── selection_sort.dart │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.dart │ │ │ │ ├── array_queue.dart │ │ │ │ ├── array_stack.dart │ │ │ │ ├── deque.dart │ │ │ │ ├── linkedlist_deque.dart │ │ │ │ ├── linkedlist_queue.dart │ │ │ │ ├── linkedlist_stack.dart │ │ │ │ ├── queue.dart │ │ │ │ └── stack.dart │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.dart │ │ │ │ ├── avl_tree.dart │ │ │ │ ├── binary_search_tree.dart │ │ │ │ ├── binary_tree.dart │ │ │ │ ├── binary_tree_bfs.dart │ │ │ │ └── binary_tree_dfs.dart │ │ │ └── utils/ │ │ │ ├── list_node.dart │ │ │ ├── print_util.dart │ │ │ ├── tree_node.dart │ │ │ └── vertex.dart │ │ ├── go/ │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.go │ │ │ │ ├── array_test.go │ │ │ │ ├── linked_list.go │ │ │ │ ├── linked_list_test.go │ │ │ │ ├── list_test.go │ │ │ │ ├── my_list.go │ │ │ │ └── my_list_test.go │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.go │ │ │ │ ├── n_queens_test.go │ │ │ │ ├── permutation_test.go │ │ │ │ ├── permutations_i.go │ │ │ │ ├── permutations_ii.go │ │ │ │ ├── preorder_traversal_i_compact.go │ │ │ │ ├── preorder_traversal_ii_compact.go │ │ │ │ ├── preorder_traversal_iii_compact.go │ │ │ │ ├── preorder_traversal_iii_template.go │ │ │ │ ├── preorder_traversal_test.go │ │ │ │ ├── subset_sum_i.go │ │ │ │ ├── subset_sum_i_naive.go │ │ │ │ ├── subset_sum_ii.go │ │ │ │ └── subset_sum_test.go │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.go │ │ │ │ ├── iteration_test.go │ │ │ │ ├── recursion.go │ │ │ │ ├── recursion_test.go │ │ │ │ ├── space_complexity.go │ │ │ │ ├── space_complexity_test.go │ │ │ │ ├── time_complexity.go │ │ │ │ ├── time_complexity_test.go │ │ │ │ ├── worst_best_time_complexity.go │ │ │ │ └── worst_best_time_complexity_test.go │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.go │ │ │ │ ├── binary_search_recur_test.go │ │ │ │ ├── build_tree.go │ │ │ │ ├── build_tree_test.go │ │ │ │ ├── hanota.go │ │ │ │ └── hanota_test.go │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.go │ │ │ │ ├── climbing_stairs_constraint_dp.go │ │ │ │ ├── climbing_stairs_dfs.go │ │ │ │ ├── climbing_stairs_dfs_mem.go │ │ │ │ ├── climbing_stairs_dp.go │ │ │ │ ├── climbing_stairs_test.go │ │ │ │ ├── coin_change.go │ │ │ │ ├── coin_change_ii.go │ │ │ │ ├── coin_change_test.go │ │ │ │ ├── edit_distance.go │ │ │ │ ├── edit_distance_test.go │ │ │ │ ├── knapsack.go │ │ │ │ ├── knapsack_test.go │ │ │ │ ├── min_cost_climbing_stairs_dp.go │ │ │ │ ├── min_path_sum.go │ │ │ │ ├── min_path_sum_test.go │ │ │ │ └── unbounded_knapsack.go │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.go │ │ │ │ ├── graph_adjacency_list_test.go │ │ │ │ ├── graph_adjacency_matrix.go │ │ │ │ ├── graph_adjacency_matrix_test.go │ │ │ │ ├── graph_bfs.go │ │ │ │ ├── graph_bfs_test.go │ │ │ │ ├── graph_dfs.go │ │ │ │ └── graph_dfs_test.go │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.go │ │ │ │ ├── coin_change_greedy_test.go │ │ │ │ ├── fractional_knapsack.go │ │ │ │ ├── fractional_knapsack_test.go │ │ │ │ ├── max_capacity.go │ │ │ │ ├── max_capacity_test.go │ │ │ │ ├── max_product_cutting.go │ │ │ │ └── max_product_cutting_test.go │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.go │ │ │ │ ├── array_hash_map_test.go │ │ │ │ ├── hash_collision_test.go │ │ │ │ ├── hash_map_chaining.go │ │ │ │ ├── hash_map_open_addressing.go │ │ │ │ ├── hash_map_test.go │ │ │ │ └── simple_hash.go │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.go │ │ │ │ ├── heap_test.go │ │ │ │ ├── my_heap.go │ │ │ │ └── top_k.go │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.go │ │ │ │ ├── binary_search_edge.go │ │ │ │ ├── binary_search_insertion.go │ │ │ │ ├── binary_search_test.go │ │ │ │ ├── hashing_search.go │ │ │ │ ├── hashing_search_test.go │ │ │ │ ├── linear_search.go │ │ │ │ ├── linear_search_test.go │ │ │ │ ├── two_sum.go │ │ │ │ └── two_sum_test.go │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.go │ │ │ │ ├── bubble_sort_test.go │ │ │ │ ├── bucket_sort.go │ │ │ │ ├── bucket_sort_test.go │ │ │ │ ├── counting_sort.go │ │ │ │ ├── counting_sort_test.go │ │ │ │ ├── heap_sort.go │ │ │ │ ├── heap_sort_test.go │ │ │ │ ├── insertion_sort.go │ │ │ │ ├── insertion_sort_test.go │ │ │ │ ├── merge_sort.go │ │ │ │ ├── merge_sort_test.go │ │ │ │ ├── quick_sort.go │ │ │ │ ├── quick_sort_test.go │ │ │ │ ├── radix_sort.go │ │ │ │ ├── radix_sort_test.go │ │ │ │ ├── selection_sort.go │ │ │ │ └── selection_sort_test.go │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.go │ │ │ │ ├── array_queue.go │ │ │ │ ├── array_stack.go │ │ │ │ ├── deque_test.go │ │ │ │ ├── linkedlist_deque.go │ │ │ │ ├── linkedlist_queue.go │ │ │ │ ├── linkedlist_stack.go │ │ │ │ ├── queue_test.go │ │ │ │ └── stack_test.go │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.go │ │ │ │ ├── array_binary_tree_test.go │ │ │ │ ├── avl_tree.go │ │ │ │ ├── avl_tree_test.go │ │ │ │ ├── binary_search_tree.go │ │ │ │ ├── binary_search_tree_test.go │ │ │ │ ├── binary_tree_bfs.go │ │ │ │ ├── binary_tree_bfs_test.go │ │ │ │ ├── binary_tree_dfs.go │ │ │ │ ├── binary_tree_dfs_test.go │ │ │ │ └── binary_tree_test.go │ │ │ ├── go.mod │ │ │ └── pkg/ │ │ │ ├── list_node.go │ │ │ ├── list_node_test.go │ │ │ ├── print_utils.go │ │ │ ├── tree_node.go │ │ │ ├── tree_node_test.go │ │ │ └── vertex.go │ │ ├── java/ │ │ │ ├── .gitignore │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.java │ │ │ │ ├── linked_list.java │ │ │ │ ├── list.java │ │ │ │ └── my_list.java │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.java │ │ │ │ ├── permutations_i.java │ │ │ │ ├── permutations_ii.java │ │ │ │ ├── preorder_traversal_i_compact.java │ │ │ │ ├── preorder_traversal_ii_compact.java │ │ │ │ ├── preorder_traversal_iii_compact.java │ │ │ │ ├── preorder_traversal_iii_template.java │ │ │ │ ├── subset_sum_i.java │ │ │ │ ├── subset_sum_i_naive.java │ │ │ │ └── subset_sum_ii.java │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.java │ │ │ │ ├── recursion.java │ │ │ │ ├── space_complexity.java │ │ │ │ ├── time_complexity.java │ │ │ │ └── worst_best_time_complexity.java │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.java │ │ │ │ ├── build_tree.java │ │ │ │ └── hanota.java │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.java │ │ │ │ ├── climbing_stairs_constraint_dp.java │ │ │ │ ├── climbing_stairs_dfs.java │ │ │ │ ├── climbing_stairs_dfs_mem.java │ │ │ │ ├── climbing_stairs_dp.java │ │ │ │ ├── coin_change.java │ │ │ │ ├── coin_change_ii.java │ │ │ │ ├── edit_distance.java │ │ │ │ ├── knapsack.java │ │ │ │ ├── min_cost_climbing_stairs_dp.java │ │ │ │ ├── min_path_sum.java │ │ │ │ └── unbounded_knapsack.java │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.java │ │ │ │ ├── graph_adjacency_matrix.java │ │ │ │ ├── graph_bfs.java │ │ │ │ └── graph_dfs.java │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.java │ │ │ │ ├── fractional_knapsack.java │ │ │ │ ├── max_capacity.java │ │ │ │ └── max_product_cutting.java │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.java │ │ │ │ ├── built_in_hash.java │ │ │ │ ├── hash_map.java │ │ │ │ ├── hash_map_chaining.java │ │ │ │ ├── hash_map_open_addressing.java │ │ │ │ └── simple_hash.java │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.java │ │ │ │ ├── my_heap.java │ │ │ │ └── top_k.java │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.java │ │ │ │ ├── binary_search_edge.java │ │ │ │ ├── binary_search_insertion.java │ │ │ │ ├── hashing_search.java │ │ │ │ ├── linear_search.java │ │ │ │ └── two_sum.java │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.java │ │ │ │ ├── bucket_sort.java │ │ │ │ ├── counting_sort.java │ │ │ │ ├── heap_sort.java │ │ │ │ ├── insertion_sort.java │ │ │ │ ├── merge_sort.java │ │ │ │ ├── quick_sort.java │ │ │ │ ├── radix_sort.java │ │ │ │ └── selection_sort.java │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.java │ │ │ │ ├── array_queue.java │ │ │ │ ├── array_stack.java │ │ │ │ ├── deque.java │ │ │ │ ├── linkedlist_deque.java │ │ │ │ ├── linkedlist_queue.java │ │ │ │ ├── linkedlist_stack.java │ │ │ │ ├── queue.java │ │ │ │ └── stack.java │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.java │ │ │ │ ├── avl_tree.java │ │ │ │ ├── binary_search_tree.java │ │ │ │ ├── binary_tree.java │ │ │ │ ├── binary_tree_bfs.java │ │ │ │ └── binary_tree_dfs.java │ │ │ └── utils/ │ │ │ ├── ListNode.java │ │ │ ├── PrintUtil.java │ │ │ ├── TreeNode.java │ │ │ └── Vertex.java │ │ ├── javascript/ │ │ │ ├── .prettierrc │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.js │ │ │ │ ├── linked_list.js │ │ │ │ ├── list.js │ │ │ │ └── my_list.js │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.js │ │ │ │ ├── permutations_i.js │ │ │ │ ├── permutations_ii.js │ │ │ │ ├── preorder_traversal_i_compact.js │ │ │ │ ├── preorder_traversal_ii_compact.js │ │ │ │ ├── preorder_traversal_iii_compact.js │ │ │ │ ├── preorder_traversal_iii_template.js │ │ │ │ ├── subset_sum_i.js │ │ │ │ ├── subset_sum_i_naive.js │ │ │ │ └── subset_sum_ii.js │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.js │ │ │ │ ├── recursion.js │ │ │ │ ├── space_complexity.js │ │ │ │ ├── time_complexity.js │ │ │ │ └── worst_best_time_complexity.js │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.js │ │ │ │ ├── build_tree.js │ │ │ │ └── hanota.js │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.js │ │ │ │ ├── climbing_stairs_constraint_dp.js │ │ │ │ ├── climbing_stairs_dfs.js │ │ │ │ ├── climbing_stairs_dfs_mem.js │ │ │ │ ├── climbing_stairs_dp.js │ │ │ │ ├── coin_change.js │ │ │ │ ├── coin_change_ii.js │ │ │ │ ├── edit_distance.js │ │ │ │ ├── knapsack.js │ │ │ │ ├── min_cost_climbing_stairs_dp.js │ │ │ │ ├── min_path_sum.js │ │ │ │ └── unbounded_knapsack.js │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.js │ │ │ │ ├── graph_adjacency_matrix.js │ │ │ │ ├── graph_bfs.js │ │ │ │ └── graph_dfs.js │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.js │ │ │ │ ├── fractional_knapsack.js │ │ │ │ ├── max_capacity.js │ │ │ │ └── max_product_cutting.js │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.js │ │ │ │ ├── hash_map.js │ │ │ │ ├── hash_map_chaining.js │ │ │ │ ├── hash_map_open_addressing.js │ │ │ │ └── simple_hash.js │ │ │ ├── chapter_heap/ │ │ │ │ ├── my_heap.js │ │ │ │ └── top_k.js │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.js │ │ │ │ ├── binary_search_edge.js │ │ │ │ ├── binary_search_insertion.js │ │ │ │ ├── hashing_search.js │ │ │ │ ├── linear_search.js │ │ │ │ └── two_sum.js │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.js │ │ │ │ ├── bucket_sort.js │ │ │ │ ├── counting_sort.js │ │ │ │ ├── heap_sort.js │ │ │ │ ├── insertion_sort.js │ │ │ │ ├── merge_sort.js │ │ │ │ ├── quick_sort.js │ │ │ │ ├── radix_sort.js │ │ │ │ └── selection_sort.js │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.js │ │ │ │ ├── array_queue.js │ │ │ │ ├── array_stack.js │ │ │ │ ├── deque.js │ │ │ │ ├── linkedlist_deque.js │ │ │ │ ├── linkedlist_queue.js │ │ │ │ ├── linkedlist_stack.js │ │ │ │ ├── queue.js │ │ │ │ └── stack.js │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.js │ │ │ │ ├── avl_tree.js │ │ │ │ ├── binary_search_tree.js │ │ │ │ ├── binary_tree.js │ │ │ │ ├── binary_tree_bfs.js │ │ │ │ └── binary_tree_dfs.js │ │ │ ├── modules/ │ │ │ │ ├── ListNode.js │ │ │ │ ├── PrintUtil.js │ │ │ │ ├── TreeNode.js │ │ │ │ └── Vertex.js │ │ │ └── test_all.js │ │ ├── kotlin/ │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.kt │ │ │ │ ├── linked_list.kt │ │ │ │ ├── list.kt │ │ │ │ └── my_list.kt │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.kt │ │ │ │ ├── permutations_i.kt │ │ │ │ ├── permutations_ii.kt │ │ │ │ ├── preorder_traversal_i_compact.kt │ │ │ │ ├── preorder_traversal_ii_compact.kt │ │ │ │ ├── preorder_traversal_iii_compact.kt │ │ │ │ ├── preorder_traversal_iii_template.kt │ │ │ │ ├── subset_sum_i.kt │ │ │ │ ├── subset_sum_i_naive.kt │ │ │ │ └── subset_sum_ii.kt │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.kt │ │ │ │ ├── recursion.kt │ │ │ │ ├── space_complexity.kt │ │ │ │ ├── time_complexity.kt │ │ │ │ └── worst_best_time_complexity.kt │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.kt │ │ │ │ ├── build_tree.kt │ │ │ │ └── hanota.kt │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.kt │ │ │ │ ├── climbing_stairs_constraint_dp.kt │ │ │ │ ├── climbing_stairs_dfs.kt │ │ │ │ ├── climbing_stairs_dfs_mem.kt │ │ │ │ ├── climbing_stairs_dp.kt │ │ │ │ ├── coin_change.kt │ │ │ │ ├── coin_change_ii.kt │ │ │ │ ├── edit_distance.kt │ │ │ │ ├── knapsack.kt │ │ │ │ ├── min_cost_climbing_stairs_dp.kt │ │ │ │ ├── min_path_sum.kt │ │ │ │ └── unbounded_knapsack.kt │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.kt │ │ │ │ ├── graph_adjacency_matrix.kt │ │ │ │ ├── graph_bfs.kt │ │ │ │ └── graph_dfs.kt │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.kt │ │ │ │ ├── fractional_knapsack.kt │ │ │ │ ├── max_capacity.kt │ │ │ │ └── max_product_cutting.kt │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.kt │ │ │ │ ├── built_in_hash.kt │ │ │ │ ├── hash_map.kt │ │ │ │ ├── hash_map_chaining.kt │ │ │ │ ├── hash_map_open_addressing.kt │ │ │ │ └── simple_hash.kt │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.kt │ │ │ │ ├── my_heap.kt │ │ │ │ └── top_k.kt │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.kt │ │ │ │ ├── binary_search_edge.kt │ │ │ │ ├── binary_search_insertion.kt │ │ │ │ ├── hashing_search.kt │ │ │ │ ├── linear_search.kt │ │ │ │ └── two_sum.kt │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.kt │ │ │ │ ├── bucket_sort.kt │ │ │ │ ├── counting_sort.kt │ │ │ │ ├── heap_sort.kt │ │ │ │ ├── insertion_sort.kt │ │ │ │ ├── merge_sort.kt │ │ │ │ ├── quick_sort.kt │ │ │ │ ├── radix_sort.kt │ │ │ │ └── selection_sort.kt │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.kt │ │ │ │ ├── array_queue.kt │ │ │ │ ├── array_stack.kt │ │ │ │ ├── deque.kt │ │ │ │ ├── linkedlist_deque.kt │ │ │ │ ├── linkedlist_queue.kt │ │ │ │ ├── linkedlist_stack.kt │ │ │ │ ├── queue.kt │ │ │ │ └── stack.kt │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.kt │ │ │ │ ├── avl_tree.kt │ │ │ │ ├── binary_search_tree.kt │ │ │ │ ├── binary_tree.kt │ │ │ │ ├── binary_tree_bfs.kt │ │ │ │ └── binary_tree_dfs.kt │ │ │ └── utils/ │ │ │ ├── ListNode.kt │ │ │ ├── PrintUtil.kt │ │ │ ├── TreeNode.kt │ │ │ └── Vertex.kt │ │ ├── python/ │ │ │ ├── .gitignore │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.py │ │ │ │ ├── linked_list.py │ │ │ │ ├── list.py │ │ │ │ └── my_list.py │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.py │ │ │ │ ├── permutations_i.py │ │ │ │ ├── permutations_ii.py │ │ │ │ ├── preorder_traversal_i_compact.py │ │ │ │ ├── preorder_traversal_ii_compact.py │ │ │ │ ├── preorder_traversal_iii_compact.py │ │ │ │ ├── preorder_traversal_iii_template.py │ │ │ │ ├── subset_sum_i.py │ │ │ │ ├── subset_sum_i_naive.py │ │ │ │ └── subset_sum_ii.py │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.py │ │ │ │ ├── recursion.py │ │ │ │ ├── space_complexity.py │ │ │ │ ├── time_complexity.py │ │ │ │ └── worst_best_time_complexity.py │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.py │ │ │ │ ├── build_tree.py │ │ │ │ └── hanota.py │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.py │ │ │ │ ├── climbing_stairs_constraint_dp.py │ │ │ │ ├── climbing_stairs_dfs.py │ │ │ │ ├── climbing_stairs_dfs_mem.py │ │ │ │ ├── climbing_stairs_dp.py │ │ │ │ ├── coin_change.py │ │ │ │ ├── coin_change_ii.py │ │ │ │ ├── edit_distance.py │ │ │ │ ├── knapsack.py │ │ │ │ ├── min_cost_climbing_stairs_dp.py │ │ │ │ ├── min_path_sum.py │ │ │ │ └── unbounded_knapsack.py │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.py │ │ │ │ ├── graph_adjacency_matrix.py │ │ │ │ ├── graph_bfs.py │ │ │ │ └── graph_dfs.py │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.py │ │ │ │ ├── fractional_knapsack.py │ │ │ │ ├── max_capacity.py │ │ │ │ └── max_product_cutting.py │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.py │ │ │ │ ├── built_in_hash.py │ │ │ │ ├── hash_map.py │ │ │ │ ├── hash_map_chaining.py │ │ │ │ ├── hash_map_open_addressing.py │ │ │ │ └── simple_hash.py │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.py │ │ │ │ ├── my_heap.py │ │ │ │ └── top_k.py │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.py │ │ │ │ ├── binary_search_edge.py │ │ │ │ ├── binary_search_insertion.py │ │ │ │ ├── hashing_search.py │ │ │ │ ├── linear_search.py │ │ │ │ └── two_sum.py │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.py │ │ │ │ ├── bucket_sort.py │ │ │ │ ├── counting_sort.py │ │ │ │ ├── heap_sort.py │ │ │ │ ├── insertion_sort.py │ │ │ │ ├── merge_sort.py │ │ │ │ ├── quick_sort.py │ │ │ │ ├── radix_sort.py │ │ │ │ └── selection_sort.py │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.py │ │ │ │ ├── array_queue.py │ │ │ │ ├── array_stack.py │ │ │ │ ├── deque.py │ │ │ │ ├── linkedlist_deque.py │ │ │ │ ├── linkedlist_queue.py │ │ │ │ ├── linkedlist_stack.py │ │ │ │ ├── queue.py │ │ │ │ └── stack.py │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.py │ │ │ │ ├── avl_tree.py │ │ │ │ ├── binary_search_tree.py │ │ │ │ ├── binary_tree.py │ │ │ │ ├── binary_tree_bfs.py │ │ │ │ └── binary_tree_dfs.py │ │ │ ├── modules/ │ │ │ │ ├── __init__.py │ │ │ │ ├── list_node.py │ │ │ │ ├── print_util.py │ │ │ │ ├── tree_node.py │ │ │ │ └── vertex.py │ │ │ └── test_all.py │ │ ├── ruby/ │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.rb │ │ │ │ ├── linked_list.rb │ │ │ │ ├── list.rb │ │ │ │ └── my_list.rb │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.rb │ │ │ │ ├── permutations_i.rb │ │ │ │ ├── permutations_ii.rb │ │ │ │ ├── preorder_traversal_i_compact.rb │ │ │ │ ├── preorder_traversal_ii_compact.rb │ │ │ │ ├── preorder_traversal_iii_compact.rb │ │ │ │ ├── preorder_traversal_iii_template.rb │ │ │ │ ├── subset_sum_i.rb │ │ │ │ ├── subset_sum_i_naive.rb │ │ │ │ └── subset_sum_ii.rb │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.rb │ │ │ │ ├── recursion.rb │ │ │ │ ├── space_complexity.rb │ │ │ │ ├── time_complexity.rb │ │ │ │ └── worst_best_time_complexity.rb │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.rb │ │ │ │ ├── build_tree.rb │ │ │ │ └── hanota.rb │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.rb │ │ │ │ ├── climbing_stairs_constraint_dp.rb │ │ │ │ ├── climbing_stairs_dfs.rb │ │ │ │ ├── climbing_stairs_dfs_mem.rb │ │ │ │ ├── climbing_stairs_dp.rb │ │ │ │ ├── coin_change.rb │ │ │ │ ├── coin_change_ii.rb │ │ │ │ ├── edit_distance.rb │ │ │ │ ├── knapsack.rb │ │ │ │ ├── min_cost_climbing_stairs_dp.rb │ │ │ │ ├── min_path_sum.rb │ │ │ │ └── unbounded_knapsack.rb │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.rb │ │ │ │ ├── graph_adjacency_matrix.rb │ │ │ │ ├── graph_bfs.rb │ │ │ │ └── graph_dfs.rb │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.rb │ │ │ │ ├── fractional_knapsack.rb │ │ │ │ ├── max_capacity.rb │ │ │ │ └── max_product_cutting.rb │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.rb │ │ │ │ ├── built_in_hash.rb │ │ │ │ ├── hash_map.rb │ │ │ │ ├── hash_map_chaining.rb │ │ │ │ ├── hash_map_open_addressing.rb │ │ │ │ └── simple_hash.rb │ │ │ ├── chapter_heap/ │ │ │ │ ├── my_heap.rb │ │ │ │ └── top_k.rb │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.rb │ │ │ │ ├── binary_search_edge.rb │ │ │ │ ├── binary_search_insertion.rb │ │ │ │ ├── hashing_search.rb │ │ │ │ ├── linear_search.rb │ │ │ │ └── two_sum.rb │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.rb │ │ │ │ ├── bucket_sort.rb │ │ │ │ ├── counting_sort.rb │ │ │ │ ├── heap_sort.rb │ │ │ │ ├── insertion_sort.rb │ │ │ │ ├── merge_sort.rb │ │ │ │ ├── quick_sort.rb │ │ │ │ ├── radix_sort.rb │ │ │ │ └── selection_sort.rb │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.rb │ │ │ │ ├── array_queue.rb │ │ │ │ ├── array_stack.rb │ │ │ │ ├── deque.rb │ │ │ │ ├── linkedlist_deque.rb │ │ │ │ ├── linkedlist_queue.rb │ │ │ │ ├── linkedlist_stack.rb │ │ │ │ ├── queue.rb │ │ │ │ └── stack.rb │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.rb │ │ │ │ ├── avl_tree.rb │ │ │ │ ├── binary_search_tree.rb │ │ │ │ ├── binary_tree.rb │ │ │ │ ├── binary_tree_bfs.rb │ │ │ │ └── binary_tree_dfs.rb │ │ │ ├── test_all.rb │ │ │ └── utils/ │ │ │ ├── list_node.rb │ │ │ ├── print_util.rb │ │ │ ├── tree_node.rb │ │ │ └── vertex.rb │ │ ├── rust/ │ │ │ ├── .gitignore │ │ │ ├── Cargo.toml │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.rs │ │ │ │ ├── linked_list.rs │ │ │ │ ├── list.rs │ │ │ │ └── my_list.rs │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.rs │ │ │ │ ├── permutations_i.rs │ │ │ │ ├── permutations_ii.rs │ │ │ │ ├── preorder_traversal_i_compact.rs │ │ │ │ ├── preorder_traversal_ii_compact.rs │ │ │ │ ├── preorder_traversal_iii_compact.rs │ │ │ │ ├── preorder_traversal_iii_template.rs │ │ │ │ ├── subset_sum_i.rs │ │ │ │ ├── subset_sum_i_naive.rs │ │ │ │ └── subset_sum_ii.rs │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.rs │ │ │ │ ├── recursion.rs │ │ │ │ ├── space_complexity.rs │ │ │ │ ├── time_complexity.rs │ │ │ │ └── worst_best_time_complexity.rs │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.rs │ │ │ │ ├── build_tree.rs │ │ │ │ └── hanota.rs │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.rs │ │ │ │ ├── climbing_stairs_constraint_dp.rs │ │ │ │ ├── climbing_stairs_dfs.rs │ │ │ │ ├── climbing_stairs_dfs_mem.rs │ │ │ │ ├── climbing_stairs_dp.rs │ │ │ │ ├── coin_change.rs │ │ │ │ ├── coin_change_ii.rs │ │ │ │ ├── edit_distance.rs │ │ │ │ ├── knapsack.rs │ │ │ │ ├── min_cost_climbing_stairs_dp.rs │ │ │ │ ├── min_path_sum.rs │ │ │ │ └── unbounded_knapsack.rs │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.rs │ │ │ │ ├── graph_adjacency_matrix.rs │ │ │ │ ├── graph_bfs.rs │ │ │ │ └── graph_dfs.rs │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.rs │ │ │ │ ├── fractional_knapsack.rs │ │ │ │ ├── max_capacity.rs │ │ │ │ └── max_product_cutting.rs │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.rs │ │ │ │ ├── build_in_hash.rs │ │ │ │ ├── hash_map.rs │ │ │ │ ├── hash_map_chaining.rs │ │ │ │ ├── hash_map_open_addressing.rs │ │ │ │ └── simple_hash.rs │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.rs │ │ │ │ ├── my_heap.rs │ │ │ │ └── top_k.rs │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.rs │ │ │ │ ├── binary_search_edge.rs │ │ │ │ ├── binary_search_insertion.rs │ │ │ │ ├── hashing_search.rs │ │ │ │ ├── linear_search.rs │ │ │ │ └── two_sum.rs │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.rs │ │ │ │ ├── bucket_sort.rs │ │ │ │ ├── counting_sort.rs │ │ │ │ ├── heap_sort.rs │ │ │ │ ├── insertion_sort.rs │ │ │ │ ├── merge_sort.rs │ │ │ │ ├── quick_sort.rs │ │ │ │ ├── radix_sort.rs │ │ │ │ └── selection_sort.rs │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.rs │ │ │ │ ├── array_queue.rs │ │ │ │ ├── array_stack.rs │ │ │ │ ├── deque.rs │ │ │ │ ├── linkedlist_deque.rs │ │ │ │ ├── linkedlist_queue.rs │ │ │ │ ├── linkedlist_stack.rs │ │ │ │ ├── queue.rs │ │ │ │ └── stack.rs │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.rs │ │ │ │ ├── avl_tree.rs │ │ │ │ ├── binary_search_tree.rs │ │ │ │ ├── binary_tree.rs │ │ │ │ ├── binary_tree_bfs.rs │ │ │ │ └── binary_tree_dfs.rs │ │ │ └── src/ │ │ │ ├── include/ │ │ │ │ ├── list_node.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── print_util.rs │ │ │ │ ├── tree_node.rs │ │ │ │ └── vertex.rs │ │ │ └── lib.rs │ │ ├── swift/ │ │ │ ├── .gitignore │ │ │ ├── Package.resolved │ │ │ ├── Package.swift │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.swift │ │ │ │ ├── linked_list.swift │ │ │ │ ├── list.swift │ │ │ │ └── my_list.swift │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.swift │ │ │ │ ├── permutations_i.swift │ │ │ │ ├── permutations_ii.swift │ │ │ │ ├── preorder_traversal_i_compact.swift │ │ │ │ ├── preorder_traversal_ii_compact.swift │ │ │ │ ├── preorder_traversal_iii_compact.swift │ │ │ │ ├── preorder_traversal_iii_template.swift │ │ │ │ ├── subset_sum_i.swift │ │ │ │ ├── subset_sum_i_naive.swift │ │ │ │ └── subset_sum_ii.swift │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.swift │ │ │ │ ├── recursion.swift │ │ │ │ ├── space_complexity.swift │ │ │ │ ├── time_complexity.swift │ │ │ │ └── worst_best_time_complexity.swift │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.swift │ │ │ │ ├── build_tree.swift │ │ │ │ └── hanota.swift │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.swift │ │ │ │ ├── climbing_stairs_constraint_dp.swift │ │ │ │ ├── climbing_stairs_dfs.swift │ │ │ │ ├── climbing_stairs_dfs_mem.swift │ │ │ │ ├── climbing_stairs_dp.swift │ │ │ │ ├── coin_change.swift │ │ │ │ ├── coin_change_ii.swift │ │ │ │ ├── edit_distance.swift │ │ │ │ ├── knapsack.swift │ │ │ │ ├── min_cost_climbing_stairs_dp.swift │ │ │ │ ├── min_path_sum.swift │ │ │ │ └── unbounded_knapsack.swift │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.swift │ │ │ │ ├── graph_adjacency_list_target.swift │ │ │ │ ├── graph_adjacency_matrix.swift │ │ │ │ ├── graph_bfs.swift │ │ │ │ └── graph_dfs.swift │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.swift │ │ │ │ ├── fractional_knapsack.swift │ │ │ │ ├── max_capacity.swift │ │ │ │ └── max_product_cutting.swift │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.swift │ │ │ │ ├── built_in_hash.swift │ │ │ │ ├── hash_map.swift │ │ │ │ ├── hash_map_chaining.swift │ │ │ │ ├── hash_map_open_addressing.swift │ │ │ │ └── simple_hash.swift │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.swift │ │ │ │ ├── my_heap.swift │ │ │ │ └── top_k.swift │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.swift │ │ │ │ ├── binary_search_edge.swift │ │ │ │ ├── binary_search_insertion.swift │ │ │ │ ├── binary_search_insertion_target.swift │ │ │ │ ├── hashing_search.swift │ │ │ │ ├── linear_search.swift │ │ │ │ └── two_sum.swift │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.swift │ │ │ │ ├── bucket_sort.swift │ │ │ │ ├── counting_sort.swift │ │ │ │ ├── heap_sort.swift │ │ │ │ ├── insertion_sort.swift │ │ │ │ ├── merge_sort.swift │ │ │ │ ├── quick_sort.swift │ │ │ │ ├── radix_sort.swift │ │ │ │ └── selection_sort.swift │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.swift │ │ │ │ ├── array_queue.swift │ │ │ │ ├── array_stack.swift │ │ │ │ ├── deque.swift │ │ │ │ ├── linkedlist_deque.swift │ │ │ │ ├── linkedlist_queue.swift │ │ │ │ ├── linkedlist_stack.swift │ │ │ │ ├── queue.swift │ │ │ │ └── stack.swift │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.swift │ │ │ │ ├── avl_tree.swift │ │ │ │ ├── binary_search_tree.swift │ │ │ │ ├── binary_tree.swift │ │ │ │ ├── binary_tree_bfs.swift │ │ │ │ └── binary_tree_dfs.swift │ │ │ └── utils/ │ │ │ ├── ListNode.swift │ │ │ ├── Pair.swift │ │ │ ├── PrintUtil.swift │ │ │ ├── TreeNode.swift │ │ │ └── Vertex.swift │ │ └── typescript/ │ │ ├── .gitignore │ │ ├── .prettierrc │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.ts │ │ │ ├── linked_list.ts │ │ │ ├── list.ts │ │ │ └── my_list.ts │ │ ├── chapter_backtracking/ │ │ │ ├── n_queens.ts │ │ │ ├── permutations_i.ts │ │ │ ├── permutations_ii.ts │ │ │ ├── preorder_traversal_i_compact.ts │ │ │ ├── preorder_traversal_ii_compact.ts │ │ │ ├── preorder_traversal_iii_compact.ts │ │ │ ├── preorder_traversal_iii_template.ts │ │ │ ├── subset_sum_i.ts │ │ │ ├── subset_sum_i_naive.ts │ │ │ └── subset_sum_ii.ts │ │ ├── chapter_computational_complexity/ │ │ │ ├── iteration.ts │ │ │ ├── recursion.ts │ │ │ ├── space_complexity.ts │ │ │ ├── time_complexity.ts │ │ │ └── worst_best_time_complexity.ts │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── binary_search_recur.ts │ │ │ ├── build_tree.ts │ │ │ └── hanota.ts │ │ ├── chapter_dynamic_programming/ │ │ │ ├── climbing_stairs_backtrack.ts │ │ │ ├── climbing_stairs_constraint_dp.ts │ │ │ ├── climbing_stairs_dfs.ts │ │ │ ├── climbing_stairs_dfs_mem.ts │ │ │ ├── climbing_stairs_dp.ts │ │ │ ├── coin_change.ts │ │ │ ├── coin_change_ii.ts │ │ │ ├── edit_distance.ts │ │ │ ├── knapsack.ts │ │ │ ├── min_cost_climbing_stairs_dp.ts │ │ │ ├── min_path_sum.ts │ │ │ └── unbounded_knapsack.ts │ │ ├── chapter_graph/ │ │ │ ├── graph_adjacency_list.ts │ │ │ ├── graph_adjacency_matrix.ts │ │ │ ├── graph_bfs.ts │ │ │ └── graph_dfs.ts │ │ ├── chapter_greedy/ │ │ │ ├── coin_change_greedy.ts │ │ │ ├── fractional_knapsack.ts │ │ │ ├── max_capacity.ts │ │ │ └── max_product_cutting.ts │ │ ├── chapter_hashing/ │ │ │ ├── array_hash_map.ts │ │ │ ├── hash_map.ts │ │ │ ├── hash_map_chaining.ts │ │ │ ├── hash_map_open_addressing.ts │ │ │ └── simple_hash.ts │ │ ├── chapter_heap/ │ │ │ ├── my_heap.ts │ │ │ └── top_k.ts │ │ ├── chapter_searching/ │ │ │ ├── binary_search.ts │ │ │ ├── binary_search_edge.ts │ │ │ ├── binary_search_insertion.ts │ │ │ ├── hashing_search.ts │ │ │ ├── linear_search.ts │ │ │ └── two_sum.ts │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.ts │ │ │ ├── bucket_sort.ts │ │ │ ├── counting_sort.ts │ │ │ ├── heap_sort.ts │ │ │ ├── insertion_sort.ts │ │ │ ├── merge_sort.ts │ │ │ ├── quick_sort.ts │ │ │ ├── radix_sort.ts │ │ │ └── selection_sort.ts │ │ ├── chapter_stack_and_queue/ │ │ │ ├── array_deque.ts │ │ │ ├── array_queue.ts │ │ │ ├── array_stack.ts │ │ │ ├── deque.ts │ │ │ ├── linkedlist_deque.ts │ │ │ ├── linkedlist_queue.ts │ │ │ ├── linkedlist_stack.ts │ │ │ ├── queue.ts │ │ │ └── stack.ts │ │ ├── chapter_tree/ │ │ │ ├── array_binary_tree.ts │ │ │ ├── avl_tree.ts │ │ │ ├── binary_search_tree.ts │ │ │ ├── binary_tree.ts │ │ │ ├── binary_tree_bfs.ts │ │ │ └── binary_tree_dfs.ts │ │ ├── modules/ │ │ │ ├── ListNode.ts │ │ │ ├── PrintUtil.ts │ │ │ ├── TreeNode.ts │ │ │ └── Vertex.ts │ │ ├── package.json │ │ └── tsconfig.json │ ├── docs/ │ │ ├── chapter_appendix/ │ │ │ ├── contribution.md │ │ │ ├── index.md │ │ │ ├── installation.md │ │ │ └── terminology.md │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.md │ │ │ ├── index.md │ │ │ ├── linked_list.md │ │ │ ├── list.md │ │ │ ├── ram_and_cache.md │ │ │ └── summary.md │ │ ├── chapter_backtracking/ │ │ │ ├── backtracking_algorithm.md │ │ │ ├── index.md │ │ │ ├── n_queens_problem.md │ │ │ ├── permutations_problem.md │ │ │ ├── subset_sum_problem.md │ │ │ └── summary.md │ │ ├── chapter_computational_complexity/ │ │ │ ├── index.md │ │ │ ├── iteration_and_recursion.md │ │ │ ├── performance_evaluation.md │ │ │ ├── space_complexity.md │ │ │ ├── summary.md │ │ │ └── time_complexity.md │ │ ├── chapter_data_structure/ │ │ │ ├── basic_data_types.md │ │ │ ├── character_encoding.md │ │ │ ├── classification_of_data_structure.md │ │ │ ├── index.md │ │ │ ├── number_encoding.md │ │ │ └── summary.md │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── binary_search_recur.md │ │ │ ├── build_binary_tree_problem.md │ │ │ ├── divide_and_conquer.md │ │ │ ├── hanota_problem.md │ │ │ ├── index.md │ │ │ └── summary.md │ │ ├── chapter_dynamic_programming/ │ │ │ ├── dp_problem_features.md │ │ │ ├── dp_solution_pipeline.md │ │ │ ├── edit_distance_problem.md │ │ │ ├── index.md │ │ │ ├── intro_to_dynamic_programming.md │ │ │ ├── knapsack_problem.md │ │ │ ├── summary.md │ │ │ └── unbounded_knapsack_problem.md │ │ ├── chapter_graph/ │ │ │ ├── graph.md │ │ │ ├── graph_operations.md │ │ │ ├── graph_traversal.md │ │ │ ├── index.md │ │ │ └── summary.md │ │ ├── chapter_greedy/ │ │ │ ├── fractional_knapsack_problem.md │ │ │ ├── greedy_algorithm.md │ │ │ ├── index.md │ │ │ ├── max_capacity_problem.md │ │ │ ├── max_product_cutting_problem.md │ │ │ └── summary.md │ │ ├── chapter_hashing/ │ │ │ ├── hash_algorithm.md │ │ │ ├── hash_collision.md │ │ │ ├── hash_map.md │ │ │ ├── index.md │ │ │ └── summary.md │ │ ├── chapter_heap/ │ │ │ ├── build_heap.md │ │ │ ├── heap.md │ │ │ ├── index.md │ │ │ ├── summary.md │ │ │ └── top_k.md │ │ ├── chapter_hello_algo/ │ │ │ └── index.md │ │ ├── chapter_introduction/ │ │ │ ├── algorithms_are_everywhere.md │ │ │ ├── index.md │ │ │ ├── summary.md │ │ │ └── what_is_dsa.md │ │ ├── chapter_preface/ │ │ │ ├── about_the_book.md │ │ │ ├── index.md │ │ │ ├── suggestions.md │ │ │ └── summary.md │ │ ├── chapter_reference/ │ │ │ └── index.md │ │ ├── chapter_searching/ │ │ │ ├── binary_search.md │ │ │ ├── binary_search_edge.md │ │ │ ├── binary_search_insertion.md │ │ │ ├── index.md │ │ │ ├── replace_linear_by_hashing.md │ │ │ ├── searching_algorithm_revisited.md │ │ │ └── summary.md │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.md │ │ │ ├── bucket_sort.md │ │ │ ├── counting_sort.md │ │ │ ├── heap_sort.md │ │ │ ├── index.md │ │ │ ├── insertion_sort.md │ │ │ ├── merge_sort.md │ │ │ ├── quick_sort.md │ │ │ ├── radix_sort.md │ │ │ ├── selection_sort.md │ │ │ ├── sorting_algorithm.md │ │ │ └── summary.md │ │ ├── chapter_stack_and_queue/ │ │ │ ├── deque.md │ │ │ ├── index.md │ │ │ ├── queue.md │ │ │ ├── stack.md │ │ │ └── summary.md │ │ ├── chapter_tree/ │ │ │ ├── array_representation_of_tree.md │ │ │ ├── avl_tree.md │ │ │ ├── binary_search_tree.md │ │ │ ├── binary_tree.md │ │ │ ├── binary_tree_traversal.md │ │ │ ├── index.md │ │ │ └── summary.md │ │ ├── index.html │ │ └── index.md │ └── mkdocs.yml ├── giscus.json ├── ja/ │ ├── README.md │ ├── codes/ │ │ ├── c/ │ │ │ ├── .gitignore │ │ │ ├── CMakeLists.txt │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array.c │ │ │ │ ├── linked_list.c │ │ │ │ └── my_list.c │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── n_queens.c │ │ │ │ ├── permutations_i.c │ │ │ │ ├── permutations_ii.c │ │ │ │ ├── preorder_traversal_i_compact.c │ │ │ │ ├── preorder_traversal_ii_compact.c │ │ │ │ ├── preorder_traversal_iii_compact.c │ │ │ │ ├── preorder_traversal_iii_template.c │ │ │ │ ├── subset_sum_i.c │ │ │ │ ├── subset_sum_i_naive.c │ │ │ │ └── subset_sum_ii.c │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── iteration.c │ │ │ │ ├── recursion.c │ │ │ │ ├── space_complexity.c │ │ │ │ ├── time_complexity.c │ │ │ │ └── worst_best_time_complexity.c │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── binary_search_recur.c │ │ │ │ ├── build_tree.c │ │ │ │ └── hanota.c │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── climbing_stairs_backtrack.c │ │ │ │ ├── climbing_stairs_constraint_dp.c │ │ │ │ ├── climbing_stairs_dfs.c │ │ │ │ ├── climbing_stairs_dfs_mem.c │ │ │ │ ├── climbing_stairs_dp.c │ │ │ │ ├── coin_change.c │ │ │ │ ├── coin_change_ii.c │ │ │ │ ├── edit_distance.c │ │ │ │ ├── knapsack.c │ │ │ │ ├── min_cost_climbing_stairs_dp.c │ │ │ │ ├── min_path_sum.c │ │ │ │ └── unbounded_knapsack.c │ │ │ ├── chapter_graph/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── graph_adjacency_list.c │ │ │ │ ├── graph_adjacency_list_test.c │ │ │ │ ├── graph_adjacency_matrix.c │ │ │ │ ├── graph_bfs.c │ │ │ │ └── graph_dfs.c │ │ │ ├── chapter_greedy/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── coin_change_greedy.c │ │ │ │ ├── fractional_knapsack.c │ │ │ │ ├── max_capacity.c │ │ │ │ └── max_product_cutting.c │ │ │ ├── chapter_hashing/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_hash_map.c │ │ │ │ ├── hash_map_chaining.c │ │ │ │ ├── hash_map_open_addressing.c │ │ │ │ └── simple_hash.c │ │ │ ├── chapter_heap/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── my_heap.c │ │ │ │ ├── my_heap_test.c │ │ │ │ └── top_k.c │ │ │ ├── chapter_searching/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── binary_search.c │ │ │ │ ├── binary_search_edge.c │ │ │ │ ├── binary_search_insertion.c │ │ │ │ └── two_sum.c │ │ │ ├── chapter_sorting/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── bubble_sort.c │ │ │ │ ├── bucket_sort.c │ │ │ │ ├── counting_sort.c │ │ │ │ ├── heap_sort.c │ │ │ │ ├── insertion_sort.c │ │ │ │ ├── merge_sort.c │ │ │ │ ├── quick_sort.c │ │ │ │ ├── radix_sort.c │ │ │ │ └── selection_sort.c │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_deque.c │ │ │ │ ├── array_queue.c │ │ │ │ ├── array_stack.c │ │ │ │ ├── linkedlist_deque.c │ │ │ │ ├── linkedlist_queue.c │ │ │ │ └── linkedlist_stack.c │ │ │ ├── chapter_tree/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_binary_tree.c │ │ │ │ ├── avl_tree.c │ │ │ │ ├── binary_search_tree.c │ │ │ │ ├── binary_tree.c │ │ │ │ ├── binary_tree_bfs.c │ │ │ │ └── binary_tree_dfs.c │ │ │ └── utils/ │ │ │ ├── CMakeLists.txt │ │ │ ├── common.h │ │ │ ├── common_test.c │ │ │ ├── list_node.h │ │ │ ├── print_util.h │ │ │ ├── tree_node.h │ │ │ ├── uthash.h │ │ │ ├── vector.h │ │ │ └── vertex.h │ │ ├── cpp/ │ │ │ ├── .gitignore │ │ │ ├── CMakeLists.txt │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array.cpp │ │ │ │ ├── linked_list.cpp │ │ │ │ ├── list.cpp │ │ │ │ └── my_list.cpp │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── n_queens.cpp │ │ │ │ ├── permutations_i.cpp │ │ │ │ ├── permutations_ii.cpp │ │ │ │ ├── preorder_traversal_i_compact.cpp │ │ │ │ ├── preorder_traversal_ii_compact.cpp │ │ │ │ ├── preorder_traversal_iii_compact.cpp │ │ │ │ ├── preorder_traversal_iii_template.cpp │ │ │ │ ├── subset_sum_i.cpp │ │ │ │ ├── subset_sum_i_naive.cpp │ │ │ │ └── subset_sum_ii.cpp │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── iteration.cpp │ │ │ │ ├── recursion.cpp │ │ │ │ ├── space_complexity.cpp │ │ │ │ ├── time_complexity.cpp │ │ │ │ └── worst_best_time_complexity.cpp │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── binary_search_recur.cpp │ │ │ │ ├── build_tree.cpp │ │ │ │ └── hanota.cpp │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── climbing_stairs_backtrack.cpp │ │ │ │ ├── climbing_stairs_constraint_dp.cpp │ │ │ │ ├── climbing_stairs_dfs.cpp │ │ │ │ ├── climbing_stairs_dfs_mem.cpp │ │ │ │ ├── climbing_stairs_dp.cpp │ │ │ │ ├── coin_change.cpp │ │ │ │ ├── coin_change_ii.cpp │ │ │ │ ├── edit_distance.cpp │ │ │ │ ├── knapsack.cpp │ │ │ │ ├── min_cost_climbing_stairs_dp.cpp │ │ │ │ ├── min_path_sum.cpp │ │ │ │ └── unbounded_knapsack.cpp │ │ │ ├── chapter_graph/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── graph_adjacency_list.cpp │ │ │ │ ├── graph_adjacency_list_test.cpp │ │ │ │ ├── graph_adjacency_matrix.cpp │ │ │ │ ├── graph_bfs.cpp │ │ │ │ └── graph_dfs.cpp │ │ │ ├── chapter_greedy/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── coin_change_greedy.cpp │ │ │ │ ├── fractional_knapsack.cpp │ │ │ │ ├── max_capacity.cpp │ │ │ │ └── max_product_cutting.cpp │ │ │ ├── chapter_hashing/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_hash_map.cpp │ │ │ │ ├── array_hash_map_test.cpp │ │ │ │ ├── built_in_hash.cpp │ │ │ │ ├── hash_map.cpp │ │ │ │ ├── hash_map_chaining.cpp │ │ │ │ ├── hash_map_open_addressing.cpp │ │ │ │ └── simple_hash.cpp │ │ │ ├── chapter_heap/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── heap.cpp │ │ │ │ ├── my_heap.cpp │ │ │ │ └── top_k.cpp │ │ │ ├── chapter_searching/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── binary_search.cpp │ │ │ │ ├── binary_search_edge.cpp │ │ │ │ ├── binary_search_insertion.cpp │ │ │ │ ├── hashing_search.cpp │ │ │ │ ├── linear_search.cpp │ │ │ │ └── two_sum.cpp │ │ │ ├── chapter_sorting/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── bubble_sort.cpp │ │ │ │ ├── bucket_sort.cpp │ │ │ │ ├── counting_sort.cpp │ │ │ │ ├── heap_sort.cpp │ │ │ │ ├── insertion_sort.cpp │ │ │ │ ├── merge_sort.cpp │ │ │ │ ├── quick_sort.cpp │ │ │ │ ├── radix_sort.cpp │ │ │ │ └── selection_sort.cpp │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_deque.cpp │ │ │ │ ├── array_queue.cpp │ │ │ │ ├── array_stack.cpp │ │ │ │ ├── deque.cpp │ │ │ │ ├── linkedlist_deque.cpp │ │ │ │ ├── linkedlist_queue.cpp │ │ │ │ ├── linkedlist_stack.cpp │ │ │ │ ├── queue.cpp │ │ │ │ └── stack.cpp │ │ │ ├── chapter_tree/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_binary_tree.cpp │ │ │ │ ├── avl_tree.cpp │ │ │ │ ├── binary_search_tree.cpp │ │ │ │ ├── binary_tree.cpp │ │ │ │ ├── binary_tree_bfs.cpp │ │ │ │ └── binary_tree_dfs.cpp │ │ │ └── utils/ │ │ │ ├── CMakeLists.txt │ │ │ ├── common.hpp │ │ │ ├── list_node.hpp │ │ │ ├── print_utils.hpp │ │ │ ├── tree_node.hpp │ │ │ └── vertex.hpp │ │ ├── csharp/ │ │ │ ├── .editorconfig │ │ │ ├── .gitignore │ │ │ ├── GlobalUsing.cs │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.cs │ │ │ │ ├── linked_list.cs │ │ │ │ ├── list.cs │ │ │ │ └── my_list.cs │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.cs │ │ │ │ ├── permutations_i.cs │ │ │ │ ├── permutations_ii.cs │ │ │ │ ├── preorder_traversal_i_compact.cs │ │ │ │ ├── preorder_traversal_ii_compact.cs │ │ │ │ ├── preorder_traversal_iii_compact.cs │ │ │ │ ├── preorder_traversal_iii_template.cs │ │ │ │ ├── subset_sum_i.cs │ │ │ │ ├── subset_sum_i_naive.cs │ │ │ │ └── subset_sum_ii.cs │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.cs │ │ │ │ ├── recursion.cs │ │ │ │ ├── space_complexity.cs │ │ │ │ ├── time_complexity.cs │ │ │ │ └── worst_best_time_complexity.cs │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.cs │ │ │ │ ├── build_tree.cs │ │ │ │ └── hanota.cs │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.cs │ │ │ │ ├── climbing_stairs_constraint_dp.cs │ │ │ │ ├── climbing_stairs_dfs.cs │ │ │ │ ├── climbing_stairs_dfs_mem.cs │ │ │ │ ├── climbing_stairs_dp.cs │ │ │ │ ├── coin_change.cs │ │ │ │ ├── coin_change_ii.cs │ │ │ │ ├── edit_distance.cs │ │ │ │ ├── knapsack.cs │ │ │ │ ├── min_cost_climbing_stairs_dp.cs │ │ │ │ ├── min_path_sum.cs │ │ │ │ └── unbounded_knapsack.cs │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.cs │ │ │ │ ├── graph_adjacency_matrix.cs │ │ │ │ ├── graph_bfs.cs │ │ │ │ └── graph_dfs.cs │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.cs │ │ │ │ ├── fractional_knapsack.cs │ │ │ │ ├── max_capacity.cs │ │ │ │ └── max_product_cutting.cs │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.cs │ │ │ │ ├── built_in_hash.cs │ │ │ │ ├── hash_map.cs │ │ │ │ ├── hash_map_chaining.cs │ │ │ │ ├── hash_map_open_addressing.cs │ │ │ │ └── simple_hash.cs │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.cs │ │ │ │ ├── my_heap.cs │ │ │ │ └── top_k.cs │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.cs │ │ │ │ ├── binary_search_edge.cs │ │ │ │ ├── binary_search_insertion.cs │ │ │ │ ├── hashing_search.cs │ │ │ │ ├── linear_search.cs │ │ │ │ └── two_sum.cs │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.cs │ │ │ │ ├── bucket_sort.cs │ │ │ │ ├── counting_sort.cs │ │ │ │ ├── heap_sort.cs │ │ │ │ ├── insertion_sort.cs │ │ │ │ ├── merge_sort.cs │ │ │ │ ├── quick_sort.cs │ │ │ │ ├── radix_sort.cs │ │ │ │ └── selection_sort.cs │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.cs │ │ │ │ ├── array_queue.cs │ │ │ │ ├── array_stack.cs │ │ │ │ ├── deque.cs │ │ │ │ ├── linkedlist_deque.cs │ │ │ │ ├── linkedlist_queue.cs │ │ │ │ ├── linkedlist_stack.cs │ │ │ │ ├── queue.cs │ │ │ │ └── stack.cs │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.cs │ │ │ │ ├── avl_tree.cs │ │ │ │ ├── binary_search_tree.cs │ │ │ │ ├── binary_tree.cs │ │ │ │ ├── binary_tree_bfs.cs │ │ │ │ └── binary_tree_dfs.cs │ │ │ ├── csharp.sln │ │ │ ├── hello-algo.csproj │ │ │ └── utils/ │ │ │ ├── ListNode.cs │ │ │ ├── PrintUtil.cs │ │ │ ├── TreeNode.cs │ │ │ └── Vertex.cs │ │ ├── dart/ │ │ │ ├── build.dart │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.dart │ │ │ │ ├── linked_list.dart │ │ │ │ ├── list.dart │ │ │ │ └── my_list.dart │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.dart │ │ │ │ ├── permutations_i.dart │ │ │ │ ├── permutations_ii.dart │ │ │ │ ├── preorder_traversal_i_compact.dart │ │ │ │ ├── preorder_traversal_ii_compact.dart │ │ │ │ ├── preorder_traversal_iii_compact.dart │ │ │ │ ├── preorder_traversal_iii_template.dart │ │ │ │ ├── subset_sum_i.dart │ │ │ │ ├── subset_sum_i_naive.dart │ │ │ │ └── subset_sum_ii.dart │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.dart │ │ │ │ ├── recursion.dart │ │ │ │ ├── space_complexity.dart │ │ │ │ ├── time_complexity.dart │ │ │ │ └── worst_best_time_complexity.dart │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.dart │ │ │ │ ├── build_tree.dart │ │ │ │ └── hanota.dart │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.dart │ │ │ │ ├── climbing_stairs_constraint_dp.dart │ │ │ │ ├── climbing_stairs_dfs.dart │ │ │ │ ├── climbing_stairs_dfs_mem.dart │ │ │ │ ├── climbing_stairs_dp.dart │ │ │ │ ├── coin_change.dart │ │ │ │ ├── coin_change_ii.dart │ │ │ │ ├── edit_distance.dart │ │ │ │ ├── knapsack.dart │ │ │ │ ├── min_cost_climbing_stairs_dp.dart │ │ │ │ ├── min_path_sum.dart │ │ │ │ └── unbounded_knapsack.dart │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.dart │ │ │ │ ├── graph_adjacency_matrix.dart │ │ │ │ ├── graph_bfs.dart │ │ │ │ └── graph_dfs.dart │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.dart │ │ │ │ ├── fractional_knapsack.dart │ │ │ │ ├── max_capacity.dart │ │ │ │ └── max_product_cutting.dart │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.dart │ │ │ │ ├── built_in_hash.dart │ │ │ │ ├── hash_map.dart │ │ │ │ ├── hash_map_chaining.dart │ │ │ │ ├── hash_map_open_addressing.dart │ │ │ │ └── simple_hash.dart │ │ │ ├── chapter_heap/ │ │ │ │ ├── my_heap.dart │ │ │ │ └── top_k.dart │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.dart │ │ │ │ ├── binary_search_edge.dart │ │ │ │ ├── binary_search_insertion.dart │ │ │ │ ├── hashing_search.dart │ │ │ │ ├── linear_search.dart │ │ │ │ └── two_sum.dart │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.dart │ │ │ │ ├── bucket_sort.dart │ │ │ │ ├── counting_sort.dart │ │ │ │ ├── heap_sort.dart │ │ │ │ ├── insertion_sort.dart │ │ │ │ ├── merge_sort.dart │ │ │ │ ├── quick_sort.dart │ │ │ │ ├── radix_sort.dart │ │ │ │ └── selection_sort.dart │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.dart │ │ │ │ ├── array_queue.dart │ │ │ │ ├── array_stack.dart │ │ │ │ ├── deque.dart │ │ │ │ ├── linkedlist_deque.dart │ │ │ │ ├── linkedlist_queue.dart │ │ │ │ ├── linkedlist_stack.dart │ │ │ │ ├── queue.dart │ │ │ │ └── stack.dart │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.dart │ │ │ │ ├── avl_tree.dart │ │ │ │ ├── binary_search_tree.dart │ │ │ │ ├── binary_tree.dart │ │ │ │ ├── binary_tree_bfs.dart │ │ │ │ └── binary_tree_dfs.dart │ │ │ └── utils/ │ │ │ ├── list_node.dart │ │ │ ├── print_util.dart │ │ │ ├── tree_node.dart │ │ │ └── vertex.dart │ │ ├── go/ │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.go │ │ │ │ ├── array_test.go │ │ │ │ ├── linked_list.go │ │ │ │ ├── linked_list_test.go │ │ │ │ ├── list_test.go │ │ │ │ ├── my_list.go │ │ │ │ └── my_list_test.go │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.go │ │ │ │ ├── n_queens_test.go │ │ │ │ ├── permutation_test.go │ │ │ │ ├── permutations_i.go │ │ │ │ ├── permutations_ii.go │ │ │ │ ├── preorder_traversal_i_compact.go │ │ │ │ ├── preorder_traversal_ii_compact.go │ │ │ │ ├── preorder_traversal_iii_compact.go │ │ │ │ ├── preorder_traversal_iii_template.go │ │ │ │ ├── preorder_traversal_test.go │ │ │ │ ├── subset_sum_i.go │ │ │ │ ├── subset_sum_i_naive.go │ │ │ │ ├── subset_sum_ii.go │ │ │ │ └── subset_sum_test.go │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.go │ │ │ │ ├── iteration_test.go │ │ │ │ ├── recursion.go │ │ │ │ ├── recursion_test.go │ │ │ │ ├── space_complexity.go │ │ │ │ ├── space_complexity_test.go │ │ │ │ ├── time_complexity.go │ │ │ │ ├── time_complexity_test.go │ │ │ │ ├── worst_best_time_complexity.go │ │ │ │ └── worst_best_time_complexity_test.go │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.go │ │ │ │ ├── binary_search_recur_test.go │ │ │ │ ├── build_tree.go │ │ │ │ ├── build_tree_test.go │ │ │ │ ├── hanota.go │ │ │ │ └── hanota_test.go │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.go │ │ │ │ ├── climbing_stairs_constraint_dp.go │ │ │ │ ├── climbing_stairs_dfs.go │ │ │ │ ├── climbing_stairs_dfs_mem.go │ │ │ │ ├── climbing_stairs_dp.go │ │ │ │ ├── climbing_stairs_test.go │ │ │ │ ├── coin_change.go │ │ │ │ ├── coin_change_ii.go │ │ │ │ ├── coin_change_test.go │ │ │ │ ├── edit_distance.go │ │ │ │ ├── edit_distance_test.go │ │ │ │ ├── knapsack.go │ │ │ │ ├── knapsack_test.go │ │ │ │ ├── min_cost_climbing_stairs_dp.go │ │ │ │ ├── min_path_sum.go │ │ │ │ ├── min_path_sum_test.go │ │ │ │ └── unbounded_knapsack.go │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.go │ │ │ │ ├── graph_adjacency_list_test.go │ │ │ │ ├── graph_adjacency_matrix.go │ │ │ │ ├── graph_adjacency_matrix_test.go │ │ │ │ ├── graph_bfs.go │ │ │ │ ├── graph_bfs_test.go │ │ │ │ ├── graph_dfs.go │ │ │ │ └── graph_dfs_test.go │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.go │ │ │ │ ├── coin_change_greedy_test.go │ │ │ │ ├── fractional_knapsack.go │ │ │ │ ├── fractional_knapsack_test.go │ │ │ │ ├── max_capacity.go │ │ │ │ ├── max_capacity_test.go │ │ │ │ ├── max_product_cutting.go │ │ │ │ └── max_product_cutting_test.go │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.go │ │ │ │ ├── array_hash_map_test.go │ │ │ │ ├── hash_collision_test.go │ │ │ │ ├── hash_map_chaining.go │ │ │ │ ├── hash_map_open_addressing.go │ │ │ │ ├── hash_map_test.go │ │ │ │ └── simple_hash.go │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.go │ │ │ │ ├── heap_test.go │ │ │ │ ├── my_heap.go │ │ │ │ └── top_k.go │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.go │ │ │ │ ├── binary_search_edge.go │ │ │ │ ├── binary_search_insertion.go │ │ │ │ ├── binary_search_test.go │ │ │ │ ├── hashing_search.go │ │ │ │ ├── hashing_search_test.go │ │ │ │ ├── linear_search.go │ │ │ │ ├── linear_search_test.go │ │ │ │ ├── two_sum.go │ │ │ │ └── two_sum_test.go │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.go │ │ │ │ ├── bubble_sort_test.go │ │ │ │ ├── bucket_sort.go │ │ │ │ ├── bucket_sort_test.go │ │ │ │ ├── counting_sort.go │ │ │ │ ├── counting_sort_test.go │ │ │ │ ├── heap_sort.go │ │ │ │ ├── heap_sort_test.go │ │ │ │ ├── insertion_sort.go │ │ │ │ ├── insertion_sort_test.go │ │ │ │ ├── merge_sort.go │ │ │ │ ├── merge_sort_test.go │ │ │ │ ├── quick_sort.go │ │ │ │ ├── quick_sort_test.go │ │ │ │ ├── radix_sort.go │ │ │ │ ├── radix_sort_test.go │ │ │ │ ├── selection_sort.go │ │ │ │ └── selection_sort_test.go │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.go │ │ │ │ ├── array_queue.go │ │ │ │ ├── array_stack.go │ │ │ │ ├── deque_test.go │ │ │ │ ├── linkedlist_deque.go │ │ │ │ ├── linkedlist_queue.go │ │ │ │ ├── linkedlist_stack.go │ │ │ │ ├── queue_test.go │ │ │ │ └── stack_test.go │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.go │ │ │ │ ├── array_binary_tree_test.go │ │ │ │ ├── avl_tree.go │ │ │ │ ├── avl_tree_test.go │ │ │ │ ├── binary_search_tree.go │ │ │ │ ├── binary_search_tree_test.go │ │ │ │ ├── binary_tree_bfs.go │ │ │ │ ├── binary_tree_bfs_test.go │ │ │ │ ├── binary_tree_dfs.go │ │ │ │ ├── binary_tree_dfs_test.go │ │ │ │ └── binary_tree_test.go │ │ │ ├── go.mod │ │ │ └── pkg/ │ │ │ ├── list_node.go │ │ │ ├── list_node_test.go │ │ │ ├── print_utils.go │ │ │ ├── tree_node.go │ │ │ ├── tree_node_test.go │ │ │ └── vertex.go │ │ ├── java/ │ │ │ ├── .gitignore │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.java │ │ │ │ ├── linked_list.java │ │ │ │ ├── list.java │ │ │ │ └── my_list.java │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.java │ │ │ │ ├── permutations_i.java │ │ │ │ ├── permutations_ii.java │ │ │ │ ├── preorder_traversal_i_compact.java │ │ │ │ ├── preorder_traversal_ii_compact.java │ │ │ │ ├── preorder_traversal_iii_compact.java │ │ │ │ ├── preorder_traversal_iii_template.java │ │ │ │ ├── subset_sum_i.java │ │ │ │ ├── subset_sum_i_naive.java │ │ │ │ └── subset_sum_ii.java │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.java │ │ │ │ ├── recursion.java │ │ │ │ ├── space_complexity.java │ │ │ │ ├── time_complexity.java │ │ │ │ └── worst_best_time_complexity.java │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.java │ │ │ │ ├── build_tree.java │ │ │ │ └── hanota.java │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.java │ │ │ │ ├── climbing_stairs_constraint_dp.java │ │ │ │ ├── climbing_stairs_dfs.java │ │ │ │ ├── climbing_stairs_dfs_mem.java │ │ │ │ ├── climbing_stairs_dp.java │ │ │ │ ├── coin_change.java │ │ │ │ ├── coin_change_ii.java │ │ │ │ ├── edit_distance.java │ │ │ │ ├── knapsack.java │ │ │ │ ├── min_cost_climbing_stairs_dp.java │ │ │ │ ├── min_path_sum.java │ │ │ │ └── unbounded_knapsack.java │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.java │ │ │ │ ├── graph_adjacency_matrix.java │ │ │ │ ├── graph_bfs.java │ │ │ │ └── graph_dfs.java │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.java │ │ │ │ ├── fractional_knapsack.java │ │ │ │ ├── max_capacity.java │ │ │ │ └── max_product_cutting.java │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.java │ │ │ │ ├── built_in_hash.java │ │ │ │ ├── hash_map.java │ │ │ │ ├── hash_map_chaining.java │ │ │ │ ├── hash_map_open_addressing.java │ │ │ │ └── simple_hash.java │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.java │ │ │ │ ├── my_heap.java │ │ │ │ └── top_k.java │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.java │ │ │ │ ├── binary_search_edge.java │ │ │ │ ├── binary_search_insertion.java │ │ │ │ ├── hashing_search.java │ │ │ │ ├── linear_search.java │ │ │ │ └── two_sum.java │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.java │ │ │ │ ├── bucket_sort.java │ │ │ │ ├── counting_sort.java │ │ │ │ ├── heap_sort.java │ │ │ │ ├── insertion_sort.java │ │ │ │ ├── merge_sort.java │ │ │ │ ├── quick_sort.java │ │ │ │ ├── radix_sort.java │ │ │ │ └── selection_sort.java │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.java │ │ │ │ ├── array_queue.java │ │ │ │ ├── array_stack.java │ │ │ │ ├── deque.java │ │ │ │ ├── linkedlist_deque.java │ │ │ │ ├── linkedlist_queue.java │ │ │ │ ├── linkedlist_stack.java │ │ │ │ ├── queue.java │ │ │ │ └── stack.java │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.java │ │ │ │ ├── avl_tree.java │ │ │ │ ├── binary_search_tree.java │ │ │ │ ├── binary_tree.java │ │ │ │ ├── binary_tree_bfs.java │ │ │ │ └── binary_tree_dfs.java │ │ │ └── utils/ │ │ │ ├── ListNode.java │ │ │ ├── PrintUtil.java │ │ │ ├── TreeNode.java │ │ │ └── Vertex.java │ │ ├── javascript/ │ │ │ ├── .prettierrc │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.js │ │ │ │ ├── linked_list.js │ │ │ │ ├── list.js │ │ │ │ └── my_list.js │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.js │ │ │ │ ├── permutations_i.js │ │ │ │ ├── permutations_ii.js │ │ │ │ ├── preorder_traversal_i_compact.js │ │ │ │ ├── preorder_traversal_ii_compact.js │ │ │ │ ├── preorder_traversal_iii_compact.js │ │ │ │ ├── preorder_traversal_iii_template.js │ │ │ │ ├── subset_sum_i.js │ │ │ │ ├── subset_sum_i_naive.js │ │ │ │ └── subset_sum_ii.js │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.js │ │ │ │ ├── recursion.js │ │ │ │ ├── space_complexity.js │ │ │ │ ├── time_complexity.js │ │ │ │ └── worst_best_time_complexity.js │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.js │ │ │ │ ├── build_tree.js │ │ │ │ └── hanota.js │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.js │ │ │ │ ├── climbing_stairs_constraint_dp.js │ │ │ │ ├── climbing_stairs_dfs.js │ │ │ │ ├── climbing_stairs_dfs_mem.js │ │ │ │ ├── climbing_stairs_dp.js │ │ │ │ ├── coin_change.js │ │ │ │ ├── coin_change_ii.js │ │ │ │ ├── edit_distance.js │ │ │ │ ├── knapsack.js │ │ │ │ ├── min_cost_climbing_stairs_dp.js │ │ │ │ ├── min_path_sum.js │ │ │ │ └── unbounded_knapsack.js │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.js │ │ │ │ ├── graph_adjacency_matrix.js │ │ │ │ ├── graph_bfs.js │ │ │ │ └── graph_dfs.js │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.js │ │ │ │ ├── fractional_knapsack.js │ │ │ │ ├── max_capacity.js │ │ │ │ └── max_product_cutting.js │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.js │ │ │ │ ├── hash_map.js │ │ │ │ ├── hash_map_chaining.js │ │ │ │ ├── hash_map_open_addressing.js │ │ │ │ └── simple_hash.js │ │ │ ├── chapter_heap/ │ │ │ │ ├── my_heap.js │ │ │ │ └── top_k.js │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.js │ │ │ │ ├── binary_search_edge.js │ │ │ │ ├── binary_search_insertion.js │ │ │ │ ├── hashing_search.js │ │ │ │ ├── linear_search.js │ │ │ │ └── two_sum.js │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.js │ │ │ │ ├── bucket_sort.js │ │ │ │ ├── counting_sort.js │ │ │ │ ├── heap_sort.js │ │ │ │ ├── insertion_sort.js │ │ │ │ ├── merge_sort.js │ │ │ │ ├── quick_sort.js │ │ │ │ ├── radix_sort.js │ │ │ │ └── selection_sort.js │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.js │ │ │ │ ├── array_queue.js │ │ │ │ ├── array_stack.js │ │ │ │ ├── deque.js │ │ │ │ ├── linkedlist_deque.js │ │ │ │ ├── linkedlist_queue.js │ │ │ │ ├── linkedlist_stack.js │ │ │ │ ├── queue.js │ │ │ │ └── stack.js │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.js │ │ │ │ ├── avl_tree.js │ │ │ │ ├── binary_search_tree.js │ │ │ │ ├── binary_tree.js │ │ │ │ ├── binary_tree_bfs.js │ │ │ │ └── binary_tree_dfs.js │ │ │ ├── modules/ │ │ │ │ ├── ListNode.js │ │ │ │ ├── PrintUtil.js │ │ │ │ ├── TreeNode.js │ │ │ │ └── Vertex.js │ │ │ └── test_all.js │ │ ├── kotlin/ │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.kt │ │ │ │ ├── linked_list.kt │ │ │ │ ├── list.kt │ │ │ │ └── my_list.kt │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.kt │ │ │ │ ├── permutations_i.kt │ │ │ │ ├── permutations_ii.kt │ │ │ │ ├── preorder_traversal_i_compact.kt │ │ │ │ ├── preorder_traversal_ii_compact.kt │ │ │ │ ├── preorder_traversal_iii_compact.kt │ │ │ │ ├── preorder_traversal_iii_template.kt │ │ │ │ ├── subset_sum_i.kt │ │ │ │ ├── subset_sum_i_naive.kt │ │ │ │ └── subset_sum_ii.kt │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.kt │ │ │ │ ├── recursion.kt │ │ │ │ ├── space_complexity.kt │ │ │ │ ├── time_complexity.kt │ │ │ │ └── worst_best_time_complexity.kt │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.kt │ │ │ │ ├── build_tree.kt │ │ │ │ └── hanota.kt │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.kt │ │ │ │ ├── climbing_stairs_constraint_dp.kt │ │ │ │ ├── climbing_stairs_dfs.kt │ │ │ │ ├── climbing_stairs_dfs_mem.kt │ │ │ │ ├── climbing_stairs_dp.kt │ │ │ │ ├── coin_change.kt │ │ │ │ ├── coin_change_ii.kt │ │ │ │ ├── edit_distance.kt │ │ │ │ ├── knapsack.kt │ │ │ │ ├── min_cost_climbing_stairs_dp.kt │ │ │ │ ├── min_path_sum.kt │ │ │ │ └── unbounded_knapsack.kt │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.kt │ │ │ │ ├── graph_adjacency_matrix.kt │ │ │ │ ├── graph_bfs.kt │ │ │ │ └── graph_dfs.kt │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.kt │ │ │ │ ├── fractional_knapsack.kt │ │ │ │ ├── max_capacity.kt │ │ │ │ └── max_product_cutting.kt │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.kt │ │ │ │ ├── built_in_hash.kt │ │ │ │ ├── hash_map.kt │ │ │ │ ├── hash_map_chaining.kt │ │ │ │ ├── hash_map_open_addressing.kt │ │ │ │ └── simple_hash.kt │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.kt │ │ │ │ ├── my_heap.kt │ │ │ │ └── top_k.kt │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.kt │ │ │ │ ├── binary_search_edge.kt │ │ │ │ ├── binary_search_insertion.kt │ │ │ │ ├── hashing_search.kt │ │ │ │ ├── linear_search.kt │ │ │ │ └── two_sum.kt │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.kt │ │ │ │ ├── bucket_sort.kt │ │ │ │ ├── counting_sort.kt │ │ │ │ ├── heap_sort.kt │ │ │ │ ├── insertion_sort.kt │ │ │ │ ├── merge_sort.kt │ │ │ │ ├── quick_sort.kt │ │ │ │ ├── radix_sort.kt │ │ │ │ └── selection_sort.kt │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.kt │ │ │ │ ├── array_queue.kt │ │ │ │ ├── array_stack.kt │ │ │ │ ├── deque.kt │ │ │ │ ├── linkedlist_deque.kt │ │ │ │ ├── linkedlist_queue.kt │ │ │ │ ├── linkedlist_stack.kt │ │ │ │ ├── queue.kt │ │ │ │ └── stack.kt │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.kt │ │ │ │ ├── avl_tree.kt │ │ │ │ ├── binary_search_tree.kt │ │ │ │ ├── binary_tree.kt │ │ │ │ ├── binary_tree_bfs.kt │ │ │ │ └── binary_tree_dfs.kt │ │ │ └── utils/ │ │ │ ├── ListNode.kt │ │ │ ├── PrintUtil.kt │ │ │ ├── TreeNode.kt │ │ │ └── Vertex.kt │ │ ├── python/ │ │ │ ├── .gitignore │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.py │ │ │ │ ├── linked_list.py │ │ │ │ ├── list.py │ │ │ │ └── my_list.py │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.py │ │ │ │ ├── permutations_i.py │ │ │ │ ├── permutations_ii.py │ │ │ │ ├── preorder_traversal_i_compact.py │ │ │ │ ├── preorder_traversal_ii_compact.py │ │ │ │ ├── preorder_traversal_iii_compact.py │ │ │ │ ├── preorder_traversal_iii_template.py │ │ │ │ ├── subset_sum_i.py │ │ │ │ ├── subset_sum_i_naive.py │ │ │ │ └── subset_sum_ii.py │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.py │ │ │ │ ├── recursion.py │ │ │ │ ├── space_complexity.py │ │ │ │ ├── time_complexity.py │ │ │ │ └── worst_best_time_complexity.py │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.py │ │ │ │ ├── build_tree.py │ │ │ │ └── hanota.py │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.py │ │ │ │ ├── climbing_stairs_constraint_dp.py │ │ │ │ ├── climbing_stairs_dfs.py │ │ │ │ ├── climbing_stairs_dfs_mem.py │ │ │ │ ├── climbing_stairs_dp.py │ │ │ │ ├── coin_change.py │ │ │ │ ├── coin_change_ii.py │ │ │ │ ├── edit_distance.py │ │ │ │ ├── knapsack.py │ │ │ │ ├── min_cost_climbing_stairs_dp.py │ │ │ │ ├── min_path_sum.py │ │ │ │ └── unbounded_knapsack.py │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.py │ │ │ │ ├── graph_adjacency_matrix.py │ │ │ │ ├── graph_bfs.py │ │ │ │ └── graph_dfs.py │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.py │ │ │ │ ├── fractional_knapsack.py │ │ │ │ ├── max_capacity.py │ │ │ │ └── max_product_cutting.py │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.py │ │ │ │ ├── built_in_hash.py │ │ │ │ ├── hash_map.py │ │ │ │ ├── hash_map_chaining.py │ │ │ │ ├── hash_map_open_addressing.py │ │ │ │ └── simple_hash.py │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.py │ │ │ │ ├── my_heap.py │ │ │ │ └── top_k.py │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.py │ │ │ │ ├── binary_search_edge.py │ │ │ │ ├── binary_search_insertion.py │ │ │ │ ├── hashing_search.py │ │ │ │ ├── linear_search.py │ │ │ │ └── two_sum.py │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.py │ │ │ │ ├── bucket_sort.py │ │ │ │ ├── counting_sort.py │ │ │ │ ├── heap_sort.py │ │ │ │ ├── insertion_sort.py │ │ │ │ ├── merge_sort.py │ │ │ │ ├── quick_sort.py │ │ │ │ ├── radix_sort.py │ │ │ │ └── selection_sort.py │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.py │ │ │ │ ├── array_queue.py │ │ │ │ ├── array_stack.py │ │ │ │ ├── deque.py │ │ │ │ ├── linkedlist_deque.py │ │ │ │ ├── linkedlist_queue.py │ │ │ │ ├── linkedlist_stack.py │ │ │ │ ├── queue.py │ │ │ │ └── stack.py │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.py │ │ │ │ ├── avl_tree.py │ │ │ │ ├── binary_search_tree.py │ │ │ │ ├── binary_tree.py │ │ │ │ ├── binary_tree_bfs.py │ │ │ │ └── binary_tree_dfs.py │ │ │ ├── modules/ │ │ │ │ ├── __init__.py │ │ │ │ ├── list_node.py │ │ │ │ ├── print_util.py │ │ │ │ ├── tree_node.py │ │ │ │ └── vertex.py │ │ │ └── test_all.py │ │ ├── pythontutor/ │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.md │ │ │ │ ├── linked_list.md │ │ │ │ └── my_list.md │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.md │ │ │ │ ├── permutations_i.md │ │ │ │ ├── permutations_ii.md │ │ │ │ ├── preorder_traversal_i_compact.md │ │ │ │ ├── preorder_traversal_ii_compact.md │ │ │ │ ├── preorder_traversal_iii_compact.md │ │ │ │ ├── preorder_traversal_iii_template.md │ │ │ │ ├── subset_sum_i.md │ │ │ │ ├── subset_sum_i_naive.md │ │ │ │ └── subset_sum_ii.md │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.md │ │ │ │ ├── recursion.md │ │ │ │ ├── space_complexity.md │ │ │ │ ├── time_complexity.md │ │ │ │ └── worst_best_time_complexity.md │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.md │ │ │ │ ├── build_tree.md │ │ │ │ └── hanota.md │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.md │ │ │ │ ├── climbing_stairs_constraint_dp.md │ │ │ │ ├── climbing_stairs_dfs.md │ │ │ │ ├── climbing_stairs_dfs_mem.md │ │ │ │ ├── climbing_stairs_dp.md │ │ │ │ ├── coin_change.md │ │ │ │ ├── coin_change_ii.md │ │ │ │ ├── edit_distance.md │ │ │ │ ├── knapsack.md │ │ │ │ ├── min_cost_climbing_stairs_dp.md │ │ │ │ ├── min_path_sum.md │ │ │ │ └── unbounded_knapsack.md │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.md │ │ │ │ ├── graph_adjacency_matrix.md │ │ │ │ ├── graph_bfs.md │ │ │ │ └── graph_dfs.md │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.md │ │ │ │ ├── fractional_knapsack.md │ │ │ │ ├── max_capacity.md │ │ │ │ └── max_product_cutting.md │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.md │ │ │ │ ├── hash_map_chaining.md │ │ │ │ └── simple_hash.md │ │ │ ├── chapter_heap/ │ │ │ │ ├── my_heap.md │ │ │ │ └── top_k.md │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.md │ │ │ │ ├── binary_search_edge.md │ │ │ │ ├── binary_search_insertion.md │ │ │ │ └── two_sum.md │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.md │ │ │ │ ├── bucket_sort.md │ │ │ │ ├── counting_sort.md │ │ │ │ ├── heap_sort.md │ │ │ │ ├── insertion_sort.md │ │ │ │ ├── merge_sort.md │ │ │ │ ├── quick_sort.md │ │ │ │ ├── radix_sort.md │ │ │ │ └── selection_sort.md │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_queue.md │ │ │ │ ├── array_stack.md │ │ │ │ ├── linkedlist_queue.md │ │ │ │ └── linkedlist_stack.md │ │ │ └── chapter_tree/ │ │ │ ├── array_binary_tree.md │ │ │ ├── binary_search_tree.md │ │ │ ├── binary_tree_bfs.md │ │ │ └── binary_tree_dfs.md │ │ ├── ruby/ │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.rb │ │ │ │ ├── linked_list.rb │ │ │ │ ├── list.rb │ │ │ │ └── my_list.rb │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.rb │ │ │ │ ├── permutations_i.rb │ │ │ │ ├── permutations_ii.rb │ │ │ │ ├── preorder_traversal_i_compact.rb │ │ │ │ ├── preorder_traversal_ii_compact.rb │ │ │ │ ├── preorder_traversal_iii_compact.rb │ │ │ │ ├── preorder_traversal_iii_template.rb │ │ │ │ ├── subset_sum_i.rb │ │ │ │ ├── subset_sum_i_naive.rb │ │ │ │ └── subset_sum_ii.rb │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.rb │ │ │ │ ├── recursion.rb │ │ │ │ ├── space_complexity.rb │ │ │ │ ├── time_complexity.rb │ │ │ │ └── worst_best_time_complexity.rb │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.rb │ │ │ │ ├── build_tree.rb │ │ │ │ └── hanota.rb │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.rb │ │ │ │ ├── climbing_stairs_constraint_dp.rb │ │ │ │ ├── climbing_stairs_dfs.rb │ │ │ │ ├── climbing_stairs_dfs_mem.rb │ │ │ │ ├── climbing_stairs_dp.rb │ │ │ │ ├── coin_change.rb │ │ │ │ ├── coin_change_ii.rb │ │ │ │ ├── edit_distance.rb │ │ │ │ ├── knapsack.rb │ │ │ │ ├── min_cost_climbing_stairs_dp.rb │ │ │ │ ├── min_path_sum.rb │ │ │ │ └── unbounded_knapsack.rb │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.rb │ │ │ │ ├── graph_adjacency_matrix.rb │ │ │ │ ├── graph_bfs.rb │ │ │ │ └── graph_dfs.rb │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.rb │ │ │ │ ├── fractional_knapsack.rb │ │ │ │ ├── max_capacity.rb │ │ │ │ └── max_product_cutting.rb │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.rb │ │ │ │ ├── built_in_hash.rb │ │ │ │ ├── hash_map.rb │ │ │ │ ├── hash_map_chaining.rb │ │ │ │ ├── hash_map_open_addressing.rb │ │ │ │ └── simple_hash.rb │ │ │ ├── chapter_heap/ │ │ │ │ ├── my_heap.rb │ │ │ │ └── top_k.rb │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.rb │ │ │ │ ├── binary_search_edge.rb │ │ │ │ ├── binary_search_insertion.rb │ │ │ │ ├── hashing_search.rb │ │ │ │ ├── linear_search.rb │ │ │ │ └── two_sum.rb │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.rb │ │ │ │ ├── bucket_sort.rb │ │ │ │ ├── counting_sort.rb │ │ │ │ ├── heap_sort.rb │ │ │ │ ├── insertion_sort.rb │ │ │ │ ├── merge_sort.rb │ │ │ │ ├── quick_sort.rb │ │ │ │ ├── radix_sort.rb │ │ │ │ └── selection_sort.rb │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.rb │ │ │ │ ├── array_queue.rb │ │ │ │ ├── array_stack.rb │ │ │ │ ├── deque.rb │ │ │ │ ├── linkedlist_deque.rb │ │ │ │ ├── linkedlist_queue.rb │ │ │ │ ├── linkedlist_stack.rb │ │ │ │ ├── queue.rb │ │ │ │ └── stack.rb │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.rb │ │ │ │ ├── avl_tree.rb │ │ │ │ ├── binary_search_tree.rb │ │ │ │ ├── binary_tree.rb │ │ │ │ ├── binary_tree_bfs.rb │ │ │ │ └── binary_tree_dfs.rb │ │ │ ├── test_all.rb │ │ │ └── utils/ │ │ │ ├── list_node.rb │ │ │ ├── print_util.rb │ │ │ ├── tree_node.rb │ │ │ └── vertex.rb │ │ ├── rust/ │ │ │ ├── .gitignore │ │ │ ├── Cargo.toml │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.rs │ │ │ │ ├── linked_list.rs │ │ │ │ ├── list.rs │ │ │ │ └── my_list.rs │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.rs │ │ │ │ ├── permutations_i.rs │ │ │ │ ├── permutations_ii.rs │ │ │ │ ├── preorder_traversal_i_compact.rs │ │ │ │ ├── preorder_traversal_ii_compact.rs │ │ │ │ ├── preorder_traversal_iii_compact.rs │ │ │ │ ├── preorder_traversal_iii_template.rs │ │ │ │ ├── subset_sum_i.rs │ │ │ │ ├── subset_sum_i_naive.rs │ │ │ │ └── subset_sum_ii.rs │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.rs │ │ │ │ ├── recursion.rs │ │ │ │ ├── space_complexity.rs │ │ │ │ ├── time_complexity.rs │ │ │ │ └── worst_best_time_complexity.rs │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.rs │ │ │ │ ├── build_tree.rs │ │ │ │ └── hanota.rs │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.rs │ │ │ │ ├── climbing_stairs_constraint_dp.rs │ │ │ │ ├── climbing_stairs_dfs.rs │ │ │ │ ├── climbing_stairs_dfs_mem.rs │ │ │ │ ├── climbing_stairs_dp.rs │ │ │ │ ├── coin_change.rs │ │ │ │ ├── coin_change_ii.rs │ │ │ │ ├── edit_distance.rs │ │ │ │ ├── knapsack.rs │ │ │ │ ├── min_cost_climbing_stairs_dp.rs │ │ │ │ ├── min_path_sum.rs │ │ │ │ └── unbounded_knapsack.rs │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.rs │ │ │ │ ├── graph_adjacency_matrix.rs │ │ │ │ ├── graph_bfs.rs │ │ │ │ └── graph_dfs.rs │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.rs │ │ │ │ ├── fractional_knapsack.rs │ │ │ │ ├── max_capacity.rs │ │ │ │ └── max_product_cutting.rs │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.rs │ │ │ │ ├── build_in_hash.rs │ │ │ │ ├── hash_map.rs │ │ │ │ ├── hash_map_chaining.rs │ │ │ │ ├── hash_map_open_addressing.rs │ │ │ │ └── simple_hash.rs │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.rs │ │ │ │ ├── my_heap.rs │ │ │ │ └── top_k.rs │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.rs │ │ │ │ ├── binary_search_edge.rs │ │ │ │ ├── binary_search_insertion.rs │ │ │ │ ├── hashing_search.rs │ │ │ │ ├── linear_search.rs │ │ │ │ └── two_sum.rs │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.rs │ │ │ │ ├── bucket_sort.rs │ │ │ │ ├── counting_sort.rs │ │ │ │ ├── heap_sort.rs │ │ │ │ ├── insertion_sort.rs │ │ │ │ ├── merge_sort.rs │ │ │ │ ├── quick_sort.rs │ │ │ │ ├── radix_sort.rs │ │ │ │ └── selection_sort.rs │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.rs │ │ │ │ ├── array_queue.rs │ │ │ │ ├── array_stack.rs │ │ │ │ ├── deque.rs │ │ │ │ ├── linkedlist_deque.rs │ │ │ │ ├── linkedlist_queue.rs │ │ │ │ ├── linkedlist_stack.rs │ │ │ │ ├── queue.rs │ │ │ │ └── stack.rs │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.rs │ │ │ │ ├── avl_tree.rs │ │ │ │ ├── binary_search_tree.rs │ │ │ │ ├── binary_tree.rs │ │ │ │ ├── binary_tree_bfs.rs │ │ │ │ └── binary_tree_dfs.rs │ │ │ └── src/ │ │ │ ├── include/ │ │ │ │ ├── list_node.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── print_util.rs │ │ │ │ ├── tree_node.rs │ │ │ │ └── vertex.rs │ │ │ └── lib.rs │ │ ├── swift/ │ │ │ ├── .gitignore │ │ │ ├── Package.resolved │ │ │ ├── Package.swift │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.swift │ │ │ │ ├── linked_list.swift │ │ │ │ ├── list.swift │ │ │ │ └── my_list.swift │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.swift │ │ │ │ ├── permutations_i.swift │ │ │ │ ├── permutations_ii.swift │ │ │ │ ├── preorder_traversal_i_compact.swift │ │ │ │ ├── preorder_traversal_ii_compact.swift │ │ │ │ ├── preorder_traversal_iii_compact.swift │ │ │ │ ├── preorder_traversal_iii_template.swift │ │ │ │ ├── subset_sum_i.swift │ │ │ │ ├── subset_sum_i_naive.swift │ │ │ │ └── subset_sum_ii.swift │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.swift │ │ │ │ ├── recursion.swift │ │ │ │ ├── space_complexity.swift │ │ │ │ ├── time_complexity.swift │ │ │ │ └── worst_best_time_complexity.swift │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.swift │ │ │ │ ├── build_tree.swift │ │ │ │ └── hanota.swift │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.swift │ │ │ │ ├── climbing_stairs_constraint_dp.swift │ │ │ │ ├── climbing_stairs_dfs.swift │ │ │ │ ├── climbing_stairs_dfs_mem.swift │ │ │ │ ├── climbing_stairs_dp.swift │ │ │ │ ├── coin_change.swift │ │ │ │ ├── coin_change_ii.swift │ │ │ │ ├── edit_distance.swift │ │ │ │ ├── knapsack.swift │ │ │ │ ├── min_cost_climbing_stairs_dp.swift │ │ │ │ ├── min_path_sum.swift │ │ │ │ └── unbounded_knapsack.swift │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.swift │ │ │ │ ├── graph_adjacency_list_target.swift │ │ │ │ ├── graph_adjacency_matrix.swift │ │ │ │ ├── graph_bfs.swift │ │ │ │ └── graph_dfs.swift │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.swift │ │ │ │ ├── fractional_knapsack.swift │ │ │ │ ├── max_capacity.swift │ │ │ │ └── max_product_cutting.swift │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.swift │ │ │ │ ├── built_in_hash.swift │ │ │ │ ├── hash_map.swift │ │ │ │ ├── hash_map_chaining.swift │ │ │ │ ├── hash_map_open_addressing.swift │ │ │ │ └── simple_hash.swift │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.swift │ │ │ │ ├── my_heap.swift │ │ │ │ └── top_k.swift │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.swift │ │ │ │ ├── binary_search_edge.swift │ │ │ │ ├── binary_search_insertion.swift │ │ │ │ ├── binary_search_insertion_target.swift │ │ │ │ ├── hashing_search.swift │ │ │ │ ├── linear_search.swift │ │ │ │ └── two_sum.swift │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.swift │ │ │ │ ├── bucket_sort.swift │ │ │ │ ├── counting_sort.swift │ │ │ │ ├── heap_sort.swift │ │ │ │ ├── insertion_sort.swift │ │ │ │ ├── merge_sort.swift │ │ │ │ ├── quick_sort.swift │ │ │ │ ├── radix_sort.swift │ │ │ │ └── selection_sort.swift │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.swift │ │ │ │ ├── array_queue.swift │ │ │ │ ├── array_stack.swift │ │ │ │ ├── deque.swift │ │ │ │ ├── linkedlist_deque.swift │ │ │ │ ├── linkedlist_queue.swift │ │ │ │ ├── linkedlist_stack.swift │ │ │ │ ├── queue.swift │ │ │ │ └── stack.swift │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.swift │ │ │ │ ├── avl_tree.swift │ │ │ │ ├── binary_search_tree.swift │ │ │ │ ├── binary_tree.swift │ │ │ │ ├── binary_tree_bfs.swift │ │ │ │ └── binary_tree_dfs.swift │ │ │ └── utils/ │ │ │ ├── ListNode.swift │ │ │ ├── Pair.swift │ │ │ ├── PrintUtil.swift │ │ │ ├── TreeNode.swift │ │ │ └── Vertex.swift │ │ ├── typescript/ │ │ │ ├── .gitignore │ │ │ ├── .prettierrc │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.ts │ │ │ │ ├── linked_list.ts │ │ │ │ ├── list.ts │ │ │ │ └── my_list.ts │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.ts │ │ │ │ ├── permutations_i.ts │ │ │ │ ├── permutations_ii.ts │ │ │ │ ├── preorder_traversal_i_compact.ts │ │ │ │ ├── preorder_traversal_ii_compact.ts │ │ │ │ ├── preorder_traversal_iii_compact.ts │ │ │ │ ├── preorder_traversal_iii_template.ts │ │ │ │ ├── subset_sum_i.ts │ │ │ │ ├── subset_sum_i_naive.ts │ │ │ │ └── subset_sum_ii.ts │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.ts │ │ │ │ ├── recursion.ts │ │ │ │ ├── space_complexity.ts │ │ │ │ ├── time_complexity.ts │ │ │ │ └── worst_best_time_complexity.ts │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.ts │ │ │ │ ├── build_tree.ts │ │ │ │ └── hanota.ts │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.ts │ │ │ │ ├── climbing_stairs_constraint_dp.ts │ │ │ │ ├── climbing_stairs_dfs.ts │ │ │ │ ├── climbing_stairs_dfs_mem.ts │ │ │ │ ├── climbing_stairs_dp.ts │ │ │ │ ├── coin_change.ts │ │ │ │ ├── coin_change_ii.ts │ │ │ │ ├── edit_distance.ts │ │ │ │ ├── knapsack.ts │ │ │ │ ├── min_cost_climbing_stairs_dp.ts │ │ │ │ ├── min_path_sum.ts │ │ │ │ └── unbounded_knapsack.ts │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.ts │ │ │ │ ├── graph_adjacency_matrix.ts │ │ │ │ ├── graph_bfs.ts │ │ │ │ └── graph_dfs.ts │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.ts │ │ │ │ ├── fractional_knapsack.ts │ │ │ │ ├── max_capacity.ts │ │ │ │ └── max_product_cutting.ts │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.ts │ │ │ │ ├── hash_map.ts │ │ │ │ ├── hash_map_chaining.ts │ │ │ │ ├── hash_map_open_addressing.ts │ │ │ │ └── simple_hash.ts │ │ │ ├── chapter_heap/ │ │ │ │ ├── my_heap.ts │ │ │ │ └── top_k.ts │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.ts │ │ │ │ ├── binary_search_edge.ts │ │ │ │ ├── binary_search_insertion.ts │ │ │ │ ├── hashing_search.ts │ │ │ │ ├── linear_search.ts │ │ │ │ └── two_sum.ts │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.ts │ │ │ │ ├── bucket_sort.ts │ │ │ │ ├── counting_sort.ts │ │ │ │ ├── heap_sort.ts │ │ │ │ ├── insertion_sort.ts │ │ │ │ ├── merge_sort.ts │ │ │ │ ├── quick_sort.ts │ │ │ │ ├── radix_sort.ts │ │ │ │ └── selection_sort.ts │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.ts │ │ │ │ ├── array_queue.ts │ │ │ │ ├── array_stack.ts │ │ │ │ ├── deque.ts │ │ │ │ ├── linkedlist_deque.ts │ │ │ │ ├── linkedlist_queue.ts │ │ │ │ ├── linkedlist_stack.ts │ │ │ │ ├── queue.ts │ │ │ │ └── stack.ts │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.ts │ │ │ │ ├── avl_tree.ts │ │ │ │ ├── binary_search_tree.ts │ │ │ │ ├── binary_tree.ts │ │ │ │ ├── binary_tree_bfs.ts │ │ │ │ └── binary_tree_dfs.ts │ │ │ ├── modules/ │ │ │ │ ├── ListNode.ts │ │ │ │ ├── PrintUtil.ts │ │ │ │ ├── TreeNode.ts │ │ │ │ └── Vertex.ts │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ └── zig/ │ │ ├── .gitignore │ │ ├── build.zig │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.zig │ │ │ ├── linked_list.zig │ │ │ ├── list.zig │ │ │ └── my_list.zig │ │ ├── chapter_computational_complexity/ │ │ │ ├── iteration.zig │ │ │ ├── recursion.zig │ │ │ ├── space_complexity.zig │ │ │ ├── time_complexity.zig │ │ │ └── worst_best_time_complexity.zig │ │ ├── chapter_dynamic_programming/ │ │ │ ├── climbing_stairs_backtrack.zig │ │ │ ├── climbing_stairs_constraint_dp.zig │ │ │ ├── climbing_stairs_dfs.zig │ │ │ ├── climbing_stairs_dfs_mem.zig │ │ │ ├── climbing_stairs_dp.zig │ │ │ ├── coin_change.zig │ │ │ ├── coin_change_ii.zig │ │ │ ├── edit_distance.zig │ │ │ ├── knapsack.zig │ │ │ ├── min_cost_climbing_stairs_dp.zig │ │ │ ├── min_path_sum.zig │ │ │ └── unbounded_knapsack.zig │ │ ├── chapter_hashing/ │ │ │ ├── array_hash_map.zig │ │ │ └── hash_map.zig │ │ ├── chapter_heap/ │ │ │ ├── heap.zig │ │ │ └── my_heap.zig │ │ ├── chapter_searching/ │ │ │ ├── binary_search.zig │ │ │ ├── hashing_search.zig │ │ │ ├── linear_search.zig │ │ │ └── two_sum.zig │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.zig │ │ │ ├── insertion_sort.zig │ │ │ ├── merge_sort.zig │ │ │ ├── quick_sort.zig │ │ │ └── radix_sort.zig │ │ ├── chapter_stack_and_queue/ │ │ │ ├── array_queue.zig │ │ │ ├── array_stack.zig │ │ │ ├── deque.zig │ │ │ ├── linkedlist_deque.zig │ │ │ ├── linkedlist_queue.zig │ │ │ ├── linkedlist_stack.zig │ │ │ ├── queue.zig │ │ │ └── stack.zig │ │ ├── chapter_tree/ │ │ │ ├── avl_tree.zig │ │ │ ├── binary_search_tree.zig │ │ │ ├── binary_tree.zig │ │ │ ├── binary_tree_bfs.zig │ │ │ └── binary_tree_dfs.zig │ │ ├── include/ │ │ │ ├── PrintUtil.zig │ │ │ └── include.zig │ │ ├── main.zig │ │ └── utils/ │ │ ├── ListNode.zig │ │ ├── TreeNode.zig │ │ ├── format.zig │ │ └── utils.zig │ ├── docs/ │ │ ├── chapter_appendix/ │ │ │ ├── contribution.md │ │ │ ├── index.md │ │ │ ├── installation.md │ │ │ └── terminology.md │ │ ├── chapter_array_and_linkedlist/ │ │ │ ├── array.md │ │ │ ├── index.md │ │ │ ├── linked_list.md │ │ │ ├── list.md │ │ │ ├── ram_and_cache.md │ │ │ └── summary.md │ │ ├── chapter_backtracking/ │ │ │ ├── backtracking_algorithm.md │ │ │ ├── index.md │ │ │ ├── n_queens_problem.md │ │ │ ├── permutations_problem.md │ │ │ ├── subset_sum_problem.md │ │ │ └── summary.md │ │ ├── chapter_computational_complexity/ │ │ │ ├── index.md │ │ │ ├── iteration_and_recursion.md │ │ │ ├── performance_evaluation.md │ │ │ ├── space_complexity.md │ │ │ ├── summary.md │ │ │ └── time_complexity.md │ │ ├── chapter_data_structure/ │ │ │ ├── basic_data_types.md │ │ │ ├── character_encoding.md │ │ │ ├── classification_of_data_structure.md │ │ │ ├── index.md │ │ │ ├── number_encoding.md │ │ │ └── summary.md │ │ ├── chapter_divide_and_conquer/ │ │ │ ├── binary_search_recur.md │ │ │ ├── build_binary_tree_problem.md │ │ │ ├── divide_and_conquer.md │ │ │ ├── hanota_problem.md │ │ │ ├── index.md │ │ │ └── summary.md │ │ ├── chapter_dynamic_programming/ │ │ │ ├── dp_problem_features.md │ │ │ ├── dp_solution_pipeline.md │ │ │ ├── edit_distance_problem.md │ │ │ ├── index.md │ │ │ ├── intro_to_dynamic_programming.md │ │ │ ├── knapsack_problem.md │ │ │ ├── summary.md │ │ │ └── unbounded_knapsack_problem.md │ │ ├── chapter_graph/ │ │ │ ├── graph.md │ │ │ ├── graph_operations.md │ │ │ ├── graph_traversal.md │ │ │ ├── index.md │ │ │ └── summary.md │ │ ├── chapter_greedy/ │ │ │ ├── fractional_knapsack_problem.md │ │ │ ├── greedy_algorithm.md │ │ │ ├── index.md │ │ │ ├── max_capacity_problem.md │ │ │ ├── max_product_cutting_problem.md │ │ │ └── summary.md │ │ ├── chapter_hashing/ │ │ │ ├── hash_algorithm.md │ │ │ ├── hash_collision.md │ │ │ ├── hash_map.md │ │ │ ├── index.md │ │ │ └── summary.md │ │ ├── chapter_heap/ │ │ │ ├── build_heap.md │ │ │ ├── heap.md │ │ │ ├── index.md │ │ │ ├── summary.md │ │ │ └── top_k.md │ │ ├── chapter_hello_algo/ │ │ │ └── index.md │ │ ├── chapter_introduction/ │ │ │ ├── algorithms_are_everywhere.md │ │ │ ├── index.md │ │ │ ├── summary.md │ │ │ └── what_is_dsa.md │ │ ├── chapter_paperbook/ │ │ │ └── index.md │ │ ├── chapter_preface/ │ │ │ ├── about_the_book.md │ │ │ ├── index.md │ │ │ ├── suggestions.md │ │ │ └── summary.md │ │ ├── chapter_reference/ │ │ │ └── index.md │ │ ├── chapter_searching/ │ │ │ ├── binary_search.md │ │ │ ├── binary_search_edge.md │ │ │ ├── binary_search_insertion.md │ │ │ ├── index.md │ │ │ ├── replace_linear_by_hashing.md │ │ │ ├── searching_algorithm_revisited.md │ │ │ └── summary.md │ │ ├── chapter_sorting/ │ │ │ ├── bubble_sort.md │ │ │ ├── bucket_sort.md │ │ │ ├── counting_sort.md │ │ │ ├── heap_sort.md │ │ │ ├── index.md │ │ │ ├── insertion_sort.md │ │ │ ├── merge_sort.md │ │ │ ├── quick_sort.md │ │ │ ├── radix_sort.md │ │ │ ├── selection_sort.md │ │ │ ├── sorting_algorithm.md │ │ │ └── summary.md │ │ ├── chapter_stack_and_queue/ │ │ │ ├── deque.md │ │ │ ├── index.md │ │ │ ├── queue.md │ │ │ ├── stack.md │ │ │ └── summary.md │ │ ├── chapter_tree/ │ │ │ ├── array_representation_of_tree.md │ │ │ ├── avl_tree.md │ │ │ ├── binary_search_tree.md │ │ │ ├── binary_tree.md │ │ │ ├── binary_tree_traversal.md │ │ │ ├── index.md │ │ │ └── summary.md │ │ ├── index.html │ │ └── index.md │ └── mkdocs.yml ├── mkdocs.yml ├── overrides/ │ ├── javascripts/ │ │ ├── katex.js │ │ ├── mathjax.js │ │ └── starfield.js │ ├── main.html │ ├── partials/ │ │ ├── LICENSE │ │ ├── actions.html │ │ ├── comments.html │ │ └── content.html │ ├── stylesheets/ │ │ ├── extra.css │ │ ├── giscus-dark.css │ │ └── giscus-light.css │ └── zensical/ │ ├── javascripts/ │ │ └── animation_player.js │ ├── stylesheets/ │ │ ├── animation_player.css │ │ └── extra.css │ └── zensical.toml ├── ru/ │ ├── README.md │ ├── codes/ │ │ ├── Dockerfile │ │ ├── c/ │ │ │ ├── .gitignore │ │ │ ├── CMakeLists.txt │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array.c │ │ │ │ ├── linked_list.c │ │ │ │ └── my_list.c │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── n_queens.c │ │ │ │ ├── permutations_i.c │ │ │ │ ├── permutations_ii.c │ │ │ │ ├── preorder_traversal_i_compact.c │ │ │ │ ├── preorder_traversal_ii_compact.c │ │ │ │ ├── preorder_traversal_iii_compact.c │ │ │ │ ├── preorder_traversal_iii_template.c │ │ │ │ ├── subset_sum_i.c │ │ │ │ ├── subset_sum_i_naive.c │ │ │ │ └── subset_sum_ii.c │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── iteration.c │ │ │ │ ├── recursion.c │ │ │ │ ├── space_complexity.c │ │ │ │ ├── time_complexity.c │ │ │ │ └── worst_best_time_complexity.c │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── binary_search_recur.c │ │ │ │ ├── build_tree.c │ │ │ │ └── hanota.c │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── climbing_stairs_backtrack.c │ │ │ │ ├── climbing_stairs_constraint_dp.c │ │ │ │ ├── climbing_stairs_dfs.c │ │ │ │ ├── climbing_stairs_dfs_mem.c │ │ │ │ ├── climbing_stairs_dp.c │ │ │ │ ├── coin_change.c │ │ │ │ ├── coin_change_ii.c │ │ │ │ ├── edit_distance.c │ │ │ │ ├── knapsack.c │ │ │ │ ├── min_cost_climbing_stairs_dp.c │ │ │ │ ├── min_path_sum.c │ │ │ │ └── unbounded_knapsack.c │ │ │ ├── chapter_graph/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── graph_adjacency_list.c │ │ │ │ ├── graph_adjacency_list_test.c │ │ │ │ ├── graph_adjacency_matrix.c │ │ │ │ ├── graph_bfs.c │ │ │ │ └── graph_dfs.c │ │ │ ├── chapter_greedy/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── coin_change_greedy.c │ │ │ │ ├── fractional_knapsack.c │ │ │ │ ├── max_capacity.c │ │ │ │ └── max_product_cutting.c │ │ │ ├── chapter_hashing/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_hash_map.c │ │ │ │ ├── hash_map_chaining.c │ │ │ │ ├── hash_map_open_addressing.c │ │ │ │ └── simple_hash.c │ │ │ ├── chapter_heap/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── my_heap.c │ │ │ │ ├── my_heap_test.c │ │ │ │ └── top_k.c │ │ │ ├── chapter_searching/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── binary_search.c │ │ │ │ ├── binary_search_edge.c │ │ │ │ ├── binary_search_insertion.c │ │ │ │ └── two_sum.c │ │ │ ├── chapter_sorting/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── bubble_sort.c │ │ │ │ ├── bucket_sort.c │ │ │ │ ├── counting_sort.c │ │ │ │ ├── heap_sort.c │ │ │ │ ├── insertion_sort.c │ │ │ │ ├── merge_sort.c │ │ │ │ ├── quick_sort.c │ │ │ │ ├── radix_sort.c │ │ │ │ └── selection_sort.c │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_deque.c │ │ │ │ ├── array_queue.c │ │ │ │ ├── array_stack.c │ │ │ │ ├── linkedlist_deque.c │ │ │ │ ├── linkedlist_queue.c │ │ │ │ └── linkedlist_stack.c │ │ │ ├── chapter_tree/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_binary_tree.c │ │ │ │ ├── avl_tree.c │ │ │ │ ├── binary_search_tree.c │ │ │ │ ├── binary_tree.c │ │ │ │ ├── binary_tree_bfs.c │ │ │ │ └── binary_tree_dfs.c │ │ │ └── utils/ │ │ │ ├── CMakeLists.txt │ │ │ ├── common.h │ │ │ ├── common_test.c │ │ │ ├── list_node.h │ │ │ ├── print_util.h │ │ │ ├── tree_node.h │ │ │ ├── uthash.h │ │ │ ├── vector.h │ │ │ └── vertex.h │ │ ├── cpp/ │ │ │ ├── .gitignore │ │ │ ├── CMakeLists.txt │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array.cpp │ │ │ │ ├── linked_list.cpp │ │ │ │ ├── list.cpp │ │ │ │ └── my_list.cpp │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── n_queens.cpp │ │ │ │ ├── permutations_i.cpp │ │ │ │ ├── permutations_ii.cpp │ │ │ │ ├── preorder_traversal_i_compact.cpp │ │ │ │ ├── preorder_traversal_ii_compact.cpp │ │ │ │ ├── preorder_traversal_iii_compact.cpp │ │ │ │ ├── preorder_traversal_iii_template.cpp │ │ │ │ ├── subset_sum_i.cpp │ │ │ │ ├── subset_sum_i_naive.cpp │ │ │ │ └── subset_sum_ii.cpp │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── iteration.cpp │ │ │ │ ├── recursion.cpp │ │ │ │ ├── space_complexity.cpp │ │ │ │ ├── time_complexity.cpp │ │ │ │ └── worst_best_time_complexity.cpp │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── binary_search_recur.cpp │ │ │ │ ├── build_tree.cpp │ │ │ │ └── hanota.cpp │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── climbing_stairs_backtrack.cpp │ │ │ │ ├── climbing_stairs_constraint_dp.cpp │ │ │ │ ├── climbing_stairs_dfs.cpp │ │ │ │ ├── climbing_stairs_dfs_mem.cpp │ │ │ │ ├── climbing_stairs_dp.cpp │ │ │ │ ├── coin_change.cpp │ │ │ │ ├── coin_change_ii.cpp │ │ │ │ ├── edit_distance.cpp │ │ │ │ ├── knapsack.cpp │ │ │ │ ├── min_cost_climbing_stairs_dp.cpp │ │ │ │ ├── min_path_sum.cpp │ │ │ │ └── unbounded_knapsack.cpp │ │ │ ├── chapter_graph/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── graph_adjacency_list.cpp │ │ │ │ ├── graph_adjacency_list_test.cpp │ │ │ │ ├── graph_adjacency_matrix.cpp │ │ │ │ ├── graph_bfs.cpp │ │ │ │ └── graph_dfs.cpp │ │ │ ├── chapter_greedy/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── coin_change_greedy.cpp │ │ │ │ ├── fractional_knapsack.cpp │ │ │ │ ├── max_capacity.cpp │ │ │ │ └── max_product_cutting.cpp │ │ │ ├── chapter_hashing/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_hash_map.cpp │ │ │ │ ├── array_hash_map_test.cpp │ │ │ │ ├── built_in_hash.cpp │ │ │ │ ├── hash_map.cpp │ │ │ │ ├── hash_map_chaining.cpp │ │ │ │ ├── hash_map_open_addressing.cpp │ │ │ │ └── simple_hash.cpp │ │ │ ├── chapter_heap/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── heap.cpp │ │ │ │ ├── my_heap.cpp │ │ │ │ └── top_k.cpp │ │ │ ├── chapter_searching/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── binary_search.cpp │ │ │ │ ├── binary_search_edge.cpp │ │ │ │ ├── binary_search_insertion.cpp │ │ │ │ ├── hashing_search.cpp │ │ │ │ ├── linear_search.cpp │ │ │ │ └── two_sum.cpp │ │ │ ├── chapter_sorting/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── bubble_sort.cpp │ │ │ │ ├── bucket_sort.cpp │ │ │ │ ├── counting_sort.cpp │ │ │ │ ├── heap_sort.cpp │ │ │ │ ├── insertion_sort.cpp │ │ │ │ ├── merge_sort.cpp │ │ │ │ ├── quick_sort.cpp │ │ │ │ ├── radix_sort.cpp │ │ │ │ └── selection_sort.cpp │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_deque.cpp │ │ │ │ ├── array_queue.cpp │ │ │ │ ├── array_stack.cpp │ │ │ │ ├── deque.cpp │ │ │ │ ├── linkedlist_deque.cpp │ │ │ │ ├── linkedlist_queue.cpp │ │ │ │ ├── linkedlist_stack.cpp │ │ │ │ ├── queue.cpp │ │ │ │ └── stack.cpp │ │ │ ├── chapter_tree/ │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── array_binary_tree.cpp │ │ │ │ ├── avl_tree.cpp │ │ │ │ ├── binary_search_tree.cpp │ │ │ │ ├── binary_tree.cpp │ │ │ │ ├── binary_tree_bfs.cpp │ │ │ │ └── binary_tree_dfs.cpp │ │ │ └── utils/ │ │ │ ├── CMakeLists.txt │ │ │ ├── common.hpp │ │ │ ├── list_node.hpp │ │ │ ├── print_utils.hpp │ │ │ ├── tree_node.hpp │ │ │ └── vertex.hpp │ │ ├── csharp/ │ │ │ ├── .editorconfig │ │ │ ├── .gitignore │ │ │ ├── GlobalUsing.cs │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.cs │ │ │ │ ├── linked_list.cs │ │ │ │ ├── list.cs │ │ │ │ └── my_list.cs │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.cs │ │ │ │ ├── permutations_i.cs │ │ │ │ ├── permutations_ii.cs │ │ │ │ ├── preorder_traversal_i_compact.cs │ │ │ │ ├── preorder_traversal_ii_compact.cs │ │ │ │ ├── preorder_traversal_iii_compact.cs │ │ │ │ ├── preorder_traversal_iii_template.cs │ │ │ │ ├── subset_sum_i.cs │ │ │ │ ├── subset_sum_i_naive.cs │ │ │ │ └── subset_sum_ii.cs │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.cs │ │ │ │ ├── recursion.cs │ │ │ │ ├── space_complexity.cs │ │ │ │ ├── time_complexity.cs │ │ │ │ └── worst_best_time_complexity.cs │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.cs │ │ │ │ ├── build_tree.cs │ │ │ │ └── hanota.cs │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.cs │ │ │ │ ├── climbing_stairs_constraint_dp.cs │ │ │ │ ├── climbing_stairs_dfs.cs │ │ │ │ ├── climbing_stairs_dfs_mem.cs │ │ │ │ ├── climbing_stairs_dp.cs │ │ │ │ ├── coin_change.cs │ │ │ │ ├── coin_change_ii.cs │ │ │ │ ├── edit_distance.cs │ │ │ │ ├── knapsack.cs │ │ │ │ ├── min_cost_climbing_stairs_dp.cs │ │ │ │ ├── min_path_sum.cs │ │ │ │ └── unbounded_knapsack.cs │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.cs │ │ │ │ ├── graph_adjacency_matrix.cs │ │ │ │ ├── graph_bfs.cs │ │ │ │ └── graph_dfs.cs │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.cs │ │ │ │ ├── fractional_knapsack.cs │ │ │ │ ├── max_capacity.cs │ │ │ │ └── max_product_cutting.cs │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.cs │ │ │ │ ├── built_in_hash.cs │ │ │ │ ├── hash_map.cs │ │ │ │ ├── hash_map_chaining.cs │ │ │ │ ├── hash_map_open_addressing.cs │ │ │ │ └── simple_hash.cs │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.cs │ │ │ │ ├── my_heap.cs │ │ │ │ └── top_k.cs │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.cs │ │ │ │ ├── binary_search_edge.cs │ │ │ │ ├── binary_search_insertion.cs │ │ │ │ ├── hashing_search.cs │ │ │ │ ├── linear_search.cs │ │ │ │ └── two_sum.cs │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.cs │ │ │ │ ├── bucket_sort.cs │ │ │ │ ├── counting_sort.cs │ │ │ │ ├── heap_sort.cs │ │ │ │ ├── insertion_sort.cs │ │ │ │ ├── merge_sort.cs │ │ │ │ ├── quick_sort.cs │ │ │ │ ├── radix_sort.cs │ │ │ │ └── selection_sort.cs │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.cs │ │ │ │ ├── array_queue.cs │ │ │ │ ├── array_stack.cs │ │ │ │ ├── deque.cs │ │ │ │ ├── linkedlist_deque.cs │ │ │ │ ├── linkedlist_queue.cs │ │ │ │ ├── linkedlist_stack.cs │ │ │ │ ├── queue.cs │ │ │ │ └── stack.cs │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.cs │ │ │ │ ├── avl_tree.cs │ │ │ │ ├── binary_search_tree.cs │ │ │ │ ├── binary_tree.cs │ │ │ │ ├── binary_tree_bfs.cs │ │ │ │ └── binary_tree_dfs.cs │ │ │ ├── csharp.sln │ │ │ ├── hello-algo.csproj │ │ │ └── utils/ │ │ │ ├── ListNode.cs │ │ │ ├── PrintUtil.cs │ │ │ ├── TreeNode.cs │ │ │ └── Vertex.cs │ │ ├── dart/ │ │ │ ├── build.dart │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.dart │ │ │ │ ├── linked_list.dart │ │ │ │ ├── list.dart │ │ │ │ └── my_list.dart │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.dart │ │ │ │ ├── permutations_i.dart │ │ │ │ ├── permutations_ii.dart │ │ │ │ ├── preorder_traversal_i_compact.dart │ │ │ │ ├── preorder_traversal_ii_compact.dart │ │ │ │ ├── preorder_traversal_iii_compact.dart │ │ │ │ ├── preorder_traversal_iii_template.dart │ │ │ │ ├── subset_sum_i.dart │ │ │ │ ├── subset_sum_i_naive.dart │ │ │ │ └── subset_sum_ii.dart │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.dart │ │ │ │ ├── recursion.dart │ │ │ │ ├── space_complexity.dart │ │ │ │ ├── time_complexity.dart │ │ │ │ └── worst_best_time_complexity.dart │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.dart │ │ │ │ ├── build_tree.dart │ │ │ │ └── hanota.dart │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.dart │ │ │ │ ├── climbing_stairs_constraint_dp.dart │ │ │ │ ├── climbing_stairs_dfs.dart │ │ │ │ ├── climbing_stairs_dfs_mem.dart │ │ │ │ ├── climbing_stairs_dp.dart │ │ │ │ ├── coin_change.dart │ │ │ │ ├── coin_change_ii.dart │ │ │ │ ├── edit_distance.dart │ │ │ │ ├── knapsack.dart │ │ │ │ ├── min_cost_climbing_stairs_dp.dart │ │ │ │ ├── min_path_sum.dart │ │ │ │ └── unbounded_knapsack.dart │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.dart │ │ │ │ ├── graph_adjacency_matrix.dart │ │ │ │ ├── graph_bfs.dart │ │ │ │ └── graph_dfs.dart │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.dart │ │ │ │ ├── fractional_knapsack.dart │ │ │ │ ├── max_capacity.dart │ │ │ │ └── max_product_cutting.dart │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.dart │ │ │ │ ├── built_in_hash.dart │ │ │ │ ├── hash_map.dart │ │ │ │ ├── hash_map_chaining.dart │ │ │ │ ├── hash_map_open_addressing.dart │ │ │ │ └── simple_hash.dart │ │ │ ├── chapter_heap/ │ │ │ │ ├── my_heap.dart │ │ │ │ └── top_k.dart │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.dart │ │ │ │ ├── binary_search_edge.dart │ │ │ │ ├── binary_search_insertion.dart │ │ │ │ ├── hashing_search.dart │ │ │ │ ├── linear_search.dart │ │ │ │ └── two_sum.dart │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.dart │ │ │ │ ├── bucket_sort.dart │ │ │ │ ├── counting_sort.dart │ │ │ │ ├── heap_sort.dart │ │ │ │ ├── insertion_sort.dart │ │ │ │ ├── merge_sort.dart │ │ │ │ ├── quick_sort.dart │ │ │ │ ├── radix_sort.dart │ │ │ │ └── selection_sort.dart │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.dart │ │ │ │ ├── array_queue.dart │ │ │ │ ├── array_stack.dart │ │ │ │ ├── deque.dart │ │ │ │ ├── linkedlist_deque.dart │ │ │ │ ├── linkedlist_queue.dart │ │ │ │ ├── linkedlist_stack.dart │ │ │ │ ├── queue.dart │ │ │ │ └── stack.dart │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.dart │ │ │ │ ├── avl_tree.dart │ │ │ │ ├── binary_search_tree.dart │ │ │ │ ├── binary_tree.dart │ │ │ │ ├── binary_tree_bfs.dart │ │ │ │ └── binary_tree_dfs.dart │ │ │ └── utils/ │ │ │ ├── list_node.dart │ │ │ ├── print_util.dart │ │ │ ├── tree_node.dart │ │ │ └── vertex.dart │ │ ├── docker-compose.yml │ │ ├── go/ │ │ │ ├── chapter_array_and_linkedlist/ │ │ │ │ ├── array.go │ │ │ │ ├── array_test.go │ │ │ │ ├── linked_list.go │ │ │ │ ├── linked_list_test.go │ │ │ │ ├── list_test.go │ │ │ │ ├── my_list.go │ │ │ │ └── my_list_test.go │ │ │ ├── chapter_backtracking/ │ │ │ │ ├── n_queens.go │ │ │ │ ├── n_queens_test.go │ │ │ │ ├── permutation_test.go │ │ │ │ ├── permutations_i.go │ │ │ │ ├── permutations_ii.go │ │ │ │ ├── preorder_traversal_i_compact.go │ │ │ │ ├── preorder_traversal_ii_compact.go │ │ │ │ ├── preorder_traversal_iii_compact.go │ │ │ │ ├── preorder_traversal_iii_template.go │ │ │ │ ├── preorder_traversal_test.go │ │ │ │ ├── subset_sum_i.go │ │ │ │ ├── subset_sum_i_naive.go │ │ │ │ ├── subset_sum_ii.go │ │ │ │ └── subset_sum_test.go │ │ │ ├── chapter_computational_complexity/ │ │ │ │ ├── iteration.go │ │ │ │ ├── iteration_test.go │ │ │ │ ├── recursion.go │ │ │ │ ├── recursion_test.go │ │ │ │ ├── space_complexity.go │ │ │ │ ├── space_complexity_test.go │ │ │ │ ├── time_complexity.go │ │ │ │ ├── time_complexity_test.go │ │ │ │ ├── worst_best_time_complexity.go │ │ │ │ └── worst_best_time_complexity_test.go │ │ │ ├── chapter_divide_and_conquer/ │ │ │ │ ├── binary_search_recur.go │ │ │ │ ├── binary_search_recur_test.go │ │ │ │ ├── build_tree.go │ │ │ │ ├── build_tree_test.go │ │ │ │ ├── hanota.go │ │ │ │ └── hanota_test.go │ │ │ ├── chapter_dynamic_programming/ │ │ │ │ ├── climbing_stairs_backtrack.go │ │ │ │ ├── climbing_stairs_constraint_dp.go │ │ │ │ ├── climbing_stairs_dfs.go │ │ │ │ ├── climbing_stairs_dfs_mem.go │ │ │ │ ├── climbing_stairs_dp.go │ │ │ │ ├── climbing_stairs_test.go │ │ │ │ ├── coin_change.go │ │ │ │ ├── coin_change_ii.go │ │ │ │ ├── coin_change_test.go │ │ │ │ ├── edit_distance.go │ │ │ │ ├── edit_distance_test.go │ │ │ │ ├── knapsack.go │ │ │ │ ├── knapsack_test.go │ │ │ │ ├── min_cost_climbing_stairs_dp.go │ │ │ │ ├── min_path_sum.go │ │ │ │ ├── min_path_sum_test.go │ │ │ │ └── unbounded_knapsack.go │ │ │ ├── chapter_graph/ │ │ │ │ ├── graph_adjacency_list.go │ │ │ │ ├── graph_adjacency_list_test.go │ │ │ │ ├── graph_adjacency_matrix.go │ │ │ │ ├── graph_adjacency_matrix_test.go │ │ │ │ ├── graph_bfs.go │ │ │ │ ├── graph_bfs_test.go │ │ │ │ ├── graph_dfs.go │ │ │ │ └── graph_dfs_test.go │ │ │ ├── chapter_greedy/ │ │ │ │ ├── coin_change_greedy.go │ │ │ │ ├── coin_change_greedy_test.go │ │ │ │ ├── fractional_knapsack.go │ │ │ │ ├── fractional_knapsack_test.go │ │ │ │ ├── max_capacity.go │ │ │ │ ├── max_capacity_test.go │ │ │ │ ├── max_product_cutting.go │ │ │ │ └── max_product_cutting_test.go │ │ │ ├── chapter_hashing/ │ │ │ │ ├── array_hash_map.go │ │ │ │ ├── array_hash_map_test.go │ │ │ │ ├── hash_collision_test.go │ │ │ │ ├── hash_map_chaining.go │ │ │ │ ├── hash_map_open_addressing.go │ │ │ │ ├── hash_map_test.go │ │ │ │ └── simple_hash.go │ │ │ ├── chapter_heap/ │ │ │ │ ├── heap.go │ │ │ │ ├── heap_test.go │ │ │ │ ├── my_heap.go │ │ │ │ └── top_k.go │ │ │ ├── chapter_searching/ │ │ │ │ ├── binary_search.go │ │ │ │ ├── binary_search_edge.go │ │ │ │ ├── binary_search_insertion.go │ │ │ │ ├── binary_search_test.go │ │ │ │ ├── hashing_search.go │ │ │ │ ├── hashing_search_test.go │ │ │ │ ├── linear_search.go │ │ │ │ ├── linear_search_test.go │ │ │ │ ├── two_sum.go │ │ │ │ └── two_sum_test.go │ │ │ ├── chapter_sorting/ │ │ │ │ ├── bubble_sort.go │ │ │ │ ├── bubble_sort_test.go │ │ │ │ ├── bucket_sort.go │ │ │ │ ├── bucket_sort_test.go │ │ │ │ ├── counting_sort.go │ │ │ │ ├── counting_sort_test.go │ │ │ │ ├── heap_sort.go │ │ │ │ ├── heap_sort_test.go │ │ │ │ ├── insertion_sort.go │ │ │ │ ├── insertion_sort_test.go │ │ │ │ ├── merge_sort.go │ │ │ │ ├── merge_sort_test.go │ │ │ │ ├── quick_sort.go │ │ │ │ ├── quick_sort_test.go │ │ │ │ ├── radix_sort.go │ │ │ │ ├── radix_sort_test.go │ │ │ │ ├── selection_sort.go │ │ │ │ └── selection_sort_test.go │ │ │ ├── chapter_stack_and_queue/ │ │ │ │ ├── array_deque.go │ │ │ │ ├── array_queue.go │ │ │ │ ├── array_stack.go │ │ │ │ ├── deque_test.go │ │ │ │ ├── linkedlist_deque.go │ │ │ │ ├── linkedlist_queue.go │ │ │ │ ├── linkedlist_stack.go │ │ │ │ ├── queue_test.go │ │ │ │ └── stack_test.go │ │ │ ├── chapter_tree/ │ │ │ │ ├── array_binary_tree.go │ │ │ │ ├── array_binary_tree_test.go │ │ │ │ ├── avl_tree.go │ │ │ │ ├── avl_tree_test.go │ │ │ │ ├── binary_search_tree.go │ │ │ │
Showing preview only (1,798K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (22693 symbols across 4765 files)
FILE: codes/c/chapter_array_and_linkedlist/array.c
function randomAccess (line 10) | int randomAccess(int *nums, int size) {
function insert (line 35) | void insert(int *nums, int size, int num, int index) {
function removeItem (line 46) | void removeItem(int *nums, int size, int index) {
function traverse (line 54) | void traverse(int *nums, int size) {
function find (line 63) | int find(int *nums, int size, int target) {
function main (line 72) | int main() {
FILE: codes/c/chapter_array_and_linkedlist/linked_list.c
function insert (line 10) | void insert(ListNode *n0, ListNode *P) {
function removeItem (line 18) | void removeItem(ListNode *n0) {
function ListNode (line 30) | ListNode *access(ListNode *head, int index) {
function find (line 40) | int find(ListNode *head, int target) {
function main (line 52) | int main() {
FILE: codes/c/chapter_array_and_linkedlist/my_list.c
type MyList (line 10) | typedef struct {
function MyList (line 20) | MyList *newMyList() {
function delMyList (line 30) | void delMyList(MyList *nums) {
function size (line 36) | int size(MyList *nums) {
function capacity (line 41) | int capacity(MyList *nums) {
function get (line 46) | int get(MyList *nums, int index) {
function set (line 52) | void set(MyList *nums, int index, int num) {
function add (line 58) | void add(MyList *nums, int num) {
function insert (line 67) | void insert(MyList *nums, int index, int num) {
function removeItem (line 82) | int removeItem(MyList *nums, int index) {
function extendCapacity (line 93) | void extendCapacity(MyList *nums) {
function main (line 117) | int main() {
FILE: codes/c/chapter_backtracking/n_queens.c
function backtrack (line 12) | void backtrack(int row, int n, char state[MAX_SIZE][MAX_SIZE], char ***r...
function main (line 64) | int main() {
FILE: codes/c/chapter_backtracking/permutations_i.c
function backtrack (line 13) | void backtrack(int *state, int stateSize, int *choices, int choicesSize,...
function main (line 58) | int main() {
FILE: codes/c/chapter_backtracking/permutations_ii.c
function backtrack (line 13) | void backtrack(int *state, int stateSize, int *choices, int choicesSize,...
function main (line 60) | int main() {
FILE: codes/c/chapter_backtracking/preorder_traversal_i_compact.c
function preOrder (line 16) | void preOrder(TreeNode *root) {
function main (line 29) | int main() {
FILE: codes/c/chapter_backtracking/preorder_traversal_ii_compact.c
function preOrder (line 18) | void preOrder(TreeNode *root) {
function main (line 38) | int main() {
FILE: codes/c/chapter_backtracking/preorder_traversal_iii_compact.c
function preOrder (line 18) | void preOrder(TreeNode *root) {
function main (line 39) | int main() {
FILE: codes/c/chapter_backtracking/preorder_traversal_iii_template.c
function isSolution (line 18) | bool isSolution(void) {
function recordSolution (line 23) | void recordSolution(void) {
function isValid (line 31) | bool isValid(TreeNode *choice) {
function makeChoice (line 36) | void makeChoice(TreeNode *choice) {
function undoChoice (line 41) | void undoChoice(void) {
function backtrack (line 46) | void backtrack(TreeNode *choices[2]) {
function main (line 69) | int main() {
FILE: codes/c/chapter_backtracking/subset_sum_i.c
function backtrack (line 22) | void backtrack(int target, int *choices, int choicesSize, int start) {
function cmp (line 50) | int cmp(const void *a, const void *b) {
function subsetSumI (line 55) | void subsetSumI(int *nums, int numsSize, int target) {
function main (line 62) | int main() {
FILE: codes/c/chapter_backtracking/subset_sum_i_naive.c
function backtrack (line 22) | void backtrack(int target, int total, int *choices, int choicesSize) {
function subsetSumINaive (line 47) | void subsetSumINaive(int *nums, int numsSize, int target) {
function main (line 53) | int main() {
FILE: codes/c/chapter_backtracking/subset_sum_ii.c
function backtrack (line 22) | void backtrack(int target, int *choices, int choicesSize, int start) {
function cmp (line 54) | int cmp(const void *a, const void *b) {
function subsetSumII (line 59) | void subsetSumII(int *nums, int numsSize, int target) {
function main (line 67) | int main() {
FILE: codes/c/chapter_computational_complexity/iteration.c
function forLoop (line 10) | int forLoop(int n) {
function whileLoop (line 20) | int whileLoop(int n) {
function whileLoopII (line 32) | int whileLoopII(int n) {
function main (line 63) | int main() {
FILE: codes/c/chapter_computational_complexity/recursion.c
function recur (line 10) | int recur(int n) {
function forLoopRecur (line 21) | int forLoopRecur(int n) {
function tailRecur (line 40) | int tailRecur(int n, int res) {
function fib (line 49) | int fib(int n) {
function main (line 60) | int main() {
FILE: codes/c/chapter_computational_complexity/space_complexity.c
function func (line 10) | int func() {
function constant (line 16) | void constant(int n) {
type HashTable (line 34) | typedef struct {
function linear (line 41) | void linear(int n) {
function linearRecur (line 75) | void linearRecur(int n) {
function quadratic (line 83) | void quadratic(int n) {
function quadraticRecur (line 102) | int quadraticRecur(int n) {
function TreeNode (line 113) | TreeNode *buildTree(int n) {
function main (line 123) | int main() {
FILE: codes/c/chapter_computational_complexity/time_complexity.c
function constant (line 10) | int constant(int n) {
function linear (line 21) | int linear(int n) {
function arrayTraversal (line 30) | int arrayTraversal(int *nums, int n) {
function quadratic (line 40) | int quadratic(int n) {
function bubbleSort (line 52) | int bubbleSort(int *nums, int n) {
function exponential (line 71) | int exponential(int n) {
function expRecur (line 86) | int expRecur(int n) {
function logarithmic (line 93) | int logarithmic(int n) {
function logRecur (line 103) | int logRecur(int n) {
function linearLogRecur (line 110) | int linearLogRecur(int n) {
function factorialRecur (line 121) | int factorialRecur(int n) {
function main (line 132) | int main(int argc, char *argv[]) {
FILE: codes/c/chapter_computational_complexity/worst_best_time_complexity.c
function findOne (line 28) | int findOne(int *nums, int n) {
function main (line 39) | int main(int argc, char *argv[]) {
FILE: codes/c/chapter_divide_and_conquer/binary_search_recur.c
function dfs (line 10) | int dfs(int nums[], int target, int i, int j) {
function binarySearch (line 30) | int binarySearch(int nums[], int target, int numsSize) {
function main (line 37) | int main() {
FILE: codes/c/chapter_divide_and_conquer/build_tree.c
function TreeNode (line 13) | TreeNode *dfs(int *preorder, int *inorderMap, int i, int l, int r, int s...
function TreeNode (line 33) | TreeNode *buildTree(int *preorder, int preorderSize, int *inorder, int i...
function main (line 45) | int main() {
FILE: codes/c/chapter_divide_and_conquer/hanota.c
function move (line 13) | void move(int *src, int *srcSize, int *tar, int *tarSize) {
function dfs (line 24) | void dfs(int i, int *src, int *srcSize, int *buf, int *bufSize, int *tar...
function solveHanota (line 39) | void solveHanota(int *A, int *ASize, int *B, int *BSize, int *C, int *CS...
function main (line 45) | int main() {
FILE: codes/c/chapter_dynamic_programming/climbing_stairs_backtrack.c
function backtrack (line 10) | void backtrack(int *choices, int state, int n, int *res, int len) {
function climbingStairsBacktrack (line 27) | int climbingStairsBacktrack(int n) {
function main (line 40) | int main() {
FILE: codes/c/chapter_dynamic_programming/climbing_stairs_constraint_dp.c
function climbingStairsConstraintDP (line 10) | int climbingStairsConstraintDP(int n) {
function main (line 39) | int main() {
FILE: codes/c/chapter_dynamic_programming/climbing_stairs_dfs.c
function dfs (line 10) | int dfs(int i) {
function climbingStairsDFS (line 20) | int climbingStairsDFS(int n) {
function main (line 25) | int main() {
FILE: codes/c/chapter_dynamic_programming/climbing_stairs_dfs_mem.c
function dfs (line 10) | int dfs(int i, int *mem) {
function climbingStairsDFSMem (line 25) | int climbingStairsDFSMem(int n) {
function main (line 37) | int main() {
FILE: codes/c/chapter_dynamic_programming/climbing_stairs_dp.c
function climbingStairsDP (line 10) | int climbingStairsDP(int n) {
function climbingStairsDPComp (line 28) | int climbingStairsDPComp(int n) {
function main (line 41) | int main() {
FILE: codes/c/chapter_dynamic_programming/coin_change.c
function myMin (line 10) | int myMin(int a, int b) {
function coinChangeDP (line 15) | int coinChangeDP(int coins[], int amt, int coinsSize) {
function coinChangeDPComp (line 49) | int coinChangeDPComp(int coins[], int amt, int coinsSize) {
function main (line 78) | int main() {
FILE: codes/c/chapter_dynamic_programming/coin_change_ii.c
function coinChangeIIDP (line 10) | int coinChangeIIDP(int coins[], int amt, int coinsSize) {
function coinChangeIIDPComp (line 43) | int coinChangeIIDPComp(int coins[], int amt, int coinsSize) {
function main (line 67) | int main() {
FILE: codes/c/chapter_dynamic_programming/edit_distance.c
function myMin (line 10) | int myMin(int a, int b) {
function editDistanceDFS (line 15) | int editDistanceDFS(char *s, char *t, int i, int j) {
function editDistanceDFSMem (line 37) | int editDistanceDFSMem(char *s, char *t, int memCols, int **mem, int i, ...
function editDistanceDP (line 63) | int editDistanceDP(char *s, char *t, int n, int m) {
function editDistanceDPComp (line 96) | int editDistanceDPComp(char *s, char *t, int n, int m) {
function main (line 127) | int main() {
FILE: codes/c/chapter_dynamic_programming/knapsack.c
function myMax (line 10) | int myMax(int a, int b) {
function knapsackDFS (line 15) | int knapsackDFS(int wgt[], int val[], int i, int c) {
function knapsackDFSMem (line 32) | int knapsackDFSMem(int wgt[], int val[], int memCols, int **mem, int i, ...
function knapsackDP (line 54) | int knapsackDP(int wgt[], int val[], int cap, int wgtSize) {
function knapsackDPComp (line 82) | int knapsackDPComp(int wgt[], int val[], int cap, int wgtSize) {
function main (line 103) | int main() {
FILE: codes/c/chapter_dynamic_programming/min_cost_climbing_stairs_dp.c
function myMin (line 10) | int myMin(int a, int b) {
function minCostClimbingStairsDP (line 15) | int minCostClimbingStairsDP(int cost[], int costSize) {
function minCostClimbingStairsDPComp (line 35) | int minCostClimbingStairsDPComp(int cost[], int costSize) {
function main (line 49) | int main() {
FILE: codes/c/chapter_dynamic_programming/min_path_sum.c
function myMin (line 13) | int myMin(int a, int b) {
function minPathSumDFS (line 18) | int minPathSumDFS(int grid[MAX_SIZE][MAX_SIZE], int i, int j) {
function minPathSumDFSMem (line 35) | int minPathSumDFSMem(int grid[MAX_SIZE][MAX_SIZE], int mem[MAX_SIZE][MAX...
function minPathSumDP (line 57) | int minPathSumDP(int grid[MAX_SIZE][MAX_SIZE], int n, int m) {
function minPathSumDPComp (line 87) | int minPathSumDPComp(int grid[MAX_SIZE][MAX_SIZE], int n, int m) {
function main (line 111) | int main() {
FILE: codes/c/chapter_dynamic_programming/unbounded_knapsack.c
function myMax (line 10) | int myMax(int a, int b) {
function unboundedKnapsackDP (line 15) | int unboundedKnapsackDP(int wgt[], int val[], int cap, int wgtSize) {
function unboundedKnapsackDPComp (line 43) | int unboundedKnapsackDPComp(int wgt[], int val[], int cap, int wgtSize) {
function main (line 66) | int main() {
FILE: codes/c/chapter_graph/graph_adjacency_list.c
type AdjListNode (line 13) | typedef struct AdjListNode {
type GraphAdjList (line 19) | typedef struct {
function GraphAdjList (line 25) | GraphAdjList *newGraphAdjList() {
function delGraphAdjList (line 38) | void delGraphAdjList(GraphAdjList *graph) {
function AdjListNode (line 55) | AdjListNode *findNode(GraphAdjList *graph, Vertex *vet) {
function addEdgeHelper (line 65) | void addEdgeHelper(AdjListNode *head, Vertex *vet) {
function addEdge (line 74) | void addEdge(GraphAdjList *graph, Vertex *vet1, Vertex *vet2) {
function removeEdgeHelper (line 84) | void removeEdgeHelper(AdjListNode *head, Vertex *vet) {
function removeEdge (line 101) | void removeEdge(GraphAdjList *graph, Vertex *vet1, Vertex *vet2) {
function addVertex (line 111) | void addVertex(GraphAdjList *graph, Vertex *vet) {
function removeVertex (line 121) | void removeVertex(GraphAdjList *graph, Vertex *vet) {
function printGraph (line 159) | void printGraph(const GraphAdjList *graph) {
FILE: codes/c/chapter_graph/graph_adjacency_list_test.c
function main (line 10) | int main() {
FILE: codes/c/chapter_graph/graph_adjacency_matrix.c
type GraphAdjMat (line 13) | typedef struct {
function GraphAdjMat (line 20) | GraphAdjMat *newGraphAdjMat() {
function delGraphAdjMat (line 32) | void delGraphAdjMat(GraphAdjMat *graph) {
function addVertex (line 37) | void addVertex(GraphAdjMat *graph, int val) {
function removeVertex (line 52) | void removeVertex(GraphAdjMat *graph, int index) {
function addEdge (line 78) | void addEdge(GraphAdjMat *graph, int i, int j) {
function removeEdge (line 89) | void removeEdge(GraphAdjMat *graph, int i, int j) {
function printGraphAdjMat (line 99) | void printGraphAdjMat(GraphAdjMat *graph) {
function main (line 109) | int main() {
FILE: codes/c/chapter_graph/graph_bfs.c
type Queue (line 13) | typedef struct {
function Queue (line 19) | Queue *newQueue() {
function isEmpty (line 26) | int isEmpty(Queue *q) {
function enqueue (line 31) | void enqueue(Queue *q, Vertex *vet) {
function Vertex (line 38) | Vertex *dequeue(Queue *q) {
function isVisited (line 46) | int isVisited(Vertex **visited, int size, Vertex *vet) {
function graphBFS (line 57) | void graphBFS(GraphAdjList *graph, Vertex *startVet, Vertex **res, int *...
function main (line 82) | int main() {
FILE: codes/c/chapter_graph/graph_dfs.c
function isVisited (line 13) | int isVisited(Vertex **res, int size, Vertex *vet) {
function dfs (line 24) | void dfs(GraphAdjList *graph, Vertex **res, int *resSize, Vertex *vet) {
function graphDFS (line 41) | void graphDFS(GraphAdjList *graph, Vertex *startVet, Vertex **res, int *...
function main (line 46) | int main() {
FILE: codes/c/chapter_greedy/coin_change_greedy.c
function coinChangeGreedy (line 10) | int coinChangeGreedy(int *coins, int size, int amt) {
function main (line 29) | int main() {
FILE: codes/c/chapter_greedy/fractional_knapsack.c
type Item (line 10) | typedef struct {
function sortByValueDensity (line 16) | int sortByValueDensity(const void *a, const void *b) {
function fractionalKnapsack (line 23) | float fractionalKnapsack(int wgt[], int val[], int itemCount, int cap) {
function main (line 50) | int main(void) {
FILE: codes/c/chapter_greedy/max_capacity.c
function myMin (line 10) | int myMin(int a, int b) {
function myMax (line 14) | int myMax(int a, int b) {
function maxCapacity (line 19) | int maxCapacity(int ht[], int htLength) {
function main (line 41) | int main(void) {
FILE: codes/c/chapter_greedy/max_product_cutting.c
function maxProductCutting (line 10) | int maxProductCutting(int n) {
function main (line 31) | int main(void) {
FILE: codes/c/chapter_hashing/array_hash_map.c
type Pair (line 13) | typedef struct {
type MapSet (line 19) | typedef struct {
type ArrayHashMap (line 25) | typedef struct {
function ArrayHashMap (line 30) | ArrayHashMap *newArrayHashMap() {
function delArrayHashMap (line 39) | void delArrayHashMap(ArrayHashMap *hmap) {
function hashFunc (line 50) | int hashFunc(int key) {
function put (line 65) | void put(ArrayHashMap *hmap, const int key, const char *val) {
function removeItem (line 76) | void removeItem(ArrayHashMap *hmap, const int key) {
function pairSet (line 84) | void pairSet(ArrayHashMap *hmap, MapSet *set) {
function keySet (line 108) | void keySet(ArrayHashMap *hmap, MapSet *set) {
function valueSet (line 130) | void valueSet(ArrayHashMap *hmap, MapSet *set) {
function print (line 152) | void print(ArrayHashMap *hmap) {
function main (line 164) | int main() {
FILE: codes/c/chapter_hashing/hash_map_chaining.c
type Pair (line 15) | typedef struct {
type Node (line 21) | typedef struct Node {
type HashMapChaining (line 27) | typedef struct {
function HashMapChaining (line 36) | HashMapChaining *newHashMapChaining() {
function delHashMapChaining (line 50) | void delHashMapChaining(HashMapChaining *hashMap) {
function hashFunc (line 65) | int hashFunc(HashMapChaining *hashMap, int key) {
function loadFactor (line 70) | double loadFactor(HashMapChaining *hashMap) {
function extend (line 92) | void extend(HashMapChaining *hashMap) {
function put (line 120) | void put(HashMapChaining *hashMap, int key, const char *val) {
function removeItem (line 147) | void removeItem(HashMapChaining *hashMap, int key) {
function print (line 171) | void print(HashMapChaining *hashMap) {
function main (line 184) | int main() {
FILE: codes/c/chapter_hashing/hash_map_open_addressing.c
type Pair (line 10) | typedef struct {
type HashMapOpenAddressing (line 16) | typedef struct {
function HashMapOpenAddressing (line 29) | HashMapOpenAddressing *newHashMapOpenAddressing() {
function delHashMapOpenAddressing (line 44) | void delHashMapOpenAddressing(HashMapOpenAddressing *hashMap) {
function hashFunc (line 58) | int hashFunc(HashMapOpenAddressing *hashMap, int key) {
function loadFactor (line 63) | double loadFactor(HashMapOpenAddressing *hashMap) {
function findBucket (line 68) | int findBucket(HashMapOpenAddressing *hashMap, int key) {
function put (line 107) | void put(HashMapOpenAddressing *hashMap, int key, char *val) {
function removeItem (line 134) | void removeItem(HashMapOpenAddressing *hashMap, int key) {
function extend (line 148) | void extend(HashMapOpenAddressing *hashMap) {
function print (line 169) | void print(HashMapOpenAddressing *hashMap) {
function main (line 183) | int main() {
FILE: codes/c/chapter_hashing/simple_hash.c
function addHash (line 10) | int addHash(char *key) {
function mulHash (line 20) | int mulHash(char *key) {
function xorHash (line 30) | int xorHash(char *key) {
function rotHash (line 41) | int rotHash(char *key) {
function main (line 52) | int main() {
FILE: codes/c/chapter_heap/my_heap.c
type MaxHeap (line 12) | typedef struct {
function MaxHeap (line 25) | MaxHeap *newMaxHeap(int nums[], int size) {
function delMaxHeap (line 38) | void delMaxHeap(MaxHeap *maxHeap) {
function left (line 44) | int left(MaxHeap *maxHeap, int i) {
function right (line 49) | int right(MaxHeap *maxHeap, int i) {
function parent (line 54) | int parent(MaxHeap *maxHeap, int i) {
function swap (line 59) | void swap(MaxHeap *maxHeap, int i, int j) {
function size (line 66) | int size(MaxHeap *maxHeap) {
function isEmpty (line 71) | int isEmpty(MaxHeap *maxHeap) {
function peek (line 76) | int peek(MaxHeap *maxHeap) {
function push (line 81) | void push(MaxHeap *maxHeap, int val) {
function pop (line 96) | int pop(MaxHeap *maxHeap) {
function siftDown (line 115) | void siftDown(MaxHeap *maxHeap, int i) {
function siftUp (line 139) | void siftUp(MaxHeap *maxHeap, int i) {
FILE: codes/c/chapter_heap/my_heap_test.c
function main (line 10) | int main() {
FILE: codes/c/chapter_heap/top_k.c
function pushMinHeap (line 10) | void pushMinHeap(MaxHeap *maxHeap, int val) {
function popMinHeap (line 16) | int popMinHeap(MaxHeap *maxHeap) {
function peekMinHeap (line 22) | int peekMinHeap(MaxHeap *maxHeap) {
function main (line 62) | int main() {
FILE: codes/c/chapter_searching/binary_search.c
function binarySearch (line 10) | int binarySearch(int *nums, int len, int target) {
function binarySearchLCRO (line 28) | int binarySearchLCRO(int *nums, int len, int target) {
function main (line 46) | int main() {
FILE: codes/c/chapter_searching/binary_search_edge.c
function binarySearchInsertion (line 10) | int binarySearchInsertion(int *nums, int numSize, int target) {
function binarySearchLeftEdge (line 25) | int binarySearchLeftEdge(int *nums, int numSize, int target) {
function binarySearchRightEdge (line 37) | int binarySearchRightEdge(int *nums, int numSize, int target) {
function main (line 51) | int main() {
FILE: codes/c/chapter_searching/binary_search_insertion.c
function binarySearchInsertionSimple (line 10) | int binarySearchInsertionSimple(int *nums, int numSize, int target) {
function binarySearchInsertion (line 27) | int binarySearchInsertion(int *nums, int numSize, int target) {
function main (line 44) | int main() {
FILE: codes/c/chapter_searching/two_sum.c
type HashTable (line 26) | typedef struct {
function HashTable (line 33) | HashTable *find(HashTable *h, int key) {
function insert (line 40) | void insert(HashTable **h, int key, int val) {
function main (line 69) | int main() {
FILE: codes/c/chapter_sorting/bubble_sort.c
function bubbleSort (line 10) | void bubbleSort(int nums[], int size) {
function bubbleSortWithFlag (line 25) | void bubbleSortWithFlag(int nums[], int size) {
function main (line 44) | int main() {
FILE: codes/c/chapter_sorting/bucket_sort.c
function compare (line 12) | int compare(const void *a, const void *b) {
function bucketSort (line 19) | void bucketSort(float nums[], int n) {
function main (line 49) | int main() {
FILE: codes/c/chapter_sorting/counting_sort.c
function countingSortNaive (line 11) | void countingSortNaive(int nums[], int size) {
function countingSort (line 38) | void countingSort(int nums[], int size) {
function main (line 73) | int main() {
FILE: codes/c/chapter_sorting/heap_sort.c
function siftDown (line 10) | void siftDown(int nums[], int n, int i) {
function heapSort (line 34) | void heapSort(int nums[], int n) {
function main (line 51) | int main() {
FILE: codes/c/chapter_sorting/insertion_sort.c
function insertionSort (line 10) | void insertionSort(int nums[], int size) {
function main (line 26) | int main() {
FILE: codes/c/chapter_sorting/merge_sort.c
function merge (line 10) | void merge(int *nums, int left, int mid, int right) {
function mergeSort (line 41) | void mergeSort(int *nums, int left, int right) {
function main (line 54) | int main() {
FILE: codes/c/chapter_sorting/quick_sort.c
function swap (line 10) | void swap(int nums[], int i, int j) {
function partition (line 17) | int partition(int nums[], int left, int right) {
function quickSort (line 37) | void quickSort(int nums[], int left, int right) {
function medianThree (line 52) | int medianThree(int nums[], int left, int mid, int right) {
function partitionMedian (line 62) | int partitionMedian(int nums[], int left, int right) {
function quickSortMedian (line 81) | void quickSortMedian(int nums[], int left, int right) {
function quickSortTailCall (line 95) | void quickSortTailCall(int nums[], int left, int right) {
function main (line 116) | int main() {
FILE: codes/c/chapter_sorting/radix_sort.c
function digit (line 10) | int digit(int num, int exp) {
function countingSortDigit (line 16) | void countingSortDigit(int nums[], int size, int exp) {
function radixSort (line 49) | void radixSort(int nums[], int size) {
function main (line 67) | int main() {
FILE: codes/c/chapter_sorting/selection_sort.c
function selectionSort (line 10) | void selectionSort(int nums[], int n) {
function main (line 27) | int main() {
FILE: codes/c/chapter_stack_and_queue/array_deque.c
type ArrayDeque (line 10) | typedef struct {
function ArrayDeque (line 18) | ArrayDeque *newArrayDeque(int capacity) {
function delArrayDeque (line 28) | void delArrayDeque(ArrayDeque *deque) {
function capacity (line 34) | int capacity(ArrayDeque *deque) {
function size (line 39) | int size(ArrayDeque *deque) {
function empty (line 44) | bool empty(ArrayDeque *deque) {
function dequeIndex (line 49) | int dequeIndex(ArrayDeque *deque, int i) {
function pushFirst (line 57) | void pushFirst(ArrayDeque *deque, int num) {
function pushLast (line 71) | void pushLast(ArrayDeque *deque, int num) {
function peekFirst (line 84) | int peekFirst(ArrayDeque *deque) {
function peekLast (line 91) | int peekLast(ArrayDeque *deque) {
function popFirst (line 99) | int popFirst(ArrayDeque *deque) {
function popLast (line 108) | int popLast(ArrayDeque *deque) {
function main (line 127) | int main() {
FILE: codes/c/chapter_stack_and_queue/array_queue.c
type ArrayQueue (line 10) | typedef struct {
function ArrayQueue (line 18) | ArrayQueue *newArrayQueue(int capacity) {
function delArrayQueue (line 28) | void delArrayQueue(ArrayQueue *queue) {
function capacity (line 34) | int capacity(ArrayQueue *queue) {
function size (line 39) | int size(ArrayQueue *queue) {
function empty (line 44) | bool empty(ArrayQueue *queue) {
function peek (line 49) | int peek(ArrayQueue *queue) {
function push (line 55) | void push(ArrayQueue *queue, int num) {
function pop (line 69) | int pop(ArrayQueue *queue) {
function main (line 90) | int main() {
FILE: codes/c/chapter_stack_and_queue/array_stack.c
type ArrayStack (line 12) | typedef struct {
function ArrayStack (line 18) | ArrayStack *newArrayStack() {
function delArrayStack (line 27) | void delArrayStack(ArrayStack *stack) {
function size (line 33) | int size(ArrayStack *stack) {
function isEmpty (line 38) | bool isEmpty(ArrayStack *stack) {
function push (line 43) | void push(ArrayStack *stack, int num) {
function peek (line 53) | int peek(ArrayStack *stack) {
function pop (line 62) | int pop(ArrayStack *stack) {
function main (line 69) | int main() {
FILE: codes/c/chapter_stack_and_queue/linkedlist_deque.c
type DoublyListNode (line 10) | typedef struct DoublyListNode {
function DoublyListNode (line 17) | DoublyListNode *newDoublyListNode(int num) {
function delDoublyListNode (line 26) | void delDoublyListNode(DoublyListNode *node) {
type LinkedListDeque (line 31) | typedef struct {
function LinkedListDeque (line 37) | LinkedListDeque *newLinkedListDeque() {
function delLinkedListdeque (line 46) | void delLinkedListdeque(LinkedListDeque *deque) {
function size (line 58) | int size(LinkedListDeque *deque) {
function empty (line 63) | bool empty(LinkedListDeque *deque) {
function push (line 68) | void push(LinkedListDeque *deque, int num, bool isFront) {
function pushFirst (line 92) | void pushFirst(LinkedListDeque *deque, int num) {
function pushLast (line 97) | void pushLast(LinkedListDeque *deque, int num) {
function peekFirst (line 102) | int peekFirst(LinkedListDeque *deque) {
function peekLast (line 108) | int peekLast(LinkedListDeque *deque) {
function pop (line 114) | int pop(LinkedListDeque *deque, bool isFront) {
function popFirst (line 145) | int popFirst(LinkedListDeque *deque) {
function popLast (line 150) | int popLast(LinkedListDeque *deque) {
function printLinkedListDeque (line 155) | void printLinkedListDeque(LinkedListDeque *deque) {
function main (line 169) | int main() {
FILE: codes/c/chapter_stack_and_queue/linkedlist_queue.c
type LinkedListQueue (line 10) | typedef struct {
function LinkedListQueue (line 16) | LinkedListQueue *newLinkedListQueue() {
function delLinkedListQueue (line 25) | void delLinkedListQueue(LinkedListQueue *queue) {
function size (line 37) | int size(LinkedListQueue *queue) {
function empty (line 42) | bool empty(LinkedListQueue *queue) {
function push (line 47) | void push(LinkedListQueue *queue, int num) {
function peek (line 64) | int peek(LinkedListQueue *queue) {
function pop (line 70) | int pop(LinkedListQueue *queue) {
function printLinkedListQueue (line 80) | void printLinkedListQueue(LinkedListQueue *queue) {
function main (line 94) | int main() {
FILE: codes/c/chapter_stack_and_queue/linkedlist_stack.c
type LinkedListStack (line 10) | typedef struct {
function LinkedListStack (line 16) | LinkedListStack *newLinkedListStack() {
function delLinkedListStack (line 24) | void delLinkedListStack(LinkedListStack *s) {
function size (line 34) | int size(LinkedListStack *s) {
function isEmpty (line 39) | bool isEmpty(LinkedListStack *s) {
function push (line 44) | void push(LinkedListStack *s, int num) {
function peek (line 53) | int peek(LinkedListStack *s) {
function pop (line 62) | int pop(LinkedListStack *s) {
function main (line 73) | int main() {
FILE: codes/c/chapter_tree/array_binary_tree.c
type ArrayBinaryTree (line 10) | typedef struct {
function ArrayBinaryTree (line 16) | ArrayBinaryTree *newArrayBinaryTree(int *arr, int arrSize) {
function delArrayBinaryTree (line 25) | void delArrayBinaryTree(ArrayBinaryTree *abt) {
function size (line 31) | int size(ArrayBinaryTree *abt) {
function val (line 36) | int val(ArrayBinaryTree *abt, int i) {
function left (line 44) | int left(int i) {
function right (line 49) | int right(int i) {
function parent (line 54) | int parent(int i) {
function dfs (line 72) | void dfs(ArrayBinaryTree *abt, int i, char *order, int *res, int *index) {
function main (line 117) | int main() {
FILE: codes/c/chapter_tree/avl_tree.c
type AVLTree (line 10) | typedef struct {
function AVLTree (line 15) | AVLTree *newAVLTree() {
function delAVLTree (line 22) | void delAVLTree(AVLTree *tree) {
function height (line 28) | int height(TreeNode *node) {
function updateHeight (line 37) | void updateHeight(TreeNode *node) {
function balanceFactor (line 49) | int balanceFactor(TreeNode *node) {
function TreeNode (line 59) | TreeNode *rightRotate(TreeNode *node) {
function TreeNode (line 74) | TreeNode *leftRotate(TreeNode *node) {
function TreeNode (line 89) | TreeNode *rotate(TreeNode *node) {
function TreeNode (line 119) | TreeNode *insertHelper(TreeNode *node, int val) {
function insert (line 141) | void insert(AVLTree *tree, int val) {
function TreeNode (line 146) | TreeNode *removeHelper(TreeNode *node, int val) {
function removeItem (line 190) | void removeItem(AVLTree *tree, int val) {
function TreeNode (line 195) | TreeNode *search(AVLTree *tree, int val) {
function testInsert (line 214) | void testInsert(AVLTree *tree, int val) {
function testRemove (line 220) | void testRemove(AVLTree *tree, int val) {
function main (line 227) | int main() {
FILE: codes/c/chapter_tree/binary_search_tree.c
type BinarySearchTree (line 10) | typedef struct {
function BinarySearchTree (line 15) | BinarySearchTree *newBinarySearchTree() {
function delBinarySearchTree (line 23) | void delBinarySearchTree(BinarySearchTree *bst) {
function TreeNode (line 29) | TreeNode *getRoot(BinarySearchTree *bst) {
function TreeNode (line 34) | TreeNode *search(BinarySearchTree *bst, int num) {
function insert (line 54) | void insert(BinarySearchTree *bst, int num) {
function removeItem (line 87) | void removeItem(BinarySearchTree *bst, int num) {
function main (line 138) | int main() {
FILE: codes/c/chapter_tree/binary_tree.c
function main (line 10) | int main() {
FILE: codes/c/chapter_tree/binary_tree_bfs.c
function main (line 54) | int main() {
FILE: codes/c/chapter_tree/binary_tree_dfs.c
function preOrder (line 15) | void preOrder(TreeNode *root, int *size) {
function inOrder (line 25) | void inOrder(TreeNode *root, int *size) {
function postOrder (line 35) | void postOrder(TreeNode *root, int *size) {
function main (line 45) | int main() {
FILE: codes/c/utils/common_test.c
function testListNode (line 9) | void testListNode() {
function testTreeNode (line 16) | void testTreeNode() {
function main (line 29) | int main(int argc, char *argv[]) {
FILE: codes/c/utils/list_node.h
type ListNode (line 15) | typedef struct ListNode {
function ListNode (line 21) | ListNode *newListNode(int val) {
function ListNode (line 30) | ListNode *arrToLinkedList(const int *arr, size_t size) {
function freeMemoryLinkedList (line 45) | void freeMemoryLinkedList(ListNode *cur) {
FILE: codes/c/utils/print_util.h
function printArray (line 22) | void printArray(int arr[], int size) {
function printArrayFloat (line 35) | void printArrayFloat(float arr[], int size) {
function printLinkedList (line 48) | void printLinkedList(ListNode *node) {
type Trunk (line 59) | typedef struct Trunk {
function Trunk (line 64) | Trunk *newTrunk(Trunk *prev, char *str) {
function showTrunks (line 72) | void showTrunks(Trunk *trunk) {
function printTreeHelper (line 85) | void printTreeHelper(TreeNode *node, Trunk *prev, bool isRight) {
function printTree (line 113) | void printTree(TreeNode *root) {
function printHeap (line 118) | void printHeap(int arr[], int size) {
FILE: codes/c/utils/tree_node.h
type TreeNode (line 19) | typedef struct TreeNode {
function TreeNode (line 27) | TreeNode *newTreeNode(int val) {
function TreeNode (line 55) | TreeNode *arrayToTreeDFS(int *arr, int size, int i) {
function TreeNode (line 67) | TreeNode *arrayToTree(int *arr, int size) {
function treeToArrayDFS (line 72) | void treeToArrayDFS(TreeNode *root, int i, int *res, int *size) {
function freeMemoryTree (line 95) | void freeMemoryTree(TreeNode *root) {
FILE: codes/c/utils/uthash.h
type UT_hash_bucket (line 1072) | typedef struct UT_hash_bucket {
type UT_hash_table (line 1096) | typedef struct UT_hash_table {
type UT_hash_handle (line 1129) | typedef struct UT_hash_handle {
FILE: codes/c/utils/vector.h
type vector (line 15) | typedef struct vector {
function vector (line 23) | vector *newVector() {
function vector (line 33) | vector *_newVector(int size, void *elem, int elemSize) {
function delVector (line 48) | void delVector(vector *v) {
function vectorPushback (line 67) | void vectorPushback(vector *v, void *elem, int elemSize) {
function vectorPopback (line 78) | void vectorPopback(vector *v) {
function vectorClear (line 86) | void vectorClear(vector *v) {
function vectorSize (line 95) | int vectorSize(vector *v) {
function vectorSet (line 120) | void vectorSet(vector *v, int pos, void *elem, int elemSize) {
function vectorExpand (line 132) | void vectorExpand(vector *v) {
function vectorShrink (line 138) | void vectorShrink(vector *v) {
function vectorInsert (line 144) | void vectorInsert(vector *v, int pos, void *elem, int elemSize) {
function vectorErase (line 158) | void vectorErase(vector *v, int pos) {
function vectorSwap (line 169) | void vectorSwap(vector *v, int i, int j) {
function vectorEmpty (line 176) | bool vectorEmpty(vector *v) {
function vectorFull (line 181) | bool vectorFull(vector *v) {
function vectorEqual (line 186) | bool vectorEqual(vector *v1, vector *v2) {
function vectorSort (line 203) | void vectorSort(vector *v, int (*cmp)(const void *, const void *)) {
function printVector (line 209) | void printVector(vector *v, void (*printFunc)(vector *v, void *p)) {
function printVectorMatrix (line 239) | void printVectorMatrix(vector *vv, void (*printFunc)(vector *v, void *p)) {
FILE: codes/c/utils/vertex.h
type Vertex (line 15) | typedef struct {
function Vertex (line 20) | Vertex *newVertex(int val) {
function Vertex (line 28) | Vertex **valsToVets(int *vals, int size) {
FILE: codes/cpp/chapter_array_and_linkedlist/array.cpp
function randomAccess (line 10) | int randomAccess(int *nums, int size) {
function insert (line 33) | void insert(int *nums, int size, int num, int index) {
function remove (line 43) | void remove(int *nums, int size, int index) {
function traverse (line 51) | void traverse(int *nums, int size) {
function find (line 60) | int find(int *nums, int size, int target) {
function main (line 69) | int main() {
FILE: codes/cpp/chapter_array_and_linkedlist/linked_list.cpp
function insert (line 10) | void insert(ListNode *n0, ListNode *P) {
function remove (line 17) | void remove(ListNode *n0) {
function ListNode (line 29) | ListNode *access(ListNode *head, int index) {
function find (line 39) | int find(ListNode *head, int target) {
function main (line 51) | int main() {
FILE: codes/cpp/chapter_array_and_linkedlist/list.cpp
function main (line 10) | int main() {
FILE: codes/cpp/chapter_array_and_linkedlist/my_list.cpp
class MyList (line 10) | class MyList {
method MyList (line 19) | MyList() {
method size (line 29) | int size() {
method capacity (line 34) | int capacity() {
method get (line 39) | int get(int index) {
method set (line 47) | void set(int index, int num) {
method add (line 54) | void add(int num) {
method insert (line 64) | void insert(int index, int num) {
method remove (line 80) | int remove(int index) {
method extendCapacity (line 95) | void extendCapacity() {
method toVector (line 110) | vector<int> toVector() {
function main (line 121) | int main() {
FILE: codes/cpp/chapter_backtracking/n_queens.cpp
function backtrack (line 10) | void backtrack(int row, int n, vector<vector<string>> &state, vector<vec...
function nQueens (line 37) | vector<vector<vector<string>>> nQueens(int n) {
function main (line 51) | int main() {
FILE: codes/cpp/chapter_backtracking/permutations_i.cpp
function backtrack (line 10) | void backtrack(vector<int> &state, const vector<int> &choices, vector<bo...
function permutationsI (line 34) | vector<vector<int>> permutationsI(vector<int> nums) {
function main (line 43) | int main() {
FILE: codes/cpp/chapter_backtracking/permutations_ii.cpp
function backtrack (line 10) | void backtrack(vector<int> &state, const vector<int> &choices, vector<bo...
function permutationsII (line 36) | vector<vector<int>> permutationsII(vector<int> nums) {
function main (line 45) | int main() {
FILE: codes/cpp/chapter_backtracking/preorder_traversal_i_compact.cpp
function preOrder (line 12) | void preOrder(TreeNode *root) {
function main (line 25) | int main() {
FILE: codes/cpp/chapter_backtracking/preorder_traversal_ii_compact.cpp
function preOrder (line 13) | void preOrder(TreeNode *root) {
function main (line 30) | int main() {
FILE: codes/cpp/chapter_backtracking/preorder_traversal_iii_compact.cpp
function preOrder (line 13) | void preOrder(TreeNode *root) {
function main (line 31) | int main() {
FILE: codes/cpp/chapter_backtracking/preorder_traversal_iii_template.cpp
function isSolution (line 10) | bool isSolution(vector<TreeNode *> &state) {
function recordSolution (line 15) | void recordSolution(vector<TreeNode *> &state, vector<vector<TreeNode *>...
function isValid (line 20) | bool isValid(vector<TreeNode *> &state, TreeNode *choice) {
function makeChoice (line 25) | void makeChoice(vector<TreeNode *> &state, TreeNode *choice) {
function undoChoice (line 30) | void undoChoice(vector<TreeNode *> &state, TreeNode *choice) {
function backtrack (line 35) | void backtrack(vector<TreeNode *> &state, vector<TreeNode *> &choices, v...
function main (line 57) | int main() {
FILE: codes/cpp/chapter_backtracking/subset_sum_i.cpp
function backtrack (line 10) | void backtrack(vector<int> &state, int target, vector<int> &choices, int...
function subsetSumI (line 34) | vector<vector<int>> subsetSumI(vector<int> &nums, int target) {
function main (line 44) | int main() {
FILE: codes/cpp/chapter_backtracking/subset_sum_i_naive.cpp
function backtrack (line 10) | void backtrack(vector<int> &state, int target, int total, vector<int> &c...
function subsetSumINaive (line 32) | vector<vector<int>> subsetSumINaive(vector<int> &nums, int target) {
function main (line 41) | int main() {
FILE: codes/cpp/chapter_backtracking/subset_sum_ii.cpp
function backtrack (line 10) | void backtrack(vector<int> &state, int target, vector<int> &choices, int...
function subsetSumII (line 39) | vector<vector<int>> subsetSumII(vector<int> &nums, int target) {
function main (line 49) | int main() {
FILE: codes/cpp/chapter_computational_complexity/iteration.cpp
function forLoop (line 10) | int forLoop(int n) {
function whileLoop (line 20) | int whileLoop(int n) {
function whileLoopII (line 32) | int whileLoopII(int n) {
function string (line 46) | string nestedForLoop(int n) {
function main (line 59) | int main() {
FILE: codes/cpp/chapter_computational_complexity/recursion.cpp
function recur (line 10) | int recur(int n) {
function forLoopRecur (line 21) | int forLoopRecur(int n) {
function tailRecur (line 41) | int tailRecur(int n, int res) {
function fib (line 50) | int fib(int n) {
function main (line 61) | int main() {
FILE: codes/cpp/chapter_computational_complexity/space_complexity.cpp
function func (line 10) | int func() {
function constant (line 16) | void constant(int n) {
function linear (line 33) | void linear(int n) {
function linearRecur (line 49) | void linearRecur(int n) {
function quadratic (line 57) | void quadratic(int n) {
function quadraticRecur (line 70) | int quadraticRecur(int n) {
function TreeNode (line 79) | TreeNode *buildTree(int n) {
function main (line 89) | int main() {
FILE: codes/cpp/chapter_computational_complexity/time_complexity.cpp
function constant (line 10) | int constant(int n) {
function linear (line 19) | int linear(int n) {
function arrayTraversal (line 27) | int arrayTraversal(vector<int> &nums) {
function quadratic (line 37) | int quadratic(int n) {
function bubbleSort (line 49) | int bubbleSort(vector<int> &nums) {
function exponential (line 68) | int exponential(int n) {
function expRecur (line 82) | int expRecur(int n) {
function logarithmic (line 89) | int logarithmic(int n) {
function logRecur (line 99) | int logRecur(int n) {
function linearLogRecur (line 106) | int linearLogRecur(int n) {
function factorialRecur (line 117) | int factorialRecur(int n) {
function main (line 129) | int main() {
FILE: codes/cpp/chapter_computational_complexity/worst_best_time_complexity.cpp
function randomNumbers (line 10) | vector<int> randomNumbers(int n) {
function findOne (line 24) | int findOne(vector<int> &nums) {
function main (line 35) | int main() {
FILE: codes/cpp/chapter_divide_and_conquer/binary_search_recur.cpp
function dfs (line 10) | int dfs(vector<int> &nums, int target, int i, int j) {
function binarySearch (line 30) | int binarySearch(vector<int> &nums, int target) {
function main (line 37) | int main() {
FILE: codes/cpp/chapter_divide_and_conquer/build_tree.cpp
function TreeNode (line 10) | TreeNode *dfs(vector<int> &preorder, unordered_map<int, int> &inorderMap...
function TreeNode (line 27) | TreeNode *buildTree(vector<int> &preorder, vector<int> &inorder) {
function main (line 38) | int main() {
FILE: codes/cpp/chapter_divide_and_conquer/hanota.cpp
function move (line 10) | void move(vector<int> &src, vector<int> &tar) {
function dfs (line 19) | void dfs(int i, vector<int> &src, vector<int> &buf, vector<int> &tar) {
function solveHanota (line 34) | void solveHanota(vector<int> &A, vector<int> &B, vector<int> &C) {
function main (line 41) | int main() {
FILE: codes/cpp/chapter_dynamic_programming/climbing_stairs_backtrack.cpp
function backtrack (line 11) | void backtrack(vector<int> &choices, int state, int n, vector<int> &res) {
function climbingStairsBacktrack (line 27) | int climbingStairsBacktrack(int n) {
function main (line 36) | int main() {
FILE: codes/cpp/chapter_dynamic_programming/climbing_stairs_constraint_dp.cpp
function climbingStairsConstraintDP (line 10) | int climbingStairsConstraintDP(int n) {
function main (line 30) | int main() {
FILE: codes/cpp/chapter_dynamic_programming/climbing_stairs_dfs.cpp
function dfs (line 10) | int dfs(int i) {
function climbingStairsDFS (line 20) | int climbingStairsDFS(int n) {
function main (line 25) | int main() {
FILE: codes/cpp/chapter_dynamic_programming/climbing_stairs_dfs_mem.cpp
function dfs (line 10) | int dfs(int i, vector<int> &mem) {
function climbingStairsDFSMem (line 25) | int climbingStairsDFSMem(int n) {
function main (line 32) | int main() {
FILE: codes/cpp/chapter_dynamic_programming/climbing_stairs_dp.cpp
function climbingStairsDP (line 10) | int climbingStairsDP(int n) {
function climbingStairsDPComp (line 26) | int climbingStairsDPComp(int n) {
function main (line 39) | int main() {
FILE: codes/cpp/chapter_dynamic_programming/coin_change.cpp
function coinChangeDP (line 10) | int coinChangeDP(vector<int> &coins, int amt) {
function coinChangeDPComp (line 35) | int coinChangeDPComp(vector<int> &coins, int amt) {
function main (line 57) | int main() {
FILE: codes/cpp/chapter_dynamic_programming/coin_change_ii.cpp
function coinChangeIIDP (line 10) | int coinChangeIIDP(vector<int> &coins, int amt) {
function coinChangeIIDPComp (line 34) | int coinChangeIIDPComp(vector<int> &coins, int amt) {
function main (line 55) | int main() {
FILE: codes/cpp/chapter_dynamic_programming/edit_distance.cpp
function editDistanceDFS (line 10) | int editDistanceDFS(string s, string t, int i, int j) {
function editDistanceDFSMem (line 32) | int editDistanceDFSMem(string s, string t, vector<vector<int>> &mem, int...
function editDistanceDP (line 58) | int editDistanceDP(string s, string t) {
function editDistanceDPComp (line 84) | int editDistanceDPComp(string s, string t) {
function main (line 113) | int main() {
FILE: codes/cpp/chapter_dynamic_programming/knapsack.cpp
function knapsackDFS (line 8) | int knapsackDFS(vector<int> &wgt, vector<int> &val, int i, int c) {
function knapsackDFSMem (line 25) | int knapsackDFSMem(vector<int> &wgt, vector<int> &val, vector<vector<int...
function knapsackDP (line 47) | int knapsackDP(vector<int> &wgt, vector<int> &val, int cap) {
function knapsackDPComp (line 67) | int knapsackDPComp(vector<int> &wgt, vector<int> &val, int cap) {
function main (line 85) | int main() {
FILE: codes/cpp/chapter_dynamic_programming/min_cost_climbing_stairs_dp.cpp
function minCostClimbingStairsDP (line 10) | int minCostClimbingStairsDP(vector<int> &cost) {
function minCostClimbingStairsDPComp (line 27) | int minCostClimbingStairsDPComp(vector<int> &cost) {
function main (line 41) | int main() {
FILE: codes/cpp/chapter_dynamic_programming/min_path_sum.cpp
function minPathSumDFS (line 10) | int minPathSumDFS(vector<vector<int>> &grid, int i, int j) {
function minPathSumDFSMem (line 27) | int minPathSumDFSMem(vector<vector<int>> &grid, vector<vector<int>> &mem...
function minPathSumDP (line 49) | int minPathSumDP(vector<vector<int>> &grid) {
function minPathSumDPComp (line 72) | int minPathSumDPComp(vector<vector<int>> &grid) {
function main (line 94) | int main() {
FILE: codes/cpp/chapter_dynamic_programming/unbounded_knapsack.cpp
function unboundedKnapsackDP (line 10) | int unboundedKnapsackDP(vector<int> &wgt, vector<int> &val, int cap) {
function unboundedKnapsackDPComp (line 30) | int unboundedKnapsackDPComp(vector<int> &wgt, vector<int> &val, int cap) {
function main (line 50) | int main() {
FILE: codes/cpp/chapter_graph/graph_adjacency_list.cpp
class GraphAdjList (line 10) | class GraphAdjList {
method remove (line 16) | void remove(vector<Vertex *> &vec, Vertex *vet) {
method GraphAdjList (line 26) | GraphAdjList(const vector<vector<Vertex *>> &edges) {
method size (line 36) | int size() {
method addEdge (line 41) | void addEdge(Vertex *vet1, Vertex *vet2) {
method removeEdge (line 50) | void removeEdge(Vertex *vet1, Vertex *vet2) {
method addVertex (line 59) | void addVertex(Vertex *vet) {
method removeVertex (line 67) | void removeVertex(Vertex *vet) {
method print (line 79) | void print() {
FILE: codes/cpp/chapter_graph/graph_adjacency_list_test.cpp
function main (line 10) | int main() {
FILE: codes/cpp/chapter_graph/graph_adjacency_matrix.cpp
class GraphAdjMat (line 10) | class GraphAdjMat {
method GraphAdjMat (line 16) | GraphAdjMat(const vector<int> &vertices, const vector<vector<int>> &ed...
method size (line 29) | int size() const {
method addVertex (line 34) | void addVertex(int val) {
method removeVertex (line 47) | void removeVertex(int index) {
method addEdge (line 63) | void addEdge(int i, int j) {
method removeEdge (line 75) | void removeEdge(int i, int j) {
method print (line 85) | void print() {
function main (line 94) | int main() {
FILE: codes/cpp/chapter_graph/graph_bfs.cpp
function graphBFS (line 12) | vector<Vertex *> graphBFS(GraphAdjList &graph, Vertex *startVet) {
function main (line 38) | int main() {
FILE: codes/cpp/chapter_graph/graph_dfs.cpp
function dfs (line 11) | void dfs(GraphAdjList &graph, unordered_set<Vertex *> &visited, vector<V...
function graphDFS (line 25) | vector<Vertex *> graphDFS(GraphAdjList &graph, Vertex *startVet) {
function main (line 35) | int main() {
FILE: codes/cpp/chapter_greedy/coin_change_greedy.cpp
function coinChangeGreedy (line 10) | int coinChangeGreedy(vector<int> &coins, int amt) {
function main (line 29) | int main() {
FILE: codes/cpp/chapter_greedy/fractional_knapsack.cpp
class Item (line 10) | class Item {
method Item (line 15) | Item(int w, int v) : w(w), v(v) {
function fractionalKnapsack (line 20) | double fractionalKnapsack(vector<int> &wgt, vector<int> &val, int cap) {
function main (line 46) | int main() {
FILE: codes/cpp/chapter_greedy/max_capacity.cpp
function maxCapacity (line 10) | int maxCapacity(vector<int> &ht) {
function main (line 31) | int main() {
FILE: codes/cpp/chapter_greedy/max_product_cutting.cpp
function maxProductCutting (line 10) | int maxProductCutting(int n) {
function main (line 31) | int main() {
FILE: codes/cpp/chapter_hashing/array_hash_map.cpp
type Pair (line 10) | struct Pair {
method Pair (line 14) | Pair(int key, string val) {
class ArrayHashMap (line 21) | class ArrayHashMap {
method ArrayHashMap (line 26) | ArrayHashMap() {
method hashFunc (line 40) | int hashFunc(int key) {
method string (line 46) | string get(int key) {
method put (line 55) | void put(int key, string val) {
method remove (line 62) | void remove(int key) {
method pairSet (line 70) | vector<Pair *> pairSet() {
method keySet (line 81) | vector<int> keySet() {
method valueSet (line 92) | vector<string> valueSet() {
method print (line 103) | void print() {
FILE: codes/cpp/chapter_hashing/array_hash_map_test.cpp
function main (line 10) | int main() {
FILE: codes/cpp/chapter_hashing/built_in_hash.cpp
function main (line 10) | int main() {
FILE: codes/cpp/chapter_hashing/hash_map.cpp
function main (line 10) | int main() {
FILE: codes/cpp/chapter_hashing/hash_map_chaining.cpp
class HashMapChaining (line 10) | class HashMapChaining {
method HashMapChaining (line 20) | HashMapChaining() : size(0), capacity(4), loadThres(2.0 / 3.0), extend...
method hashFunc (line 35) | int hashFunc(int key) {
method loadFactor (line 40) | double loadFactor() {
method string (line 45) | string get(int key) {
method put (line 58) | void put(int key, string val) {
method remove (line 77) | void remove(int key) {
method extend (line 93) | void extend() {
method print (line 112) | void print() {
function main (line 124) | int main() {
FILE: codes/cpp/chapter_hashing/hash_map_open_addressing.cpp
class HashMapOpenAddressing (line 10) | class HashMapOpenAddressing {
method HashMapOpenAddressing (line 21) | HashMapOpenAddressing() : size(0), buckets(capacity, nullptr) {
method hashFunc (line 35) | int hashFunc(int key) {
method loadFactor (line 40) | double loadFactor() {
method findBucket (line 45) | int findBucket(int key) {
method string (line 72) | string get(int key) {
method put (line 84) | void put(int key, string val) {
method remove (line 102) | void remove(int key) {
method extend (line 114) | void extend() {
method print (line 131) | void print() {
function main (line 145) | int main() {
FILE: codes/cpp/chapter_hashing/simple_hash.cpp
function addHash (line 10) | int addHash(string key) {
function mulHash (line 20) | int mulHash(string key) {
function xorHash (line 30) | int xorHash(string key) {
function rotHash (line 40) | int rotHash(string key) {
function main (line 50) | int main() {
FILE: codes/cpp/chapter_heap/heap.cpp
function testPush (line 9) | void testPush(priority_queue<int> &heap, int val) {
function testPop (line 15) | void testPop(priority_queue<int> &heap) {
function main (line 23) | int main() {
FILE: codes/cpp/chapter_heap/my_heap.cpp
class MaxHeap (line 10) | class MaxHeap {
method left (line 16) | int left(int i) {
method right (line 21) | int right(int i) {
method parent (line 26) | int parent(int i) {
method siftUp (line 31) | void siftUp(int i) {
method siftDown (line 46) | void siftDown(int i) {
method MaxHeap (line 65) | MaxHeap(vector<int> nums) {
method size (line 75) | int size() {
method isEmpty (line 80) | bool isEmpty() {
method peek (line 85) | int peek() {
method push (line 90) | void push(int val) {
method pop (line 98) | void pop() {
method print (line 112) | void print() {
function main (line 123) | int main() {
FILE: codes/cpp/chapter_heap/top_k.cpp
function topKHeap (line 10) | priority_queue<int, vector<int>, greater<int>> topKHeap(vector<int> &num...
function main (line 29) | int main() {
FILE: codes/cpp/chapter_searching/binary_search.cpp
function binarySearch (line 10) | int binarySearch(vector<int> &nums, int target) {
function binarySearchLCRO (line 28) | int binarySearchLCRO(vector<int> &nums, int target) {
function main (line 46) | int main() {
FILE: codes/cpp/chapter_searching/binary_search_edge.cpp
function binarySearchInsertion (line 10) | int binarySearchInsertion(const vector<int> &nums, int target) {
function binarySearchLeftEdge (line 25) | int binarySearchLeftEdge(vector<int> &nums, int target) {
function binarySearchRightEdge (line 37) | int binarySearchRightEdge(vector<int> &nums, int target) {
function main (line 51) | int main() {
FILE: codes/cpp/chapter_searching/binary_search_insertion.cpp
function binarySearchInsertionSimple (line 10) | int binarySearchInsertionSimple(vector<int> &nums, int target) {
function binarySearchInsertion (line 27) | int binarySearchInsertion(vector<int> &nums, int target) {
function main (line 44) | int main() {
FILE: codes/cpp/chapter_searching/hashing_search.cpp
function hashingSearchArray (line 10) | int hashingSearchArray(unordered_map<int, int> map, int target) {
function ListNode (line 19) | ListNode *hashingSearchLinkedList(unordered_map<int, ListNode *> map, in...
function main (line 28) | int main() {
FILE: codes/cpp/chapter_searching/linear_search.cpp
function linearSearchArray (line 10) | int linearSearchArray(vector<int> &nums, int target) {
function ListNode (line 22) | ListNode *linearSearchLinkedList(ListNode *head, int target) {
function main (line 35) | int main() {
FILE: codes/cpp/chapter_searching/two_sum.cpp
function twoSumBruteForce (line 10) | vector<int> twoSumBruteForce(vector<int> &nums, int target) {
function twoSumHashTable (line 23) | vector<int> twoSumHashTable(vector<int> &nums, int target) {
function main (line 38) | int main() {
FILE: codes/cpp/chapter_sorting/bubble_sort.cpp
function bubbleSort (line 10) | void bubbleSort(vector<int> &nums) {
function bubbleSortWithFlag (line 25) | void bubbleSortWithFlag(vector<int> &nums) {
function main (line 44) | int main() {
FILE: codes/cpp/chapter_sorting/bucket_sort.cpp
function bucketSort (line 10) | void bucketSort(vector<float> &nums) {
function main (line 36) | int main() {
FILE: codes/cpp/chapter_sorting/counting_sort.cpp
function countingSortNaive (line 11) | void countingSortNaive(vector<int> &nums) {
function countingSort (line 34) | void countingSort(vector<int> &nums) {
function main (line 65) | int main() {
FILE: codes/cpp/chapter_sorting/heap_sort.cpp
function siftDown (line 10) | void siftDown(vector<int> &nums, int n, int i) {
function heapSort (line 32) | void heapSort(vector<int> &nums) {
function main (line 47) | int main() {
FILE: codes/cpp/chapter_sorting/insertion_sort.cpp
function insertionSort (line 10) | void insertionSort(vector<int> &nums) {
function main (line 24) | int main() {
FILE: codes/cpp/chapter_sorting/merge_sort.cpp
function merge (line 10) | void merge(vector<int> &nums, int left, int mid, int right) {
function mergeSort (line 37) | void mergeSort(vector<int> &nums, int left, int right) {
function main (line 50) | int main() {
FILE: codes/cpp/chapter_sorting/quick_sort.cpp
class QuickSort (line 10) | class QuickSort {
method partition (line 13) | static int partition(vector<int> &nums, int left, int right) {
method quickSort (line 29) | static void quickSort(vector<int> &nums, int left, int right) {
class QuickSortMedian (line 42) | class QuickSortMedian {
method medianThree (line 45) | static int medianThree(vector<int> &nums, int left, int mid, int right) {
method partition (line 55) | static int partition(vector<int> &nums, int left, int right) {
method quickSort (line 75) | static void quickSort(vector<int> &nums, int left, int right) {
class QuickSortTailCall (line 88) | class QuickSortTailCall {
method partition (line 91) | static int partition(vector<int> &nums, int left, int right) {
method quickSort (line 107) | static void quickSort(vector<int> &nums, int left, int right) {
function main (line 125) | int main() {
FILE: codes/cpp/chapter_sorting/radix_sort.cpp
function digit (line 10) | int digit(int num, int exp) {
function countingSortDigit (line 16) | void countingSortDigit(vector<int> &nums, int exp) {
function radixSort (line 43) | void radixSort(vector<int> &nums) {
function main (line 56) | int main() {
FILE: codes/cpp/chapter_sorting/selection_sort.cpp
function selectionSort (line 10) | void selectionSort(vector<int> &nums) {
function main (line 26) | int main() {
FILE: codes/cpp/chapter_stack_and_queue/array_deque.cpp
class ArrayDeque (line 10) | class ArrayDeque {
method ArrayDeque (line 18) | ArrayDeque(int capacity) {
method capacity (line 24) | int capacity() {
method size (line 29) | int size() {
method isEmpty (line 34) | bool isEmpty() {
method index (line 39) | int index(int i) {
method pushFirst (line 47) | void pushFirst(int num) {
method pushLast (line 61) | void pushLast(int num) {
method popFirst (line 74) | int popFirst() {
method popLast (line 83) | int popLast() {
method peekFirst (line 90) | int peekFirst() {
method peekLast (line 97) | int peekLast() {
method toVector (line 106) | vector<int> toVector() {
function main (line 117) | int main() {
FILE: codes/cpp/chapter_stack_and_queue/array_queue.cpp
class ArrayQueue (line 10) | class ArrayQueue {
method ArrayQueue (line 18) | ArrayQueue(int capacity) {
method capacity (line 30) | int capacity() {
method size (line 35) | int size() {
method isEmpty (line 40) | bool isEmpty() {
method push (line 45) | void push(int num) {
method pop (line 59) | int pop() {
method peek (line 68) | int peek() {
method toVector (line 75) | vector<int> toVector() {
function main (line 86) | int main() {
FILE: codes/cpp/chapter_stack_and_queue/array_stack.cpp
class ArrayStack (line 10) | class ArrayStack {
method size (line 16) | int size() {
method isEmpty (line 21) | bool isEmpty() {
method push (line 26) | void push(int num) {
method pop (line 31) | int pop() {
method top (line 38) | int top() {
method toVector (line 45) | vector<int> toVector() {
function main (line 51) | int main() {
FILE: codes/cpp/chapter_stack_and_queue/deque.cpp
function main (line 10) | int main() {
FILE: codes/cpp/chapter_stack_and_queue/linkedlist_deque.cpp
type DoublyListNode (line 10) | struct DoublyListNode {
method DoublyListNode (line 14) | DoublyListNode(int val) : val(val), prev(nullptr), next(nullptr) {
class LinkedListDeque (line 19) | class LinkedListDeque {
method LinkedListDeque (line 26) | LinkedListDeque() : front(nullptr), rear(nullptr) {
method size (line 41) | int size() {
method isEmpty (line 46) | bool isEmpty() {
method push (line 51) | void push(int num, bool isFront) {
method pushFirst (line 73) | void pushFirst(int num) {
method pushLast (line 78) | void pushLast(int num) {
method pop (line 83) | int pop(bool isFront) {
method popFirst (line 115) | int popFirst() {
method popLast (line 120) | int popLast() {
method peekFirst (line 125) | int peekFirst() {
method peekLast (line 132) | int peekLast() {
method toVector (line 139) | vector<int> toVector() {
function main (line 151) | int main() {
FILE: codes/cpp/chapter_stack_and_queue/linkedlist_queue.cpp
class LinkedListQueue (line 10) | class LinkedListQueue {
method LinkedListQueue (line 16) | LinkedListQueue() {
method size (line 28) | int size() {
method isEmpty (line 33) | bool isEmpty() {
method push (line 38) | void push(int num) {
method pop (line 55) | int pop() {
method peek (line 67) | int peek() {
method toVector (line 74) | vector<int> toVector() {
function main (line 86) | int main() {
FILE: codes/cpp/chapter_stack_and_queue/linkedlist_stack.cpp
class LinkedListStack (line 10) | class LinkedListStack {
method LinkedListStack (line 16) | LinkedListStack() {
method size (line 27) | int size() {
method isEmpty (line 32) | bool isEmpty() {
method push (line 37) | void push(int num) {
method pop (line 45) | int pop() {
method top (line 56) | int top() {
method toVector (line 63) | vector<int> toVector() {
function main (line 75) | int main() {
FILE: codes/cpp/chapter_stack_and_queue/queue.cpp
function main (line 10) | int main() {
FILE: codes/cpp/chapter_stack_and_queue/stack.cpp
function main (line 10) | int main() {
FILE: codes/cpp/chapter_tree/array_binary_tree.cpp
class ArrayBinaryTree (line 10) | class ArrayBinaryTree {
method ArrayBinaryTree (line 13) | ArrayBinaryTree(vector<int> arr) {
method size (line 18) | int size() {
method val (line 23) | int val(int i) {
method left (line 31) | int left(int i) {
method right (line 36) | int right(int i) {
method parent (line 41) | int parent(int i) {
method levelOrder (line 46) | vector<int> levelOrder() {
method preOrder (line 57) | vector<int> preOrder() {
method inOrder (line 64) | vector<int> inOrder() {
method postOrder (line 71) | vector<int> postOrder() {
method dfs (line 81) | void dfs(int i, string order, vector<int> &res) {
function main (line 100) | int main() {
FILE: codes/cpp/chapter_tree/avl_tree.cpp
class AVLTree (line 10) | class AVLTree {
method updateHeight (line 13) | void updateHeight(TreeNode *node) {
method TreeNode (line 19) | TreeNode *rightRotate(TreeNode *node) {
method TreeNode (line 33) | TreeNode *leftRotate(TreeNode *node) {
method TreeNode (line 47) | TreeNode *rotate(TreeNode *node) {
method TreeNode (line 77) | TreeNode *insertHelper(TreeNode *node, int val) {
method TreeNode (line 95) | TreeNode *removeHelper(TreeNode *node, int val) {
method height (line 138) | int height(TreeNode *node) {
method balanceFactor (line 144) | int balanceFactor(TreeNode *node) {
method insert (line 153) | void insert(int val) {
method remove (line 158) | void remove(int val) {
method TreeNode (line 163) | TreeNode *search(int val) {
method AVLTree (line 182) | AVLTree() : root(nullptr) {
function testInsert (line 191) | void testInsert(AVLTree &tree, int val) {
function testRemove (line 197) | void testRemove(AVLTree &tree, int val) {
function main (line 204) | int main() {
FILE: codes/cpp/chapter_tree/binary_search_tree.cpp
class BinarySearchTree (line 10) | class BinarySearchTree {
method BinarySearchTree (line 16) | BinarySearchTree() {
method TreeNode (line 27) | TreeNode *getRoot() {
method TreeNode (line 32) | TreeNode *search(int num) {
method insert (line 51) | void insert(int num) {
method remove (line 80) | void remove(int num) {
function main (line 135) | int main() {
FILE: codes/cpp/chapter_tree/binary_tree.cpp
function main (line 10) | int main() {
FILE: codes/cpp/chapter_tree/binary_tree_bfs.cpp
function levelOrder (line 10) | vector<int> levelOrder(TreeNode *root) {
function main (line 29) | int main() {
FILE: codes/cpp/chapter_tree/binary_tree_dfs.cpp
function preOrder (line 13) | void preOrder(TreeNode *root) {
function inOrder (line 23) | void inOrder(TreeNode *root) {
function postOrder (line 33) | void postOrder(TreeNode *root) {
function main (line 43) | int main() {
FILE: codes/cpp/utils/list_node.hpp
type ListNode (line 15) | struct ListNode {
method ListNode (line 18) | ListNode(int x) : val(x), next(nullptr) {
function ListNode (line 23) | ListNode *vecToLinkedList(vector<int> list) {
method ListNode (line 18) | ListNode(int x) : val(x), next(nullptr) {
function freeMemoryLinkedList (line 34) | void freeMemoryLinkedList(ListNode *cur) {
FILE: codes/cpp/utils/print_utils.hpp
function vecFind (line 17) | int vecFind(const vector<T> &vec, T ele) {
function string (line 28) | string strJoin(const string &delim, const T &vec) {
function string (line 40) | string strRepeat(string str, int n) {
function printArray (line 48) | void printArray(T *arr, int n) {
function string (line 60) | string getVectorString(vector<T> &list) {
function printVector (line 65) | void printVector(vector<T> list) {
function printVectorMatrix (line 70) | void printVectorMatrix(vector<vector<T>> &matrix) {
function printLinkedList (line 78) | void printLinkedList(ListNode *head) {
type Trunk (line 88) | struct Trunk {
method Trunk (line 91) | Trunk(Trunk *prev, string str) {
function showTrunks (line 97) | void showTrunks(Trunk *p) {
function printTree (line 111) | void printTree(TreeNode *root, Trunk *prev, bool isRight) {
function printTree (line 143) | void printTree(TreeNode *root) {
function printStack (line 148) | void printStack(stack<T> stk) {
function printQueue (line 170) | void printQueue(queue<T> queue) {
function printDeque (line 186) | void printDeque(deque<T> deque) {
function printHashMap (line 203) | void printHashMap(unordered_map<TKey, TValue> map) {
function S (line 210) | S &Container(priority_queue<T, S, C> &pq) {
function printHeap (line 220) | void printHeap(priority_queue<T, S, C> &heap) {
FILE: codes/cpp/utils/tree_node.hpp
type TreeNode (line 15) | struct TreeNode {
method TreeNode (line 21) | TreeNode() = default;
method TreeNode (line 22) | explicit TreeNode(int x, TreeNode *parent = nullptr) : val(x), parent(...
function TreeNode (line 43) | TreeNode *vectorToTreeDFS(vector<int> &arr, int i) {
method TreeNode (line 21) | TreeNode() = default;
method TreeNode (line 22) | explicit TreeNode(int x, TreeNode *parent = nullptr) : val(x), parent(...
function TreeNode (line 54) | TreeNode *vectorToTree(vector<int> arr) {
method TreeNode (line 21) | TreeNode() = default;
method TreeNode (line 22) | explicit TreeNode(int x, TreeNode *parent = nullptr) : val(x), parent(...
function treeToVecorDFS (line 59) | void treeToVecorDFS(TreeNode *root, int i, vector<int> &res) {
function treeToVecor (line 71) | vector<int> treeToVecor(TreeNode *root) {
function freeMemoryTree (line 78) | void freeMemoryTree(TreeNode *root) {
FILE: codes/cpp/utils/vertex.hpp
type Vertex (line 14) | struct Vertex {
method Vertex (line 16) | Vertex(int x) : val(x) {
function valsToVets (line 21) | vector<Vertex *> valsToVets(vector<int> vals) {
function vetsToVals (line 30) | vector<int> vetsToVals(vector<Vertex *> vets) {
FILE: codes/csharp/chapter_array_and_linkedlist/array.cs
class array (line 7) | public class array {
method RandomAccess (line 9) | int RandomAccess(int[] nums) {
method Extend (line 19) | int[] Extend(int[] nums, int enlarge) {
method Insert (line 31) | void Insert(int[] nums, int num, int index) {
method Remove (line 41) | void Remove(int[] nums, int index) {
method Traverse (line 49) | void Traverse(int[] nums) {
method Find (line 62) | int Find(int[] nums, int target) {
method ToString (line 71) | string ToString(int[] nums) {
method Test (line 76) | [Test]
FILE: codes/csharp/chapter_array_and_linkedlist/linked_list.cs
class linked_list (line 7) | public class linked_list {
method Insert (line 9) | void Insert(ListNode n0, ListNode P) {
method Remove (line 16) | void Remove(ListNode n0) {
method Access (line 26) | ListNode? Access(ListNode? head, int index) {
method Find (line 36) | int Find(ListNode? head, int target) {
method Test (line 48) | [Test]
FILE: codes/csharp/chapter_array_and_linkedlist/list.cs
class list (line 9) | public class list {
method Test (line 10) | [Test]
FILE: codes/csharp/chapter_array_and_linkedlist/my_list.cs
class MyList (line 10) | class MyList {
method MyList (line 17) | public MyList() {
method Size (line 22) | public int Size() {
method Capacity (line 27) | public int Capacity() {
method Get (line 32) | public int Get(int index) {
method Set (line 40) | public void Set(int index, int num) {
method Add (line 47) | public void Add(int num) {
method Insert (line 57) | public void Insert(int index, int num) {
method Remove (line 73) | public int Remove(int index) {
method ExtendCapacity (line 88) | public void ExtendCapacity() {
method ToArray (line 96) | public int[] ToArray() {
class my_list (line 106) | public class my_list {
method Test (line 107) | [Test]
FILE: codes/csharp/chapter_backtracking/n_queens.cs
class n_queens (line 9) | public class n_queens {
method Backtrack (line 11) | void Backtrack(int row, int n, List<List<string>> state, List<List<Lis...
method NQueens (line 42) | List<List<List<string>>> NQueens(int n) {
method Test (line 62) | [Test]
FILE: codes/csharp/chapter_backtracking/permutations_i.cs
class permutations_i (line 9) | public class permutations_i {
method Backtrack (line 11) | void Backtrack(List<int> state, int[] choices, bool[] selected, List<L...
method PermutationsI (line 35) | List<List<int>> PermutationsI(int[] nums) {
method Test (line 41) | [Test]
FILE: codes/csharp/chapter_backtracking/permutations_ii.cs
class permutations_ii (line 9) | public class permutations_ii {
method Backtrack (line 11) | void Backtrack(List<int> state, int[] choices, bool[] selected, List<L...
method PermutationsII (line 37) | List<List<int>> PermutationsII(int[] nums) {
method Test (line 43) | [Test]
FILE: codes/csharp/chapter_backtracking/preorder_traversal_i_compact.cs
class preorder_traversal_i_compact (line 9) | public class preorder_traversal_i_compact {
method PreOrder (line 13) | void PreOrder(TreeNode? root) {
method Test (line 25) | [Test]
FILE: codes/csharp/chapter_backtracking/preorder_traversal_ii_compact.cs
class preorder_traversal_ii_compact (line 9) | public class preorder_traversal_ii_compact {
method PreOrder (line 14) | void PreOrder(TreeNode? root) {
method Test (line 30) | [Test]
FILE: codes/csharp/chapter_backtracking/preorder_traversal_iii_compact.cs
class preorder_traversal_iii_compact (line 9) | public class preorder_traversal_iii_compact {
method PreOrder (line 14) | void PreOrder(TreeNode? root) {
method Test (line 31) | [Test]
FILE: codes/csharp/chapter_backtracking/preorder_traversal_iii_template.cs
class preorder_traversal_iii_template (line 9) | public class preorder_traversal_iii_template {
method IsSolution (line 11) | bool IsSolution(List<TreeNode> state) {
method RecordSolution (line 16) | void RecordSolution(List<TreeNode> state, List<List<TreeNode>> res) {
method IsValid (line 21) | bool IsValid(List<TreeNode> state, TreeNode choice) {
method MakeChoice (line 26) | void MakeChoice(List<TreeNode> state, TreeNode choice) {
method UndoChoice (line 31) | void UndoChoice(List<TreeNode> state, TreeNode choice) {
method Backtrack (line 36) | void Backtrack(List<TreeNode> state, List<TreeNode> choices, List<List...
method Test (line 56) | [Test]
FILE: codes/csharp/chapter_backtracking/subset_sum_i.cs
class subset_sum_i (line 9) | public class subset_sum_i {
method Backtrack (line 11) | void Backtrack(List<int> state, int target, int[] choices, int start, ...
method SubsetSumI (line 35) | List<List<int>> SubsetSumI(int[] nums, int target) {
method Test (line 44) | [Test]
FILE: codes/csharp/chapter_backtracking/subset_sum_i_naive.cs
class subset_sum_i_naive (line 9) | public class subset_sum_i_naive {
method Backtrack (line 11) | void Backtrack(List<int> state, int target, int total, int[] choices, ...
method SubsetSumINaive (line 33) | List<List<int>> SubsetSumINaive(int[] nums, int target) {
method Test (line 41) | [Test]
FILE: codes/csharp/chapter_backtracking/subset_sum_ii.cs
class subset_sum_ii (line 9) | public class subset_sum_ii {
method Backtrack (line 11) | void Backtrack(List<int> state, int target, int[] choices, int start, ...
method SubsetSumII (line 40) | List<List<int>> SubsetSumII(int[] nums, int target) {
method Test (line 49) | [Test]
FILE: codes/csharp/chapter_computational_complexity/iteration.cs
class iteration (line 9) | public class iteration {
method ForLoop (line 11) | int ForLoop(int n) {
method WhileLoop (line 21) | int WhileLoop(int n) {
method WhileLoopII (line 33) | int WhileLoopII(int n) {
method NestedForLoop (line 47) | string NestedForLoop(int n) {
method Test (line 60) | [Test]
FILE: codes/csharp/chapter_computational_complexity/recursion.cs
class recursion (line 9) | public class recursion {
method Recur (line 11) | int Recur(int n) {
method ForLoopRecur (line 22) | int ForLoopRecur(int n) {
method TailRecur (line 41) | int TailRecur(int n, int res) {
method Fib (line 50) | int Fib(int n) {
method Test (line 61) | [Test]
FILE: codes/csharp/chapter_computational_complexity/space_complexity.cs
class space_complexity (line 9) | public class space_complexity {
method Function (line 11) | int Function() {
method Constant (line 17) | void Constant(int n) {
method Linear (line 34) | void Linear(int n) {
method LinearRecur (line 50) | void LinearRecur(int n) {
method Quadratic (line 57) | void Quadratic(int n) {
method QuadraticRecur (line 72) | int QuadraticRecur(int n) {
method BuildTree (line 80) | TreeNode? BuildTree(int n) {
method Test (line 89) | [Test]
FILE: codes/csharp/chapter_computational_complexity/time_complexity.cs
class time_complexity (line 9) | public class time_complexity {
method Algorithm (line 10) | void Algorithm(int n) {
method AlgorithmA (line 26) | void AlgorithmA(int n) {
method AlgorithmB (line 31) | void AlgorithmB(int n) {
method AlgorithmC (line 38) | void AlgorithmC(int n) {
method Constant (line 45) | int Constant(int n) {
method Linear (line 54) | int Linear(int n) {
method ArrayTraversal (line 62) | int ArrayTraversal(int[] nums) {
method Quadratic (line 72) | int Quadratic(int n) {
method BubbleSort (line 84) | int BubbleSort(int[] nums) {
method Exponential (line 101) | int Exponential(int n) {
method ExpRecur (line 115) | int ExpRecur(int n) {
method Logarithmic (line 121) | int Logarithmic(int n) {
method LogRecur (line 131) | int LogRecur(int n) {
method LinearLogRecur (line 137) | int LinearLogRecur(int n) {
method FactorialRecur (line 147) | int FactorialRecur(int n) {
method Test (line 157) | [Test]
FILE: codes/csharp/chapter_computational_complexity/worst_best_time_complexity.cs
class worst_best_time_complexity (line 9) | public class worst_best_time_complexity {
method RandomNumbers (line 11) | int[] RandomNumbers(int n) {
method FindOne (line 27) | int FindOne(int[] nums) {
method Test (line 39) | [Test]
FILE: codes/csharp/chapter_divide_and_conquer/binary_search_recur.cs
class binary_search_recur (line 9) | public class binary_search_recur {
method DFS (line 11) | int DFS(int[] nums, int target, int i, int j) {
method BinarySearch (line 31) | int BinarySearch(int[] nums, int target) {
method Test (line 37) | [Test]
FILE: codes/csharp/chapter_divide_and_conquer/build_tree.cs
class build_tree (line 9) | public class build_tree {
method DFS (line 11) | TreeNode? DFS(int[] preorder, Dictionary<int, int> inorderMap, int i, ...
method BuildTree (line 28) | TreeNode? BuildTree(int[] preorder, int[] inorder) {
method Test (line 38) | [Test]
FILE: codes/csharp/chapter_divide_and_conquer/hanota.cs
class hanota (line 9) | public class hanota {
method Move (line 11) | void Move(List<int> src, List<int> tar) {
method DFS (line 20) | void DFS(int i, List<int> src, List<int> buf, List<int> tar) {
method SolveHanota (line 35) | void SolveHanota(List<int> A, List<int> B, List<int> C) {
method Test (line 41) | [Test]
FILE: codes/csharp/chapter_dynamic_programming/climbing_stairs_backtrack.cs
class climbing_stairs_backtrack (line 9) | public class climbing_stairs_backtrack {
method Backtrack (line 11) | void Backtrack(List<int> choices, int state, int n, List<int> res) {
method ClimbingStairsBacktrack (line 27) | int ClimbingStairsBacktrack(int n) {
method Test (line 35) | [Test]
FILE: codes/csharp/chapter_dynamic_programming/climbing_stairs_constraint_dp.cs
class climbing_stairs_constraint_dp (line 9) | public class climbing_stairs_constraint_dp {
method ClimbingStairsConstraintDP (line 11) | int ClimbingStairsConstraintDP(int n) {
method Test (line 30) | [Test]
FILE: codes/csharp/chapter_dynamic_programming/climbing_stairs_dfs.cs
class climbing_stairs_dfs (line 9) | public class climbing_stairs_dfs {
method DFS (line 11) | int DFS(int i) {
method ClimbingStairsDFS (line 21) | int ClimbingStairsDFS(int n) {
method Test (line 25) | [Test]
FILE: codes/csharp/chapter_dynamic_programming/climbing_stairs_dfs_mem.cs
class climbing_stairs_dfs_mem (line 9) | public class climbing_stairs_dfs_mem {
method DFS (line 11) | int DFS(int i, int[] mem) {
method ClimbingStairsDFSMem (line 26) | int ClimbingStairsDFSMem(int n) {
method Test (line 33) | [Test]
FILE: codes/csharp/chapter_dynamic_programming/climbing_stairs_dp.cs
class climbing_stairs_dp (line 9) | public class climbing_stairs_dp {
method ClimbingStairsDP (line 11) | int ClimbingStairsDP(int n) {
method ClimbingStairsDPComp (line 27) | int ClimbingStairsDPComp(int n) {
method Test (line 39) | [Test]
FILE: codes/csharp/chapter_dynamic_programming/coin_change.cs
class coin_change (line 9) | public class coin_change {
method CoinChangeDP (line 11) | int CoinChangeDP(int[] coins, int amt) {
method CoinChangeDPComp (line 36) | int CoinChangeDPComp(int[] coins, int amt) {
method Test (line 58) | [Test]
FILE: codes/csharp/chapter_dynamic_programming/coin_change_ii.cs
class coin_change_ii (line 9) | public class coin_change_ii {
method CoinChangeIIDP (line 11) | int CoinChangeIIDP(int[] coins, int amt) {
method CoinChangeIIDPComp (line 35) | int CoinChangeIIDPComp(int[] coins, int amt) {
method Test (line 55) | [Test]
FILE: codes/csharp/chapter_dynamic_programming/edit_distance.cs
class edit_distance (line 9) | public class edit_distance {
method EditDistanceDFS (line 11) | int EditDistanceDFS(string s, string t, int i, int j) {
method EditDistanceDFSMem (line 33) | int EditDistanceDFSMem(string s, string t, int[][] mem, int i, int j) {
method EditDistanceDP (line 59) | int EditDistanceDP(string s, string t) {
method EditDistanceDPComp (line 85) | int EditDistanceDPComp(string s, string t) {
method Test (line 113) | [Test]
FILE: codes/csharp/chapter_dynamic_programming/knapsack.cs
class knapsack (line 9) | public class knapsack {
method KnapsackDFS (line 11) | int KnapsackDFS(int[] weight, int[] val, int i, int c) {
method KnapsackDFSMem (line 28) | int KnapsackDFSMem(int[] weight, int[] val, int[][] mem, int i, int c) {
method KnapsackDP (line 50) | int KnapsackDP(int[] weight, int[] val, int cap) {
method KnapsackDPComp (line 70) | int KnapsackDPComp(int[] weight, int[] val, int cap) {
method Test (line 90) | [Test]
FILE: codes/csharp/chapter_dynamic_programming/min_cost_climbing_stairs_dp.cs
class min_cost_climbing_stairs_dp (line 9) | public class min_cost_climbing_stairs_dp {
method MinCostClimbingStairsDP (line 11) | int MinCostClimbingStairsDP(int[] cost) {
method MinCostClimbingStairsDPComp (line 28) | int MinCostClimbingStairsDPComp(int[] cost) {
method Test (line 41) | [Test]
FILE: codes/csharp/chapter_dynamic_programming/min_path_sum.cs
class min_path_sum (line 9) | public class min_path_sum {
method MinPathSumDFS (line 11) | int MinPathSumDFS(int[][] grid, int i, int j) {
method MinPathSumDFSMem (line 28) | int MinPathSumDFSMem(int[][] grid, int[][] mem, int i, int j) {
method MinPathSumDP (line 50) | int MinPathSumDP(int[][] grid) {
method MinPathSumDPComp (line 73) | int MinPathSumDPComp(int[][] grid) {
method Test (line 94) | [Test]
FILE: codes/csharp/chapter_dynamic_programming/unbounded_knapsack.cs
class unbounded_knapsack (line 9) | public class unbounded_knapsack {
method UnboundedKnapsackDP (line 11) | int UnboundedKnapsackDP(int[] wgt, int[] val, int cap) {
method UnboundedKnapsackDPComp (line 31) | int UnboundedKnapsackDPComp(int[] wgt, int[] val, int cap) {
method Test (line 50) | [Test]
FILE: codes/csharp/chapter_graph/graph_adjacency_list.cs
class GraphAdjList (line 10) | public class GraphAdjList {
method GraphAdjList (line 15) | public GraphAdjList(Vertex[][] edges) {
method Size (line 26) | int Size() {
method AddEdge (line 31) | public void AddEdge(Vertex vet1, Vertex vet2) {
method RemoveEdge (line 40) | public void RemoveEdge(Vertex vet1, Vertex vet2) {
method AddVertex (line 49) | public void AddVertex(Vertex vet) {
method RemoveVertex (line 57) | public void RemoveVertex(Vertex vet) {
method Print (line 69) | public void Print() {
class graph_adjacency_list (line 80) | public class graph_adjacency_list {
method Test (line 81) | [Test]
FILE: codes/csharp/chapter_graph/graph_adjacency_matrix.cs
class GraphAdjMat (line 10) | class GraphAdjMat {
method GraphAdjMat (line 15) | public GraphAdjMat(int[] vertices, int[][] edges) {
method Size (line 30) | int Size() {
method AddVertex (line 35) | public void AddVertex(int val) {
method RemoveVertex (line 52) | public void RemoveVertex(int index) {
method AddEdge (line 67) | public void AddEdge(int i, int j) {
method RemoveEdge (line 78) | public void RemoveEdge(int i, int j) {
method Print (line 87) | public void Print() {
class graph_adjacency_matrix (line 95) | public class graph_adjacency_matrix {
method Test (line 96) | [Test]
FILE: codes/csharp/chapter_graph/graph_bfs.cs
class graph_bfs (line 9) | public class graph_bfs {
method GraphBFS (line 12) | List<Vertex> GraphBFS(GraphAdjList graph, Vertex startVet) {
method Test (line 37) | [Test]
FILE: codes/csharp/chapter_graph/graph_dfs.cs
class graph_dfs (line 9) | public class graph_dfs {
method DFS (line 11) | void DFS(GraphAdjList graph, HashSet<Vertex> visited, List<Vertex> res...
method GraphDFS (line 26) | List<Vertex> GraphDFS(GraphAdjList graph, Vertex startVet) {
method Test (line 35) | [Test]
FILE: codes/csharp/chapter_greedy/coin_change_greedy.cs
class coin_change_greedy (line 9) | public class coin_change_greedy {
method CoinChangeGreedy (line 11) | int CoinChangeGreedy(int[] coins, int amt) {
method Test (line 29) | [Test]
FILE: codes/csharp/chapter_greedy/fractional_knapsack.cs
class Item (line 10) | class Item(int w, int v) {
class fractional_knapsack (line 15) | public class fractional_knapsack {
method FractionalKnapsack (line 17) | double FractionalKnapsack(int[] wgt, int[] val, int cap) {
method Test (line 42) | [Test]
FILE: codes/csharp/chapter_greedy/max_capacity.cs
class max_capacity (line 9) | public class max_capacity {
method MaxCapacity (line 11) | int MaxCapacity(int[] ht) {
method Test (line 31) | [Test]
FILE: codes/csharp/chapter_greedy/max_product_cutting.cs
class max_product_cutting (line 9) | public class max_product_cutting {
method MaxProductCutting (line 11) | int MaxProductCutting(int n) {
method Test (line 31) | [Test]
FILE: codes/csharp/chapter_hashing/array_hash_map.cs
class Pair (line 10) | class Pair(int key, string val) {
class ArrayHashMap (line 16) | class ArrayHashMap {
method ArrayHashMap (line 18) | public ArrayHashMap() {
method HashFunc (line 27) | int HashFunc(int key) {
method Get (line 33) | public string? Get(int key) {
method Put (line 41) | public void Put(int key, string val) {
method Remove (line 48) | public void Remove(int key) {
method PairSet (line 55) | public List<Pair> PairSet() {
method KeySet (line 65) | public List<int> KeySet() {
method ValueSet (line 75) | public List<string> ValueSet() {
method Print (line 85) | public void Print() {
class array_hash_map (line 93) | public class array_hash_map {
method Test (line 94) | [Test]
FILE: codes/csharp/chapter_hashing/built_in_hash.cs
class built_in_hash (line 9) | public class built_in_hash {
method Test (line 10) | [Test]
FILE: codes/csharp/chapter_hashing/hash_map.cs
class hash_map (line 10) | public class hash_map {
method Test (line 11) | [Test]
FILE: codes/csharp/chapter_hashing/hash_map_chaining.cs
class HashMapChaining (line 10) | class HashMapChaining {
method HashMapChaining (line 18) | public HashMapChaining() {
method HashFunc (line 30) | int HashFunc(int key) {
method LoadFactor (line 35) | double LoadFactor() {
method Get (line 40) | public string? Get(int key) {
method Put (line 53) | public void Put(int key, string val) {
method Remove (line 72) | public void Remove(int key) {
method Extend (line 85) | void Extend() {
method Print (line 104) | public void Print() {
class hash_map_chaining (line 117) | public class hash_map_chaining {
method Test (line 118) | [Test]
FILE: codes/csharp/chapter_hashing/hash_map_open_addressing.cs
class HashMapOpenAddressing (line 10) | class HashMapOpenAddressing {
method HashMapOpenAddressing (line 19) | public HashMapOpenAddressing() {
method HashFunc (line 25) | int HashFunc(int key) {
method LoadFactor (line 30) | double LoadFactor() {
method FindBucket (line 35) | int FindBucket(int key) {
method Get (line 62) | public string? Get(int key) {
method Put (line 74) | public void Put(int key, string val) {
method Remove (line 92) | public void Remove(int key) {
method Extend (line 103) | void Extend() {
method Print (line 119) | public void Print() {
class hash_map_open_addressing (line 132) | public class hash_map_open_addressing {
method Test (line 133) | [Test]
FILE: codes/csharp/chapter_hashing/simple_hash.cs
class simple_hash (line 9) | public class simple_hash {
method AddHash (line 11) | int AddHash(string key) {
method MulHash (line 21) | int MulHash(string key) {
method XorHash (line 31) | int XorHash(string key) {
method RotHash (line 41) | int RotHash(string key) {
method Test (line 50) | [Test]
FILE: codes/csharp/chapter_heap/heap.cs
class heap (line 9) | public class heap {
method TestPush (line 10) | void TestPush(PriorityQueue<int, int> heap, int val) {
method TestPop (line 16) | void TestPop(PriorityQueue<int, int> heap) {
method Test (line 22) | [Test]
FILE: codes/csharp/chapter_heap/my_heap.cs
class MaxHeap (line 10) | class MaxHeap {
method MaxHeap (line 15) | public MaxHeap() {
method MaxHeap (line 20) | public MaxHeap(IEnumerable<int> nums) {
method Left (line 31) | int Left(int i) {
method Right (line 36) | int Right(int i) {
method Parent (line 41) | int Parent(int i) {
method Peek (line 46) | public int Peek() {
method Push (line 51) | public void Push(int val) {
method Size (line 59) | public int Size() {
method IsEmpty (line 64) | public bool IsEmpty() {
method SiftUp (line 69) | void SiftUp(int i) {
method Pop (line 84) | public int Pop() {
method SiftDown (line 100) | void SiftDown(int i) {
method Swap (line 118) | void Swap(int i, int p) {
method Print (line 123) | public void Print() {
class my_heap (line 129) | public class my_heap {
method Test (line 130) | [Test]
FILE: codes/csharp/chapter_heap/top_k.cs
class top_k (line 9) | public class top_k {
method TopKHeap (line 11) | PriorityQueue<int, int> TopKHeap(int[] nums, int k) {
method Test (line 29) | [Test]
FILE: codes/csharp/chapter_searching/binary_search.cs
class binary_search (line 9) | public class binary_search {
method BinarySearch (line 11) | int BinarySearch(int[] nums, int target) {
method BinarySearchLCRO (line 29) | int BinarySearchLCRO(int[] nums, int target) {
method Test (line 46) | [Test]
FILE: codes/csharp/chapter_searching/binary_search_edge.cs
class binary_search_edge (line 9) | public class binary_search_edge {
method BinarySearchLeftEdge (line 11) | int BinarySearchLeftEdge(int[] nums, int target) {
method BinarySearchRightEdge (line 23) | int BinarySearchRightEdge(int[] nums, int target) {
method Test (line 36) | [Test]
FILE: codes/csharp/chapter_searching/binary_search_insertion.cs
class binary_search_insertion (line 9) | public class binary_search_insertion {
method BinarySearchInsertionSimple (line 11) | public static int BinarySearchInsertionSimple(int[] nums, int target) {
method BinarySearchInsertion (line 28) | public static int BinarySearchInsertion(int[] nums, int target) {
method Test (line 44) | [Test]
FILE: codes/csharp/chapter_searching/hashing_search.cs
class hashing_search (line 9) | public class hashing_search {
method HashingSearchArray (line 11) | int HashingSearchArray(Dictionary<int, int> map, int target) {
method HashingSearchLinkedList (line 18) | ListNode? HashingSearchLinkedList(Dictionary<int, ListNode> map, int t...
method Test (line 25) | [Test]
FILE: codes/csharp/chapter_searching/linear_search.cs
class linear_search (line 9) | public class linear_search {
method LinearSearchArray (line 11) | int LinearSearchArray(int[] nums, int target) {
method LinearSearchLinkedList (line 23) | ListNode? LinearSearchLinkedList(ListNode? head, int target) {
method Test (line 35) | [Test]
FILE: codes/csharp/chapter_searching/two_sum.cs
class two_sum (line 9) | public class two_sum {
method TwoSumBruteForce (line 11) | int[] TwoSumBruteForce(int[] nums, int target) {
method TwoSumHashTable (line 24) | int[] TwoSumHashTable(int[] nums, int target) {
method Test (line 38) | [Test]
FILE: codes/csharp/chapter_sorting/bubble_sort.cs
class bubble_sort (line 9) | public class bubble_sort {
method BubbleSort (line 11) | void BubbleSort(int[] nums) {
method BubbleSortWithFlag (line 25) | void BubbleSortWithFlag(int[] nums) {
method Test (line 41) | [Test]
FILE: codes/csharp/chapter_sorting/bucket_sort.cs
class bucket_sort (line 9) | public class bucket_sort {
method BucketSort (line 11) | void BucketSort(float[] nums) {
method Test (line 39) | [Test]
FILE: codes/csharp/chapter_sorting/counting_sort.cs
class counting_sort (line 9) | public class counting_sort {
method CountingSortNaive (line 12) | void CountingSortNaive(int[] nums) {
method CountingSort (line 35) | void CountingSort(int[] nums) {
method Test (line 67) | [Test]
FILE: codes/csharp/chapter_sorting/heap_sort.cs
class heap_sort (line 9) | public class heap_sort {
method SiftDown (line 11) | void SiftDown(int[] nums, int n, int i) {
method HeapSort (line 32) | void HeapSort(int[] nums) {
method Test (line 46) | [Test]
FILE: codes/csharp/chapter_sorting/insertion_sort.cs
class insertion_sort (line 9) | public class insertion_sort {
method InsertionSort (line 11) | void InsertionSort(int[] nums) {
method Test (line 24) | [Test]
FILE: codes/csharp/chapter_sorting/merge_sort.cs
class merge_sort (line 9) | public class merge_sort {
method Merge (line 11) | void Merge(int[] nums, int left, int mid, int right) {
method MergeSort (line 38) | void MergeSort(int[] nums, int left, int right) {
method Test (line 49) | [Test]
FILE: codes/csharp/chapter_sorting/quick_sort.cs
class quickSort (line 9) | class quickSort {
method Swap (line 11) | static void Swap(int[] nums, int i, int j) {
method Partition (line 16) | static int Partition(int[] nums, int left, int right) {
method QuickSort (line 31) | public static void QuickSort(int[] nums, int left, int right) {
class QuickSortMedian (line 44) | class QuickSortMedian {
method Swap (line 46) | static void Swap(int[] nums, int i, int j) {
method MedianThree (line 51) | static int MedianThree(int[] nums, int left, int mid, int right) {
method Partition (line 61) | static int Partition(int[] nums, int left, int right) {
method QuickSort (line 80) | public static void QuickSort(int[] nums, int left, int right) {
class QuickSortTailCall (line 93) | class QuickSortTailCall {
method Swap (line 95) | static void Swap(int[] nums, int i, int j) {
method Partition (line 100) | static int Partition(int[] nums, int left, int right) {
method QuickSort (line 115) | public static void QuickSort(int[] nums, int left, int right) {
class quick_sort (line 132) | public class quick_sort {
method Test (line 133) | [Test]
FILE: codes/csharp/chapter_sorting/radix_sort.cs
class radix_sort (line 9) | public class radix_sort {
method Digit (line 11) | int Digit(int num, int exp) {
method CountingSortDigit (line 17) | void CountingSortDigit(int[] nums, int exp) {
method RadixSort (line 45) | void RadixSort(int[] nums) {
method Test (line 61) | [Test]
FILE: codes/csharp/chapter_sorting/selection_sort.cs
class selection_sort (line 9) | public class selection_sort {
method SelectionSort (line 11) | void SelectionSort(int[] nums) {
method Test (line 26) | [Test]
FILE: codes/csharp/chapter_stack_and_queue/array_deque.cs
class ArrayDeque (line 10) | public class ArrayDeque {
method ArrayDeque (line 16) | public ArrayDeque(int capacity) {
method Capacity (line 22) | int Capacity() {
method Size (line 27) | public int Size() {
method IsEmpty (line 32) | public bool IsEmpty() {
method Index (line 37) | int Index(int i) {
method PushFirst (line 45) | public void PushFirst(int num) {
method PushLast (line 59) | public void PushLast(int num) {
method PopFirst (line 72) | public int PopFirst() {
method PopLast (line 81) | public int PopLast() {
method PeekFirst (line 88) | public int PeekFirst() {
method PeekLast (line 96) | public int PeekLast() {
method ToArray (line 106) | public int[] ToArray() {
class array_deque (line 116) | public class array_deque {
method Test (line 117) | [Test]
FILE: codes/csharp/chapter_stack_and_queue/array_queue.cs
class ArrayQueue (line 10) | class ArrayQueue {
method ArrayQueue (line 15) | public ArrayQueue(int capacity) {
method Capacity (line 21) | int Capacity() {
method Size (line 26) | public int Size() {
method IsEmpty (line 31) | public bool IsEmpty() {
method Push (line 36) | public void Push(int num) {
method Pop (line 50) | public int Pop() {
method Peek (line 59) | public int Peek() {
method ToArray (line 66) | public int[] ToArray() {
class array_queue (line 76) | public class array_queue {
method Test (line 77) | [Test]
FILE: codes/csharp/chapter_stack_and_queue/array_stack.cs
class ArrayStack (line 10) | class ArrayStack {
method ArrayStack (line 12) | public ArrayStack() {
method Size (line 18) | public int Size() {
method IsEmpty (line 23) | public bool IsEmpty() {
method Push (line 28) | public void Push(int num) {
method Pop (line 33) | public int Pop() {
method Peek (line 42) | public int Peek() {
method ToArray (line 49) | public int[] ToArray() {
class array_stack (line 54) | public class array_stack {
method Test (line 55) | [Test]
FILE: codes/csharp/chapter_stack_and_queue/deque.cs
class deque (line 9) | public class deque {
method Test (line 10) | [Test]
FILE: codes/csharp/chapter_stack_and_queue/linkedlist_deque.cs
class ListNode (line 10) | public class ListNode(int val) {
class LinkedListDeque (line 17) | public class LinkedListDeque {
method LinkedListDeque (line 21) | public LinkedListDeque() {
method Size (line 27) | public int Size() {
method IsEmpty (line 32) | public bool IsEmpty() {
method Push (line 37) | void Push(int num, bool isFront) {
method PushFirst (line 63) | public void PushFirst(int num) {
method PushLast (line 68) | public void PushLast(int num) {
method Pop (line 73) | int? Pop(bool isFront) {
method PopFirst (line 105) | public int? PopFirst() {
method PopLast (line 110) | public int? PopLast() {
method PeekFirst (line 115) | public int? PeekFirst() {
method PeekLast (line 122) | public int? PeekLast() {
method ToArray (line 129) | public int?[] ToArray() {
class linkedlist_deque (line 141) | public class linkedlist_deque {
method Test (line 142) | [Test]
FILE: codes/csharp/chapter_stack_and_queue/linkedlist_queue.cs
class LinkedListQueue (line 10) | class LinkedListQueue {
method LinkedListQueue (line 14) | public LinkedListQueue() {
method Size (line 20) | public int Size() {
method IsEmpty (line 25) | public bool IsEmpty() {
method Push (line 30) | public void Push(int num) {
method Pop (line 46) | public int Pop() {
method Peek (line 55) | public int Peek() {
method ToArray (line 62) | public int[] ToArray() {
class linkedlist_queue (line 76) | public class linkedlist_queue {
method Test (line 77) | [Test]
FILE: codes/csharp/chapter_stack_and_queue/linkedlist_stack.cs
class LinkedListStack (line 10) | class LinkedListStack {
method LinkedListStack (line 14) | public LinkedListStack() {
method Size (line 19) | public int Size() {
method IsEmpty (line 24) | public bool IsEmpty() {
method Push (line 29) | public void Push(int num) {
method Pop (line 38) | public int Pop() {
method Peek (line 46) | public int Peek() {
method ToArray (line 53) | public int[] ToArray() {
class linkedlist_stack (line 67) | public class linkedlist_stack {
method Test (line 68) | [Test]
FILE: codes/csharp/chapter_stack_and_queue/queue.cs
class queue (line 9) | public class queue {
method Test (line 10) | [Test]
FILE: codes/csharp/chapter_stack_and_queue/stack.cs
class stack (line 9) | public class stack {
method Test (line 10) | [Test]
FILE: codes/csharp/chapter_tree/array_binary_tree.cs
class ArrayBinaryTree (line 10) | public class ArrayBinaryTree(List<int?> arr) {
method Size (line 14) | public int Size() {
method Val (line 19) | public int? Val(int i) {
method Left (line 27) | public int Left(int i) {
method Right (line 32) | public int Right(int i) {
method Parent (line 37) | public int Parent(int i) {
method LevelOrder (line 42) | public List<int> LevelOrder() {
method DFS (line 53) | void DFS(int i, string order, List<int> res) {
method PreOrder (line 71) | public List<int> PreOrder() {
method InOrder (line 78) | public List<int> InOrder() {
method PostOrder (line 85) | public List<int> PostOrder() {
class array_binary_tree (line 92) | public class array_binary_tree {
method Test (line 93) | [Test]
FILE: codes/csharp/chapter_tree/avl_tree.cs
class AVLTree (line 10) | class AVLTree {
method Height (line 14) | int Height(TreeNode? node) {
method UpdateHeight (line 20) | void UpdateHeight(TreeNode node) {
method BalanceFactor (line 26) | public int BalanceFactor(TreeNode? node) {
method RightRotate (line 34) | TreeNode? RightRotate(TreeNode? node) {
method LeftRotate (line 48) | TreeNode? LeftRotate(TreeNode? node) {
method Rotate (line 62) | TreeNode? Rotate(TreeNode? node) {
method Insert (line 92) | public void Insert(int val) {
method InsertHelper (line 97) | TreeNode? InsertHelper(TreeNode? node, int val) {
method Remove (line 114) | public void Remove(int val) {
method RemoveHelper (line 119) | TreeNode? RemoveHelper(TreeNode? node, int val) {
method Search (line 153) | public TreeNode? Search(int val) {
class avl_tree (line 172) | public class avl_tree {
method TestInsert (line 173) | static void TestInsert(AVLTree tree, int val) {
method TestRemove (line 179) | static void TestRemove(AVLTree tree, int val) {
method Test (line 185) | [Test]
FILE: codes/csharp/chapter_tree/binary_search_tree.cs
class BinarySearchTree (line 9) | class BinarySearchTree {
method BinarySearchTree (line 12) | public BinarySearchTree() {
method GetRoot (line 18) | public TreeNode? GetRoot() {
method Search (line 23) | public TreeNode? Search(int num) {
method Insert (line 42) | public void Insert(int num) {
method Remove (line 75) | public void Remove(int num) {
class binary_search_tree (line 126) | public class binary_search_tree {
method Test (line 127) | [Test]
FILE: codes/csharp/chapter_tree/binary_tree.cs
class binary_tree (line 9) | public class binary_tree {
method Test (line 10) | [Test]
FILE: codes/csharp/chapter_tree/binary_tree_bfs.cs
class binary_tree_bfs (line 9) | public class binary_tree_bfs {
method LevelOrder (line 12) | List<int> LevelOrder(TreeNode root) {
method Test (line 29) | [Test]
FILE: codes/csharp/chapter_tree/binary_tree_dfs.cs
class binary_tree_dfs (line 9) | public class binary_tree_dfs {
method PreOrder (line 13) | void PreOrder(TreeNode? root) {
method InOrder (line 22) | void InOrder(TreeNode? root) {
method PostOrder (line 31) | void PostOrder(TreeNode? root) {
method Test (line 39) | [Test]
FILE: codes/csharp/utils/ListNode.cs
class ListNode (line 8) | public class ListNode(int x) {
method ArrToLinkedList (line 13) | public static ListNode? ArrToLinkedList(int[] arr) {
method ToString (line 23) | public override string? ToString() {
FILE: codes/csharp/utils/PrintUtil.cs
class Trunk (line 9) | public class Trunk(Trunk? prev, string str) {
class PrintUtil (line 14) | public static class PrintUtil {
method PrintList (line 16) | public static void PrintList<T>(IList<T> list) {
method PrintList (line 20) | public static string PrintList<T>(this IEnumerable<T?> list) {
method PrintMatrix (line 25) | public static void PrintMatrix<T>(T[][] matrix) {
method PrintMatrix (line 34) | public static void PrintMatrix<T>(List<List<T>> matrix) {
method PrintLinkedList (line 43) | public static void PrintLinkedList(ListNode? head) {
method PrintTree (line 57) | public static void PrintTree(TreeNode? root) {
method PrintTree (line 62) | public static void PrintTree(TreeNode? root, Trunk? prev, bool isRight) {
method ShowTrunks (line 93) | public static void ShowTrunks(Trunk? p) {
method PrintHashMap (line 103) | public static void PrintHashMap<K, V>(Dictionary<K, V> map) where K : ...
method PrintHeap (line 110) | public static void PrintHeap(Queue<int> queue) {
method PrintHeap (line 120) | public static void PrintHeap(PriorityQueue<int, int> queue) {
FILE: codes/csharp/utils/TreeNode.cs
class TreeNode (line 10) | public class TreeNode(int? x) {
method ListToTreeDFS (line 33) | static TreeNode? ListToTreeDFS(List<int?> arr, int i) {
method ListToTree (line 45) | public static TreeNode? ListToTree(List<int?> arr) {
method TreeToListDFS (line 50) | static void TreeToListDFS(TreeNode? root, int i, List<int?> res) {
method TreeToList (line 62) | public static List<int?> TreeToList(TreeNode root) {
FILE: codes/csharp/utils/Vertex.cs
class Vertex (line 10) | public class Vertex(int val) {
method ValsToVets (line 14) | public static Vertex[] ValsToVets(int[] vals) {
method VetsToVals (line 23) | public static List<int> VetsToVals(List<Vertex> vets) {
FILE: codes/dart/build.dart
function main (line 3) | void main()
FILE: codes/dart/chapter_array_and_linkedlist/array.dart
function randomAccess (line 12) | int randomAccess(List<int> nums)
function extend (line 21) | List<int> extend(List<int> nums, int enlarge)
function insert (line 33) | void insert(List<int> nums, int _num, int index)
function remove (line 43) | void remove(List<int> nums, int index)
function traverse (line 51) | void traverse(List<int> nums)
function find (line 68) | int find(List<int> nums, int target)
function main (line 76) | void main()
FILE: codes/dart/chapter_array_and_linkedlist/linked_list.dart
function insert (line 11) | void insert(ListNode n0, ListNode P)
function remove (line 18) | void remove(ListNode n0)
function access (line 27) | ListNode? access(ListNode? head, int index)
function find (line 36) | int find(ListNode? head, int target)
function main (line 49) | void main()
FILE: codes/dart/chapter_array_and_linkedlist/list.dart
function main (line 10) | void main()
FILE: codes/dart/chapter_array_and_linkedlist/my_list.dart
class MyList (line 8) | class MyList {
method size (line 20) | int size()
method capacity (line 23) | int capacity()
method get (line 26) | int get(int index)
method set (line 32) | void set(int index, int _num)
method add (line 38) | void add(int _num)
method insert (line 47) | void insert(int index, int _num)
method remove (line 61) | int remove(int index)
method extendCapacity (line 75) | void extendCapacity()
method toArray (line 87) | List<int> toArray()
function main (line 97) | void main()
FILE: codes/dart/chapter_backtracking/n_queens.dart
function backtrack (line 8) | void backtrack(
function nQueens (line 50) | List<List<List<String>>> nQueens(int n)
function main (line 64) | void main()
FILE: codes/dart/chapter_backtracking/permutations_i.dart
function backtrack (line 8) | void backtrack(
function permutationsI (line 37) | List<List<int>> permutationsI(List<int> nums)
function main (line 44) | void main()
FILE: codes/dart/chapter_backtracking/permutations_ii.dart
function backtrack (line 8) | void backtrack(
function permutationsII (line 39) | List<List<int>> permutationsII(List<int> nums)
function main (line 46) | void main()
FILE: codes/dart/chapter_backtracking/preorder_traversal_i_compact.dart
function preOrder (line 11) | void preOrder(TreeNode? root, List<TreeNode> res)
function main (line 24) | void main()
FILE: codes/dart/chapter_backtracking/preorder_traversal_ii_compact.dart
function preOrder (line 11) | void preOrder(
function main (line 33) | void main()
FILE: codes/dart/chapter_backtracking/preorder_traversal_iii_compact.dart
function preOrder (line 11) | void preOrder(
function main (line 33) | void main()
FILE: codes/dart/chapter_backtracking/preorder_traversal_iii_template.dart
function isSolution (line 11) | bool isSolution(List<TreeNode> state)
function recordSolution (line 16) | void recordSolution(List<TreeNode> state, List<List<TreeNode>> res)
function isValid (line 21) | bool isValid(List<TreeNode> state, TreeNode? choice)
function makeChoice (line 26) | void makeChoice(List<TreeNode> state, TreeNode? choice)
function undoChoice (line 31) | void undoChoice(List<TreeNode> state, TreeNode? choice)
function backtrack (line 36) | void backtrack(
function main (line 61) | void main()
FILE: codes/dart/chapter_backtracking/subset_sum_i.dart
function backtrack (line 8) | void backtrack(
function subsetSumI (line 38) | List<List<int>> subsetSumI(List<int> nums, int target)
function main (line 48) | void main()
FILE: codes/dart/chapter_backtracking/subset_sum_i_naive.dart
function backtrack (line 8) | void backtrack(
function subsetSumINaive (line 36) | List<List<int>> subsetSumINaive(List<int> nums, int target)
function main (line 45) | void main()
FILE: codes/dart/chapter_backtracking/subset_sum_ii.dart
function backtrack (line 8) | void backtrack(
function subsetSumII (line 43) | List<List<int>> subsetSumII(List<int> nums, int target)
function main (line 53) | void main()
FILE: codes/dart/chapter_computational_complexity/iteration.dart
function forLoop (line 8) | int forLoop(int n)
function whileLoop (line 18) | int whileLoop(int n)
function whileLoopII (line 30) | int whileLoopII(int n)
function nestedForLoop (line 44) | String nestedForLoop(int n)
function main (line 57) | void main()
FILE: codes/dart/chapter_computational_complexity/recursion.dart
function recur (line 8) | int recur(int n)
function forLoopRecur (line 18) | int forLoopRecur(int n)
function tailRecur (line 37) | int tailRecur(int n, int res)
function fib (line 45) | int fib(int n)
function main (line 55) | void main()
FILE: codes/dart/chapter_computational_complexity/space_complexity.dart
function function (line 15) | int function()
function constant (line 21) | void constant(int n)
function linear (line 38) | void linear(int n)
function linearRecur (line 54) | void linearRecur(int n)
function quadratic (line 61) | void quadratic(int n)
function quadraticRecur (line 76) | int quadraticRecur(int n)
function buildTree (line 84) | TreeNode? buildTree(int n)
function main (line 93) | void main()
FILE: codes/dart/chapter_computational_complexity/time_complexity.dart
function constant (line 10) | int constant(int n)
function linear (line 20) | int linear(int n)
function arrayTraversal (line 29) | int arrayTraversal(List<int> nums)
function quadratic (line 39) | int quadratic(int n)
function bubbleSort (line 51) | int bubbleSort(List<int> nums)
function exponential (line 70) | int exponential(int n)
function expRecur (line 84) | int expRecur(int n)
function logarithmic (line 90) | int logarithmic(int n)
function logRecur (line 100) | int logRecur(int n)
function linearLogRecur (line 106) | int linearLogRecur(int n)
function factorialRecur (line 116) | int factorialRecur(int n)
function main (line 127) | void main()
FILE: codes/dart/chapter_computational_complexity/worst_best_time_complexity.dart
function randomNumbers (line 8) | List<int> randomNumbers(int n)
function findOne (line 21) | int findOne(List<int> nums)
function main (line 32) | void main()
FILE: codes/dart/chapter_divide_and_conquer/binary_search_recur.dart
function dfs (line 8) | int dfs(List<int> nums, int target, int i, int j)
function binarySearch (line 28) | int binarySearch(List<int> nums, int target)
function main (line 35) | void main()
FILE: codes/dart/chapter_divide_and_conquer/build_tree.dart
function dfs (line 11) | TreeNode? dfs(
function buildTree (line 35) | TreeNode? buildTree(List<int> preorder, List<int> inorder)
function main (line 46) | void main()
FILE: codes/dart/chapter_divide_and_conquer/hanota.dart
function move (line 8) | void move(List<int> src, List<int> tar)
function dfs (line 16) | void dfs(int i, List<int> src, List<int> buf, List<int> tar)
function solveHanota (line 31) | void solveHanota(List<int> A, List<int> B, List<int> C)
function main (line 38) | void main()
FILE: codes/dart/chapter_dynamic_programming/climbing_stairs_backtrack.dart
function backtrack (line 8) | void backtrack(List<int> choices, int state, int n, List<int> res)
function climbingStairsBacktrack (line 24) | int climbingStairsBacktrack(int n)
function main (line 34) | void main()
FILE: codes/dart/chapter_dynamic_programming/climbing_stairs_constraint_dp.dart
function climbingStairsConstraintDP (line 8) | int climbingStairsConstraintDP(int n)
function main (line 28) | void main()
FILE: codes/dart/chapter_dynamic_programming/climbing_stairs_dfs.dart
function dfs (line 8) | int dfs(int i)
function climbingStairsDFS (line 17) | int climbingStairsDFS(int n)
function main (line 22) | void main()
FILE: codes/dart/chapter_dynamic_programming/climbing_stairs_dfs_mem.dart
function dfs (line 8) | int dfs(int i, List<int> mem)
function climbingStairsDFSMem (line 21) | int climbingStairsDFSMem(int n)
function main (line 28) | void main()
FILE: codes/dart/chapter_dynamic_programming/climbing_stairs_dp.dart
function climbingStairsDP (line 8) | int climbingStairsDP(int n)
function climbingStairsDPComp (line 23) | int climbingStairsDPComp(int n)
function main (line 35) | void main()
FILE: codes/dart/chapter_dynamic_programming/coin_change.dart
function coinChangeDP (line 10) | int coinChangeDP(List<int> coins, int amt)
function coinChangeDPComp (line 35) | int coinChangeDPComp(List<int> coins, int amt)
function main (line 57) | void main()
FILE: codes/dart/chapter_dynamic_programming/coin_change_ii.dart
function coinChangeIIDP (line 8) | int coinChangeIIDP(List<int> coins, int amt)
function coinChangeIIDPComp (line 32) | int coinChangeIIDPComp(List<int> coins, int amt)
function main (line 53) | void main()
FILE: codes/dart/chapter_dynamic_programming/edit_distance.dart
function editDistanceDFS (line 10) | int editDistanceDFS(String s, String t, int i, int j)
function editDistanceDFSMem (line 28) | int editDistanceDFSMem(String s, String t, List<List<int>> mem, int i, i...
function editDistanceDP (line 49) | int editDistanceDP(String s, String t)
function editDistanceDPComp (line 75) | int editDistanceDPComp(String s, String t)
function main (line 104) | void main()
FILE: codes/dart/chapter_dynamic_programming/knapsack.dart
function knapsackDFS (line 10) | int knapsackDFS(List<int> wgt, List<int> val, int i, int c)
function knapsackDFSMem (line 27) | int knapsackDFSMem(
function knapsackDP (line 55) | int knapsackDP(List<int> wgt, List<int> val, int cap)
function knapsackDPComp (line 75) | int knapsackDPComp(List<int> wgt, List<int> val, int cap)
function main (line 93) | void main()
FILE: codes/dart/chapter_dynamic_programming/min_cost_climbing_stairs_dp.dart
function minCostClimbingStairsDP (line 10) | int minCostClimbingStairsDP(List<int> cost)
function minCostClimbingStairsDPComp (line 26) | int minCostClimbingStairsDPComp(List<int> cost)
function main (line 39) | void main()
FILE: codes/dart/chapter_dynamic_programming/min_path_sum.dart
function minPathSumDFS (line 10) | int minPathSumDFS(List<List<int>> grid, int i, int j)
function minPathSumDFSMem (line 28) | int minPathSumDFSMem(List<List<int>> grid, List<List<int>> mem, int i, i...
function minPathSumDP (line 51) | int minPathSumDP(List<List<int>> grid)
function minPathSumDPComp (line 74) | int minPathSumDPComp(List<List<int>> grid)
function main (line 95) | void main()
FILE: codes/dart/chapter_dynamic_programming/unbounded_knapsack.dart
function unboundedKnapsackDP (line 10) | int unboundedKnapsackDP(List<int> wgt, List<int> val, int cap)
function unboundedKnapsackDPComp (line 30) | int unboundedKnapsackDPComp(List<int> wgt, List<int> val, int cap)
function main (line 50) | void main()
FILE: codes/dart/chapter_graph/graph_adjacency_list.dart
class GraphAdjList (line 10) | class GraphAdjList {
method size (line 24) | int size()
method addEdge (line 29) | void addEdge(Vertex vet1, Vertex vet2)
method removeEdge (line 41) | void removeEdge(Vertex vet1, Vertex vet2)
method addVertex (line 53) | void addVertex(Vertex vet)
method removeVertex (line 60) | void removeVertex(Vertex vet)
method printAdjList (line 73) | void printAdjList()
function main (line 86) | void main()
FILE: codes/dart/chapter_graph/graph_adjacency_matrix.dart
class GraphAdjMat (line 10) | class GraphAdjMat {
method size (line 30) | int size()
method addVertex (line 35) | void addVertex(int val)
method removeVertex (line 49) | void removeVertex(int index)
method addEdge (line 65) | void addEdge(int i, int j)
method removeEdge (line 77) | void removeEdge(int i, int j)
method printAdjMat (line 87) | void printAdjMat()
function main (line 95) | void main()
FILE: codes/dart/chapter_graph/graph_bfs.dart
function graphBFS (line 13) | List<Vertex> graphBFS(GraphAdjList graph, Vertex startVet)
function main (line 41) | void main()
FILE: codes/dart/chapter_graph/graph_dfs.dart
function dfs (line 11) | void dfs(
function graphDFS (line 30) | List<Vertex> graphDFS(GraphAdjList graph, Vertex startVet)
function main (line 40) | void main()
FILE: codes/dart/chapter_greedy/coin_change_greedy.dart
function coinChangeGreedy (line 8) | int coinChangeGreedy(List<int> coins, int amt)
function main (line 27) | void main()
FILE: codes/dart/chapter_greedy/fractional_knapsack.dart
class Item (line 8) | class Item {
function fractionalKnapsack (line 16) | double fractionalKnapsack(List<int> wgt, List<int> val, int cap)
function main (line 39) | void main()
FILE: codes/dart/chapter_greedy/max_capacity.dart
function maxCapacity (line 10) | int maxCapacity(List<int> ht)
function main (line 31) | void main()
FILE: codes/dart/chapter_greedy/max_product_cutting.dart
function maxProductCutting (line 10) | int maxProductCutting(int n)
function main (line 31) | void main()
FILE: codes/dart/chapter_hashing/array_hash_map.dart
class Pair (line 8) | class Pair {
class ArrayHashMap (line 15) | class ArrayHashMap {
method _hashFunc (line 24) | int _hashFunc(int key)
method get (line 30) | String? get(int key)
method put (line 40) | void put(int key, String val)
method remove (line 47) | void remove(int key)
method pairSet (line 53) | List<Pair> pairSet()
method keySet (line 64) | List<int> keySet()
method values (line 75) | List<String> values()
method printHashMap (line 86) | void printHashMap()
function main (line 94) | void main()
FILE: codes/dart/chapter_hashing/built_in_hash.dart
function main (line 10) | void main()
FILE: codes/dart/chapter_hashing/hash_map.dart
function main (line 8) | void main()
FILE: codes/dart/chapter_hashing/hash_map_chaining.dart
class HashMapChaining (line 10) | class HashMapChaining {
method hashFunc (line 27) | int hashFunc(int key)
method loadFactor (line 32) | double loadFactor()
method get (line 37) | String? get(int key)
method put (line 51) | void put(int key, String val)
method remove (line 72) | void remove(int key)
method extend (line 86) | void extend()
method printHashMap (line 102) | void printHashMap()
function main (line 114) | void main()
FILE: codes/dart/chapter_hashing/hash_map_open_addressing.dart
class HashMapOpenAddressing (line 10) | class HashMapOpenAddressing {
method hashFunc (line 25) | int hashFunc(int key)
method loadFactor (line 30) | double loadFactor()
method findBucket (line 35) | int findBucket(int key)
method get (line 62) | String? get(int key)
method put (line 74) | void put(int key, String val)
method remove (line 92) | void remove(int key)
method extend (line 103) | void extend()
method printHashMap (line 119) | void printHashMap()
function main (line 133) | void main()
FILE: codes/dart/chapter_hashing/simple_hash.dart
function addHash (line 8) | int addHash(String key)
function mulHash (line 18) | int mulHash(String key)
function xorHash (line 28) | int xorHash(String key)
function rotHash (line 38) | int rotHash(String key)
function main (line 48) | void main()
FILE: codes/dart/chapter_heap/my_heap.dart
class MaxHeap (line 10) | class MaxHeap {
method _left (line 24) | int _left(int i)
method _right (line 29) | int _right(int i)
method _parent (line 34) | int _parent(int i)
method _swap (line 39) | void _swap(int i, int j)
method size (line 46) | int size()
method isEmpty (line 51) | bool isEmpty()
method peek (line 56) | int peek()
method push (line 61) | void push(int val)
method siftUp (line 69) | void siftUp(int i)
method pop (line 85) | int pop()
method siftDown (line 99) | void siftDown(int i)
method print (line 117) | void print()
function main (line 123) | void main()
FILE: codes/dart/chapter_heap/top_k.dart
function topKHeap (line 10) | MinHeap topKHeap(List<int> nums, int k)
function main (line 25) | void main()
class MinHeap (line 35) | class MinHeap {
method getHeap (line 49) | List<int> getHeap()
method _left (line 54) | int _left(int i)
method _right (line 59) | int _right(int i)
method _parent (line 64) | int _parent(int i)
method _swap (line 69) | void _swap(int i, int j)
method size (line 76) | int size()
method isEmpty (line 81) | bool isEmpty()
method peek (line 86) | int peek()
method push (line 91) | void push(int val)
method siftUp (line 99) | void siftUp(int i)
method pop (line 115) | int pop()
method siftDown (line 129) | void siftDown(int i)
method print (line 147) | void print()
FILE: codes/dart/chapter_searching/binary_search.dart
function binarySearch (line 8) | int binarySearch(List<int> nums, int target)
function binarySearchLCRO (line 30) | int binarySearchLCRO(List<int> nums, int target)
function main (line 52) | void main()
FILE: codes/dart/chapter_searching/binary_search_edge.dart
function binarySearchLeftEdge (line 10) | int binarySearchLeftEdge(List<int> nums, int target)
function binarySearchRightEdge (line 22) | int binarySearchRightEdge(List<int> nums, int target)
function main (line 36) | void main()
FILE: codes/dart/chapter_searching/binary_search_insertion.dart
function binarySearchInsertionSimple (line 8) | int binarySearchInsertionSimple(List<int> nums, int target)
function binarySearchInsertion (line 25) | int binarySearchInsertion(List<int> nums, int target)
function main (line 42) | void main()
FILE: codes/dart/chapter_searching/hashing_search.dart
function hashingSearchArray (line 11) | int hashingSearchArray(Map<int, int> map, int target)
function hashingSearchLinkedList (line 21) | ListNode? hashingSearchLinkedList(Map<int, ListNode> map, int target)
function main (line 31) | void main()
FILE: codes/dart/chapter_searching/linear_search.dart
function linearSearchArray (line 10) | int linearSearchArray(List<int> nums, int target)
function linearSearchList (line 23) | ListNode? linearSearchList(ListNode? head, int target)
function main (line 35) | void main()
FILE: codes/dart/chapter_searching/two_sum.dart
function twoSumBruteForce (line 10) | List<int> twoSumBruteForce(List<int> nums, int target)
function twoSumHashTable (line 22) | List<int> twoSumHashTable(List<int> nums, int target)
function main (line 37) | void main()
FILE: codes/dart/chapter_sorting/bubble_sort.dart
function bubbleSort (line 8) | void bubbleSort(List<int> nums)
function bubbleSortWithFlag (line 24) | void bubbleSortWithFlag(List<int> nums)
function main (line 43) | void main()
FILE: codes/dart/chapter_sorting/bucket_sort.dart
function bucketSort (line 8) | void bucketSort(List<double> nums)
function main (line 34) | void main()
FILE: codes/dart/chapter_sorting/counting_sort.dart
function countingSortNaive (line 10) | void countingSortNaive(List<int> nums)
function countingSort (line 33) | void countingSort(List<int> nums)
function main (line 64) | void main()
FILE: codes/dart/chapter_sorting/heap_sort.dart
function siftDown (line 8) | void siftDown(List<int> nums, int n, int i)
function heapSort (line 28) | void heapSort(List<int> nums)
function main (line 45) | void main()
FILE: codes/dart/chapter_sorting/insertion_sort.dart
function insertionSort (line 8) | void insertionSort(List<int> nums)
function main (line 22) | void main()
FILE: codes/dart/chapter_sorting/merge_sort.dart
function merge (line 8) | void merge(List<int> nums, int left, int mid, int right)
function mergeSort (line 35) | void mergeSort(List<int> nums, int left, int right)
function main (line 47) | void main()
FILE: codes/dart/chapter_sorting/quick_sort.dart
class QuickSort (line 8) | class QuickSort {
method _swap (line 10) | void _swap(List<int> nums, int i, int j)
method _partition (line 17) | int _partition(List<int> nums, int left, int right)
method quickSort (line 30) | void quickSort(List<int> nums, int left, int right)
class QuickSortMedian (line 42) | class QuickSortMedian {
method _swap (line 44) | void _swap(List<int> nums, int i, int j)
method _medianThree (line 51) | int _medianThree(List<int> nums, int left, int mid, int right)
method _partition (line 61) | int _partition(List<int> nums, int left, int right)
method quickSort (line 78) | void quickSort(List<int> nums, int left, int right)
class QuickSortTailCall (line 90) | class QuickSortTailCall {
method _swap (line 92) | void _swap(List<int> nums, int i, int j)
method _partition (line 99) | int _partition(List<int> nums, int left, int right)
method quickSort (line 112) | void quickSort(List<int> nums, int left, int right)
function main (line 130) | void main()
FILE: codes/dart/chapter_sorting/radix_sort.dart
function digit (line 8) | int digit(int _num, int exp)
function countingSortDigit (line 14) | void countingSortDigit(List<int> nums, int exp)
function radixSort (line 40) | void radixSort(List<int> nums)
function main (line 55) | void main()
FILE: codes/dart/chapter_sorting/selection_sort.dart
function selectionSort (line 8) | void selectionSort(List<int> nums)
function main (line 25) | void main()
FILE: codes/dart/chapter_stack_and_queue/array_deque.dart
class ArrayDeque (line 8) | class ArrayDeque {
method capacity (line 20) | int capacity()
method size (line 25) | int size()
method isEmpty (line 30) | bool isEmpty()
method index (line 35) | int index(int i)
method pushFirst (line 43) | void pushFirst(int _num)
method pushLast (line 56) | void pushLast(int _num)
method popFirst (line 68) | int popFirst()
method popLast (line 77) | int popLast()
method peekFirst (line 84) | int peekFirst()
method peekLast (line 92) | int peekLast()
method toArray (line 102) | List<int> toArray()
function main (line 113) | void main()
FILE: codes/dart/chapter_stack_and_queue/array_queue.dart
class ArrayQueue (line 8) | class ArrayQueue {
method capaCity (line 19) | int capaCity()
method size (line 24) | int size()
method isEmpty (line 29) | bool isEmpty()
method push (line 34) | void push(int _num)
method pop (line 47) | int pop()
method peek (line 56) | int peek()
method toArray (line 64) | List<int> toArray()
function main (line 75) | void main()
FILE: codes/dart/chapter_stack_and_queue/array_stack.dart
class ArrayStack (line 8) | class ArrayStack {
method size (line 15) | int size()
method isEmpty (line 20) | bool isEmpty()
method push (line 25) | void push(int _num)
method pop (line 30) | int pop()
method peek (line 38) | int peek()
method toArray (line 46) | List<int> toArray()
function main (line 50) | void main()
FILE: codes/dart/chapter_stack_and_queue/deque.dart
function main (line 9) | void main()
FILE: codes/dart/chapter_stack_and_queue/linkedlist_deque.dart
class ListNode (line 8) | class ListNode {
class LinkedListDeque (line 17) | class LinkedListDeque {
method size (line 28) | int size()
method isEmpty (line 33) | bool isEmpty()
method push (line 38) | void push(int _num, bool isFront)
method pushFirst (line 60) | void pushFirst(int _num)
method pushLast (line 65) | void pushLast(int _num)
method pop (line 70) | int? pop(bool isFront)
method popFirst (line 102) | int? popFirst()
method popLast (line 107) | int? popLast()
method peekFirst (line 112) | int? peekFirst()
method peekLast (line 117) | int? peekLast()
method toArray (line 122) | List<int> toArray()
function main (line 134) | void main()
FILE: codes/dart/chapter_stack_and_queue/linkedlist_queue.dart
class LinkedListQueue (line 10) | class LinkedListQueue {
method size (line 21) | int size()
method isEmpty (line 26) | bool isEmpty()
method push (line 31) | void push(int _num)
method pop (line 47) | int pop()
method peek (line 56) | int peek()
method toArray (line 64) | List<int> toArray()
function main (line 76) | void main()
FILE: codes/dart/chapter_stack_and_queue/linkedlist_stack.dart
class LinkedListStack (line 10) | class LinkedListStack {
method size (line 19) | int size()
method isEmpty (line 24) | bool isEmpty()
method push (line 29) | void push(int _num)
method pop (line 37) | int pop()
method peek (line 45) | int peek()
method toList (line 53) | List<int> toList()
function main (line 66) | void main()
FILE: codes/dart/chapter_stack_and_queue/queue.dart
function main (line 9) | void main()
FILE: codes/dart/chapter_stack_and_queue/stack.dart
function main (line 7) | void main()
FILE: codes/dart/chapter_tree/array_binary_tree.dart
class ArrayBinaryTree (line 11) | class ArrayBinaryTree {
method size (line 18) | int size()
method val (line 23) | int? val(int i)
method left (line 32) | int? left(int i)
method right (line 37) | int? right(int i)
method parent (line 42) | int? parent(int i)
method levelOrder (line 47) | List<int> levelOrder()
method dfs (line 58) | void dfs(int i, String order, List<int?> res)
method preOrder (line 80) | List<int?> preOrder()
method inOrder (line 87) | List<int?> inOrder()
method postOrder (line 94) | List<int?> postOrder()
function main (line 102) | void main()
FILE: codes/dart/chapter_tree/avl_tree.dart
class AVLTree (line 11) | class AVLTree {
method height (line 20) | int height(TreeNode? node)
method updateHeight (line 26) | void updateHeight(TreeNode? node)
method balanceFactor (line 32) | int balanceFactor(TreeNode? node)
method rightRotate (line 40) | TreeNode? rightRotate(TreeNode? node)
method leftRotate (line 54) | TreeNode? leftRotate(TreeNode? node)
method rotate (line 68) | TreeNode? rotate(TreeNode? node)
method insert (line 98) | void insert(int val)
method insertHelper (line 103) | TreeNode? insertHelper(TreeNode? node, int val)
method remove (line 120) | void remove(int val)
method removeHelper (line 125) | TreeNode? removeHelper(TreeNode? node, int val)
method search (line 159) | TreeNode? search(int val)
function testInsert (line 177) | void testInsert(AVLTree tree, int val)
function testRemove (line 183) | void testRemove(AVLTree tree, int val)
function main (line 190) | void main()
FILE: codes/dart/chapter_tree/binary_search_tree.dart
class BinarySearchTree (line 11) | class BinarySearchTree {
method getRoot (line 21) | TreeNode? getRoot()
method search (line 26) | TreeNode? search(int _num)
method insert (line 45) | void insert(int _num)
method remove (line 74) | void remove(int _num)
function main (line 123) | void main()
FILE: codes/dart/chapter_tree/binary_tree.dart
function main (line 10) | void main()
FILE: codes/dart/chapter_tree/binary_tree_bfs.dart
function levelOrder (line 12) | List<int> levelOrder(TreeNode? root)
function main (line 28) | void main()
FILE: codes/dart/chapter_tree/binary_tree_dfs.dart
function preOrder (line 14) | void preOrder(TreeNode? node)
function inOrder (line 23) | void inOrder(TreeNode? node)
function postOrder (line 32) | void postOrder(TreeNode? node)
function main (line 41) | void main()
FILE: codes/dart/utils/list_node.dart
class ListNode (line 8) | class ListNode {
function listToLinkedList (line 16) | ListNode? listToLinkedList(List<int> list)
FILE: codes/dart/utils/print_util.dart
class Trunk (line 12) | class Trunk {
function printMatrix (line 20) | void printMatrix(List<List<int>> matrix)
function printLinkedList (line 29) | void printLinkedList(ListNode? head)
function printTree (line 45) | void printTree(TreeNode? root, [Trunk? prev = null, bool isRight = false])
function showTrunks (line 75) | void showTrunks(Trunk? p)
function printHeap (line 85) | void printHeap(List<int> heap)
FILE: codes/dart/utils/tree_node.dart
class TreeNode (line 8) | class TreeNode {
function listToTreeDFS (line 19) | TreeNode? listToTreeDFS(List<int?> arr, int i)
function listToTree (line 30) | TreeNode? listToTree(List<int?> arr)
function treeToListDFS (line 35) | void treeToListDFS(TreeNode? root, int i, List<int?> res)
function treeToList (line 46) | List<int?> treeToList(TreeNode? root)
FILE: codes/dart/utils/vertex.dart
class Vertex (line 8) | class Vertex {
method valsToVets (line 13) | List<Vertex> valsToVets(List<int> vals)
method vetsToVals (line 22) | List<int> vetsToVals(List<Vertex> vets)
FILE: codes/go/chapter_array_and_linkedlist/array.go
function randomAccess (line 12) | func randomAccess(nums []int) (randomNum int) {
function extend (line 21) | func extend(nums []int, enlarge int) []int {
function insert (line 33) | func insert(nums []int, num int, index int) {
function remove (line 43) | func remove(nums []int, index int) {
function traverse (line 51) | func traverse(nums []int) {
function find (line 70) | func find(nums []int, target int) (index int) {
FILE: codes/go/chapter_array_and_linkedlist/array_test.go
function TestArray (line 18) | func TestArray(t *testing.T) {
FILE: codes/go/chapter_array_and_linkedlist/linked_list.go
function insertNode (line 12) | func insertNode(n0 *ListNode, P *ListNode) {
function removeItem (line 19) | func removeItem(n0 *ListNode) {
function access (line 30) | func access(head *ListNode, index int) *ListNode {
function findNode (line 41) | func findNode(head *ListNode, target int) int {
FILE: codes/go/chapter_array_and_linkedlist/linked_list_test.go
function TestLinkedList (line 14) | func TestLinkedList(t *testing.T) {
FILE: codes/go/chapter_array_and_linkedlist/list_test.go
function TestList (line 14) | func TestList(t *testing.T) {
FILE: codes/go/chapter_array_and_linkedlist/my_list.go
type myList (line 8) | type myList struct
method size (line 26) | func (l *myList) size() int {
method capacity (line 31) | func (l *myList) capacity() int {
method get (line 36) | func (l *myList) get(index int) int {
method set (line 45) | func (l *myList) set(num, index int) {
method add (line 53) | func (l *myList) add(num int) {
method insert (line 64) | func (l *myList) insert(num, index int) {
method remove (line 82) | func (l *myList) remove(index int) int {
method extendCapacity (line 98) | func (l *myList) extendCapacity() {
method toArray (line 106) | func (l *myList) toArray() []int {
function newMyList (line 16) | func newMyList() *myList {
FILE: codes/go/chapter_array_and_linkedlist/my_list_test.go
function TestMyList (line 13) | func TestMyList(t *testing.T) {
FILE: codes/go/chapter_backtracking/n_queens.go
function backtrack (line 8) | func backtrack(row, n int, state *[][]string, res *[][][]string, cols, d...
function nQueens (line 40) | func nQueens(n int) [][][]string {
FILE: codes/go/chapter_backtracking/n_queens_test.go
function TestNQueens (line 12) | func TestNQueens(t *testing.T) {
FILE: codes/go/chapter_backtracking/permutation_test.go
function TestPermutationI (line 14) | func TestPermutationI(t *testing.T) {
function TestPermutationII (line 25) | func TestPermutationII(t *testing.T) {
FILE: codes/go/chapter_backtracking/permutations_i.go
function backtrackI (line 8) | func backtrackI(state *[]int, choices *[]int, selected *[]bool, res *[][...
function permutationsI (line 32) | func permutationsI(nums []int) [][]int {
FILE: codes/go/chapter_backtracking/permutations_ii.go
function backtrackII (line 8) | func backtrackII(state *[]int, choices *[]int, selected *[]bool, res *[]...
function permutationsII (line 35) | func permutationsII(nums []int) [][]int {
FILE: codes/go/chapter_backtracking/preorder_traversal_i_compact.go
function preOrderI (line 12) | func preOrderI(root *TreeNode, res *[]*TreeNode) {
FILE: codes/go/chapter_backtracking/preorder_traversal_ii_compact.go
function preOrderII (line 12) | func preOrderII(root *TreeNode, res *[][]*TreeNode, path *[]*TreeNode) {
FILE: codes/go/chapter_backtracking/preorder_traversal_iii_compact.go
function preOrderIII (line 12) | func preOrderIII(root *TreeNode, res *[][]*TreeNode, path *[]*TreeNode) {
FILE: codes/go/chapter_backtracking/preorder_traversal_iii_template.go
function isSolution (line 12) | func isSolution(state *[]*TreeNode) bool {
function recordSolution (line 17) | func recordSolution(state *[]*TreeNode, res *[][]*TreeNode) {
function isValid (line 22) | func isValid(state *[]*TreeNode, choice *TreeNode) bool {
function makeChoice (line 27) | func makeChoice(state *[]*TreeNode, choice *TreeNode) {
function undoChoice (line 32) | func undoChoice(state *[]*TreeNode, choice *TreeNode) {
function backtrackIII (line 37) | func backtrackIII(state *[]*TreeNode, choices *[]*TreeNode, res *[][]*Tr...
FILE: codes/go/chapter_backtracking/preorder_traversal_test.go
function TestPreorderTraversalICompact (line 14) | func TestPreorderTraversalICompact(t *testing.T) {
function TestPreorderTraversalIICompact (line 31) | func TestPreorderTraversalIICompact(t *testing.T) {
function TestPreorderTraversalIIICompact (line 51) | func TestPreorderTraversalIIICompact(t *testing.T) {
function TestPreorderTraversalIIITemplate (line 71) | func TestPreorderTraversalIIITemplate(t *testing.T) {
FILE: codes/go/chapter_backtracking/subset_sum_i.go
function backtrackSubsetSumI (line 10) | func backtrackSubsetSumI(start, target int, state, choices *[]int, res *...
function subsetSumI (line 35) | func subsetSumI(nums []int, target int) [][]int {
FILE: codes/go/chapter_backtracking/subset_sum_i_naive.go
function backtrackSubsetSumINaive (line 8) | func backtrackSubsetSumINaive(total, target int, state, choices *[]int, ...
function subsetSumINaive (line 31) | func subsetSumINaive(nums []int, target int) [][]int {
FILE: codes/go/chapter_backtracking/subset_sum_ii.go
function backtrackSubsetSumII (line 10) | func backtrackSubsetSumII(start, target int, state, choices *[]int, res ...
function subsetSumII (line 40) | func subsetSumII(nums []int, target int) [][]int {
FILE: codes/go/chapter_backtracking/subset_sum_test.go
function TestSubsetSumINaive (line 15) | func TestSubsetSumINaive(t *testing.T) {
function TestSubsetSumI (line 30) | func TestSubsetSumI(t *testing.T) {
function TestSubsetSumII (line 44) | func TestSubsetSumII(t *testing.T) {
FILE: codes/go/chapter_computational_complexity/iteration.go
function forLoop (line 10) | func forLoop(n int) int {
function whileLoop (line 20) | func whileLoop(n int) int {
function whileLoopII (line 34) | func whileLoopII(n int) int {
function nestedForLoop (line 49) | func nestedForLoop(n int) string {
FILE: codes/go/chapter_computational_complexity/iteration_test.go
function TestIteration (line 13) | func TestIteration(t *testing.T) {
FILE: codes/go/chapter_computational_complexity/recursion.go
function recur (line 10) | func recur(n int) int {
function forLoopRecur (line 22) | func forLoopRecur(n int) int {
function tailRecur (line 42) | func tailRecur(n int, res int) int {
function fib (line 52) | func fib(n int) int {
FILE: codes/go/chapter_computational_complexity/recursion_test.go
function TestRecursion (line 13) | func TestRecursion(t *testing.T) {
FILE: codes/go/chapter_computational_complexity/space_complexity.go
type node (line 15) | type node struct
function newNode (line 21) | func newNode(val int) *node {
function function (line 26) | func function() int {
function spaceConstant (line 32) | func spaceConstant(n int) {
function spaceLinear (line 54) | func spaceLinear(n int) {
function spaceLinearRecur (line 70) | func spaceLinearRecur(n int) {
function spaceQuadratic (line 79) | func spaceQuadratic(n int) {
function spaceQuadraticRecur (line 88) | func spaceQuadraticRecur(n int) int {
function buildTree (line 98) | func buildTree(n int) *TreeNode {
FILE: codes/go/chapter_computational_complexity/space_complexity_test.go
function TestSpaceComplexity (line 13) | func TestSpaceComplexity(t *testing.T) {
FILE: codes/go/chapter_computational_complexity/time_complexity.go
function constant (line 8) | func constant(n int) int {
function linear (line 18) | func linear(n int) int {
function arrayTraversal (line 27) | func arrayTraversal(nums []int) int {
function quadratic (line 37) | func quadratic(n int) int {
function bubbleSort (line 49) | func bubbleSort(nums []int) int {
function exponential (line 68) | func exponential(n int) int {
function expRecur (line 82) | func expRecur(n int) int {
function logarithmic (line 90) | func logarithmic(n int) int {
function logRecur (line 100) | func logRecur(n int) int {
function linearLogRecur (line 108) | func linearLogRecur(n int) int {
function factorialRecur (line 120) | func factorialRecur(n int) int {
FILE: codes/go/chapter_computational_complexity/time_complexity_test.go
function TestTimeComplexity (line 12) | func TestTimeComplexity(t *testing.T) {
FILE: codes/go/chapter_computational_complexity/worst_best_time_complexity.go
function randomNumbers (line 12) | func randomNumbers(n int) []int {
function findOne (line 26) | func findOne(nums []int) int {
FILE: codes/go/chapter_computational_complexity/worst_best_time_complexity_test.go
function TestWorstBestTimeComplexity (line 12) | func TestWorstBestTimeComplexity(t *testing.T) {
FILE: codes/go/chapter_divide_and_conquer/binary_search_recur.go
function dfs (line 8) | func dfs(nums []int, target, i, j int) int {
function binarySearch (line 31) | func binarySearch(nums []int, target int) int {
FILE: codes/go/chapter_divide_and_conquer/binary_search_recur_test.go
function TestBinarySearch (line 12) | func TestBinarySearch(t *testing.T) {
FILE: codes/go/chapter_divide_and_conquer/build_tree.go
function dfsBuildTree (line 10) | func dfsBuildTree(preorder []int, inorderMap map[int]int, i, l, r int) *...
function buildTree (line 28) | func buildTree(preorder, inorder []int) *TreeNode {
FILE: codes/go/chapter_divide_and_conquer/build_tree_test.go
function TestBuildTree (line 14) | func TestBuildTree(t *testing.T) {
FILE: codes/go/chapter_divide_and_conquer/hanota.go
function move (line 10) | func move(src, tar *list.List) {
function dfsHanota (line 20) | func dfsHanota(i int, src, buf, tar *list.List) {
function solveHanota (line 35) | func solveHanota(A, B, C *list.List) {
FILE: codes/go/chapter_divide_and_conquer/hanota_test.go
function TestHanota (line 15) | func TestHanota(t *testing.T) {
FILE: codes/go/chapter_dynamic_programming/climbing_stairs_backtrack.go
function backtrack (line 8) | func backtrack(choices []int, state, n int, res []int) {
function climbingStairsBacktrack (line 26) | func climbingStairsBacktrack(n int) int {
FILE: codes/go/chapter_dynamic_programming/climbing_stairs_constraint_dp.go
function climbingStairsConstraintDP (line 8) | func climbingStairsConstraintDP(n int) int {
FILE: codes/go/chapter_dynamic_programming/climbing_stairs_dfs.go
function dfs (line 8) | func dfs(i int) int {
function climbingStairsDFS (line 19) | func climbingStairsDFS(n int) int {
FILE: codes/go/chapter_dynamic_programming/climbing_stairs_dfs_mem.go
function dfsMem (line 8) | func dfsMem(i int, mem []int) int {
function climbingStairsDFSMem (line 25) | func climbingStairsDFSMem(n int) int {
FILE: codes/go/chapter_dynamic_programming/climbing_stairs_dp.go
function climbingStairsDP (line 8) | func climbingStairsDP(n int) int {
function climbingStairsDPComp (line 25) | func climbingStairsDPComp(n int) int {
FILE: codes/go/chapter_dynamic_programming/climbing_stairs_test.go
function TestClimbingStairsBacktrack (line 12) | func TestClimbingStairsBacktrack(t *testing.T) {
function TestClimbingStairsDFS (line 18) | func TestClimbingStairsDFS(t *testing.T) {
function TestClimbingStairsDFSMem (line 24) | func TestClimbingStairsDFSMem(t *testing.T) {
function TestClimbingStairsDP (line 30) | func TestClimbingStairsDP(t *testing.T) {
function TestClimbingStairsDPComp (line 36) | func TestClimbingStairsDPComp(t *testing.T) {
function TestClimbingStairsConstraintDP (line 42) | func TestClimbingStairsConstraintDP(t *testing.T) {
function TestMinCostClimbingStairsDPComp (line 48) | func TestMinCostClimbingStairsDPComp(t *testing.T) {
FILE: codes/go/chapter_dynamic_programming/coin_change.go
function coinChangeDP (line 10) | func coinChangeDP(coins []int, amt int) int {
function coinChangeDPComp (line 41) | func coinChangeDPComp(coins []int, amt int) int {
FILE: codes/go/chapter_dynamic_programming/coin_change_ii.go
function coinChangeIIDP (line 8) | func coinChangeIIDP(coins []int, amt int) int {
function coinChangeIIDPComp (line 35) | func coinChangeIIDPComp(coins []int, amt int) int {
FILE: codes/go/chapter_dynamic_programming/coin_change_test.go
function TestCoinChange (line 12) | func TestCoinChange(t *testing.T) {
FILE: codes/go/chapter_dynamic_programming/edit_distance.go
function editDistanceDFS (line 8) | func editDistanceDFS(s string, t string, i int, j int) int {
function editDistanceDFSMem (line 34) | func editDistanceDFSMem(s string, t string, mem [][]int, i int, j int) i...
function editDistanceDP (line 65) | func editDistanceDP(s string, t string) int {
function editDistanceDPComp (line 95) | func editDistanceDPComp(s string, t string) int {
function MinInt (line 124) | func MinInt(a, b int) int {
FILE: codes/go/chapter_dynamic_programming/edit_distance_test.go
function TestEditDistanceDFS (line 12) | func TestEditDistanceDFS(test *testing.T) {
FILE: codes/go/chapter_dynamic_programming/knapsack.go
function knapsackDFS (line 10) | func knapsackDFS(wgt, val []int, i, c int) int {
function knapsackDFSMem (line 27) | func knapsackDFSMem(wgt, val []int, mem [][]int, i, c int) int {
function knapsackDP (line 49) | func knapsackDP(wgt, val []int, cap int) int {
function knapsackDPComp (line 72) | func knapsackDPComp(wgt, val []int, cap int) int {
FILE: codes/go/chapter_dynamic_programming/knapsack_test.go
function TestKnapsack (line 12) | func TestKnapsack(t *testing.T) {
function TestUnboundedKnapsack (line 42) | func TestUnboundedKnapsack(t *testing.T) {
FILE: codes/go/chapter_dynamic_programming/min_cost_climbing_stairs_dp.go
function minCostClimbingStairsDP (line 8) | func minCostClimbingStairsDP(cost []int) int {
function minCostClimbingStairsDPComp (line 32) | func minCostClimbingStairsDPComp(cost []int) int {
FILE: codes/go/chapter_dynamic_programming/min_path_sum.go
function minPathSumDFS (line 10) | func minPathSumDFS(grid [][]int, i, j int) int {
function minPathSumDFSMem (line 27) | func minPathSumDFSMem(grid, mem [][]int, i, j int) int {
function minPathSumDP (line 49) | func minPathSumDP(grid [][]int) int {
function minPathSumDPComp (line 75) | func minPathSumDPComp(grid [][]int) int {
FILE: codes/go/chapter_dynamic_programming/min_path_sum_test.go
function TestMinPathSum (line 12) | func TestMinPathSum(t *testing.T) {
FILE: codes/go/chapter_dynamic_programming/unbounded_knapsack.go
function unboundedKnapsackDP (line 10) | func unboundedKnapsackDP(wgt, val []int, cap int) int {
function unboundedKnapsackDPComp (line 33) | func unboundedKnapsackDPComp(wgt, val []int, cap int) int {
FILE: codes/go/chapter_graph/graph_adjacency_list.go
type graphAdjList (line 16) | type graphAdjList struct
method size (line 36) | func (g *graphAdjList) size() int {
method addEdge (line 41) | func (g *graphAdjList) addEdge(vet1 Vertex, vet2 Vertex) {
method removeEdge (line 53) | func (g *graphAdjList) removeEdge(vet1 Vertex, vet2 Vertex) {
method addVertex (line 65) | func (g *graphAdjList) addVertex(vet Vertex) {
method removeVertex (line 75) | func (g *graphAdjList) removeVertex(vet Vertex) {
method print (line 89) | func (g *graphAdjList) print() {
function newGraphAdjList (line 22) | func newGraphAdjList(edges [][]Vertex) *graphAdjList {
FILE: codes/go/chapter_graph/graph_adjacency_list_test.go
function TestGraphAdjList (line 14) | func TestGraphAdjList(t *testing.T) {
FILE: codes/go/chapter_graph/graph_adjacency_matrix.go
type graphAdjMat (line 10) | type graphAdjMat struct
method size (line 39) | func (g *graphAdjMat) size() int {
method addVertex (line 44) | func (g *graphAdjMat) addVertex(val int) {
method removeVertex (line 58) | func (g *graphAdjMat) removeVertex(index int) {
method addEdge (line 74) | func (g *graphAdjMat) addEdge(i, j int) {
method removeEdge (line 86) | func (g *graphAdjMat) removeEdge(i, j int) {
method print (line 96) | func (g *graphAdjMat) print() {
function newGraphAdjMat (line 18) | func newGraphAdjMat(vertices []int, edges [][]int) *graphAdjMat {
FILE: codes/go/chapter_graph/graph_adjacency_matrix_test.go
function TestGraphAdjMat (line 12) | func TestGraphAdjMat(t *testing.T) {
FILE: codes/go/chapter_graph/graph_bfs.go
function graphBFS (line 13) | func graphBFS(g *graphAdjList, startVet Vertex) []Vertex {
FILE: codes/go/chapter_graph/graph_bfs_test.go
function TestGraphBFS (line 14) | func TestGraphBFS(t *testing.T) {
FILE: codes/go/chapter_graph/graph_dfs.go
function dfs (line 12) | func dfs(g *graphAdjList, visited map[Vertex]struct{}, res *[]Vertex, ve...
function graphDFS (line 28) | func graphDFS(g *graphAdjList, startVet Vertex) []Vertex {
FILE: codes/go/chapter_graph/graph_dfs_test.go
function TestGraphDFS (line 14) | func TestGraphDFS(t *testing.T) {
FILE: codes/go/chapter_greedy/coin_change_greedy.go
function coinChangeGreedy (line 8) | func coinChangeGreedy(coins []int, amt int) int {
FILE: codes/go/chapter_greedy/coin_change_greedy_test.go
function TestCoinChangeGreedy (line 12) | func TestCoinChangeGreedy(t *testing.T) {
FILE: codes/go/chapter_greedy/fractional_knapsack.go
type Item (line 10) | type Item struct
function fractionalKnapsack (line 16) | func fractionalKnapsack(wgt []int, val []int, cap int) float64 {
FILE: codes/go/chapter_greedy/fractional_knapsack_test.go
function TestFractionalKnapsack (line 12) | func TestFractionalKnapsack(t *testing.T) {
FILE: codes/go/chapter_greedy/max_capacity.go
function maxCapacity (line 10) | func maxCapacity(ht []int) int {
FILE: codes/go/chapter_greedy/max_capacity_test.go
function TestMaxCapacity (line 12) | func TestMaxCapacity(t *testing.T) {
FILE: codes/go/chapter_greedy/max_product_cutting.go
function maxProductCutting (line 10) | func maxProductCutting(n int) int {
FILE: codes/go/chapter_greedy/max_product_cutting_test.go
function TestMaxProductCutting (line 12) | func TestMaxProductCutting(t *testing.T) {
FILE: codes/go/chapter_hashing/array_hash_map.go
type pair (line 10) | type pair struct
type arrayHashMap (line 16) | type arrayHashMap struct
method hashFunc (line 28) | func (a *arrayHashMap) hashFunc(key int) int {
method get (line 34) | func (a *arrayHashMap) get(key int) string {
method put (line 44) | func (a *arrayHashMap) put(key int, val string) {
method remove (line 51) | func (a *arrayHashMap) remove(key int) {
method pairSet (line 58) | func (a *arrayHashMap) pairSet() []*pair {
method keySet (line 69) | func (a *arrayHashMap) keySet() []int {
method valueSet (line 80) | func (a *arrayHashMap) valueSet() []string {
method print (line 91) | func (a *arrayHashMap) print() {
function newArrayHashMap (line 21) | func newArrayHashMap() *arrayHashMap {
FILE: codes/go/chapter_hashing/array_hash_map_test.go
function TestArrayHashMap (line 12) | func TestArrayHashMap(t *testing.T) {
FILE: codes/go/chapter_hashing/hash_collision_test.go
function TestHashMapChaining (line 12) | func TestHashMapChaining(t *testing.T) {
function TestHashMapOpenAddressing (line 38) | func TestHashMapOpenAddressing(t *testing.T) {
FILE: codes/go/chapter_hashing/hash_map_chaining.go
type hashMapChaining (line 14) | type hashMapChaining struct
method hashFunc (line 38) | func (m *hashMapChaining) hashFunc(key int) int {
method loadFactor (line 43) | func (m *hashMapChaining) loadFactor() float64 {
method get (line 48) | func (m *hashMapChaining) get(key int) string {
method put (line 62) | func (m *hashMapChaining) put(key int, val string) {
method remove (line 85) | func (m *hashMapChaining) remove(key int) {
method extend (line 99) | func (m *hashMapChaining) extend() {
method print (line 122) | func (m *hashMapChaining) print() {
function newHashMapChaining (line 23) | func newHashMapChaining() *hashMapChaining {
FILE: codes/go/chapter_hashing/hash_map_open_addressing.go
type hashMapOpenAddressing (line 12) | type hashMapOpenAddressing struct
method hashFunc (line 34) | func (h *hashMapOpenAddressing) hashFunc(key int) int {
method loadFactor (line 39) | func (h *hashMapOpenAddressing) loadFactor() float64 {
method findBucket (line 44) | func (h *hashMapOpenAddressing) findBucket(key int) int {
method get (line 70) | func (h *hashMapOpenAddressing) get(key int) string {
method put (line 79) | func (h *hashMapOpenAddressing) put(key int, val string) {
method remove (line 93) | func (h *hashMapOpenAddressing) remove(key int) {
method extend (line 102) | func (h *hashMapOpenAddressing) extend() {
method print (line 116) | func (h *hashMapOpenAddressing) print() {
function newHashMapOpenAddressing (line 22) | func newHashMapOpenAddressing() *hashMapOpenAddressing {
FILE: codes/go/chapter_hashing/hash_map_test.go
function TestHashMap (line 15) | func TestHashMap(t *testing.T) {
function TestSimpleHash (line 58) | func TestSimpleHash(t *testing.T) {
FILE: codes/go/chapter_hashing/simple_hash.go
function addHash (line 10) | func addHash(key string) int {
function mulHash (line 22) | func mulHash(key string) int {
function xorHash (line 34) | func xorHash(key string) int {
function rotHash (line 46) | func rotHash(key string) int {
FILE: codes/go/chapter_heap/heap.go
type intHeap (line 9) | type intHeap
method Push (line 12) | func (h *intHeap) Push(x any) {
method Pop (line 19) | func (h *intHeap) Pop() any {
method Len (line 27) | func (h *intHeap) Len() int {
method Less (line 32) | func (h *intHeap) Less(i, j int) bool {
method Swap (line 38) | func (h *intHeap) Swap(i, j int) {
method Top (line 43) | func (h *intHeap) Top() any {
FILE: codes/go/chapter_heap/heap_test.go
function testPush (line 16) | func testPush(h *intHeap, val int) {
function testPop (line 23) | func testPop(h *intHeap) {
function TestHeap (line 30) | func TestHeap(t *testing.T) {
function TestMyHeap (line 62) | func TestMyHeap(t *testing.T) {
function TestTopKHeap (line 93) | func TestTopKHeap(t *testing.T) {
FILE: codes/go/chapter_heap/my_heap.go
type maxHeap (line 13) | type maxHeap struct
method left (line 37) | func (h *maxHeap) left(i int) int {
method right (line 42) | func (h *maxHeap) right(i int) int {
method parent (line 47) | func (h *maxHeap) parent(i int) int {
method swap (line 53) | func (h *maxHeap) swap(i, j int) {
method size (line 58) | func (h *maxHeap) size() int {
method isEmpty (line 63) | func (h *maxHeap) isEmpty() bool {
method peek (line 68) | func (h *maxHeap) peek() any {
method push (line 73) | func (h *maxHeap) push(val any) {
method siftUp (line 81) | func (h *maxHeap) siftUp(i int) {
method pop (line 97) | func (h *maxHeap) pop() any {
method siftDown (line 116) | func (h *maxHeap) siftDown(i int) {
method print (line 138) | func (h *maxHeap) print() {
function newHeap (line 19) | func newHeap() *maxHeap {
function newMaxHeap (line 26) | func newMaxHeap(nums []any) *maxHeap {
FILE: codes/go/chapter_heap/top_k.go
type minHeap (line 9) | type minHeap
method Len (line 11) | func (h *minHeap) Len() int { return len(*h) }
method Less (line 12) | func (h *minHeap) Less(i, j int) bool { return (*h)[i].(int) < (*h)[j]...
method Swap (line 13) | func (h *minHeap) Swap(i, j int) { (*h)[i], (*h)[j] = (*h)[j], (*...
method Push (line 16) | func (h *minHeap) Push(x any) {
method Pop (line 21) | func (h *minHeap) Pop() any {
method Top (line 29) | func (h *minHeap) Top() any {
function topKHeap (line 34) | func topKHeap(nums []int, k int) *minHeap {
FILE: codes/go/chapter_searching/binary_search.go
function binarySearch (line 8) | func binarySearch(nums []int, target int) int {
function binarySearchLCRO (line 27) | func binarySearchLCRO(nums []int, target int) int {
FILE: codes/go/chapter_searching/binary_search_edge.go
function binarySearchLeftEdge (line 8) | func binarySearchLeftEdge(nums []int, target int) int {
function binarySearchRightEdge (line 20) | func binarySearchRightEdge(nums []int, target int) int {
FILE: codes/go/chapter_searching/binary_search_insertion.go
function binarySearchInsertionSimple (line 8) | func binarySearchInsertionSimple(nums []int, target int) int {
function binarySearchInsertion (line 30) | func binarySearchInsertion(nums []int, target int) int {
FILE: codes/go/chapter_searching/binary_search_test.go
function TestBinarySearch (line 12) | func TestBinarySearch(t *testing.T) {
function TestBinarySearchEdge (line 26) | func TestBinarySearchEdge(t *testing.T) {
function TestBinarySearchInsertion (line 41) | func TestBinarySearchInsertion(t *testing.T) {
FILE: codes/go/chapter_searching/hashing_search.go
function hashingSearchArray (line 10) | func hashingSearchArray(m map[int]int, target int) int {
function hashingSearchLinkedList (line 21) | func hashingSearchLinkedList(m map[int]*ListNode, target int) *ListNode {
FILE: codes/go/chapter_searching/hashing_search_test.go
function TestHashingSearch (line 14) | func TestHashingSearch(t *testing.T) {
FILE: codes/go/chapter_searching/linear_search.go
function linearSearchArray (line 12) | func linearSearchArray(nums []int, target int) int {
function linearSearchLinkedList (line 25) | func linearSearchLinkedList(node *ListNode, target int) *ListNode {
FILE: codes/go/chapter_searching/linear_search_test.go
function TestLinearSearch (line 14) | func TestLinearSearch(t *testing.T) {
FILE: codes/go/chapter_searching/two_sum.go
function twoSumBruteForce (line 8) | func twoSumBruteForce(nums []int, target int) []int {
function twoSumHashTable (line 22) | func twoSumHashTable(nums []int, target int) []int {
FILE: codes/go/chapter_searching/two_sum_test.go
function TestTwoSum (line 12) | func TestTwoSum(t *testing.T) {
FILE: codes/go/chapter_sorting/bubble_sort.go
function bubbleSort (line 8) | func bubbleSort(nums []int) {
function bubbleSortWithFlag (line 22) | func bubbleSortWithFlag(nums []int) {
FILE: codes/go/chapter_sorting/bubble_sort_test.go
function TestBubbleSort (line 12) | func TestBubbleSort(t *testing.T) {
FILE: codes/go/chapter_sorting/bucket_sort.go
function bucketSort (line 10) | func bucketSort(nums []float64) {
FILE: codes/go/chapter_sorting/bucket_sort_test.go
function TestBucketSort (line 12) | func TestBucketSort(t *testing.T) {
FILE: codes/go/chapter_sorting/counting_sort.go
type CountingSort (line 7) | type CountingSort struct
function countingSortNaive (line 11) | func countingSortNaive(nums []int) {
function countingSort (line 36) | func countingSort(nums []int) {
FILE: codes/go/chapter_sorting/counting_sort_test.go
function TestCountingSort (line 12) | func TestCountingSort(t *testing.T) {
FILE: codes/go/chapter_sorting/heap_sort.go
function siftDown (line 8) | func siftDown(nums *[]int, n, i int) {
function heapSort (line 32) | func heapSort(nums *[]int) {
FILE: codes/go/chapter_sorting/heap_sort_test.go
function TestHeapSort (line 12) | func TestHeapSort(t *testing.T) {
FILE: codes/go/chapter_sorting/insertion_sort.go
function insertionSort (line 8) | func insertionSort(nums []int) {
FILE: codes/go/chapter_sorting/insertion_sort_test.go
function TestInsertionSort (line 12) | func TestInsertionSort(t *testing.T) {
FILE: codes/go/chapter_sorting/merge_sort.go
function merge (line 8) | func merge(nums []int, left, mid, right int) {
function mergeSort (line 43) | func mergeSort(nums []int, left, right int) {
FILE: codes/go/chapter_sorting/merge_sort_test.go
function TestMergeSort (line 12) | func TestMergeSort(t *testing.T) {
FILE: codes/go/chapter_sorting/quick_sort.go
type quickSort (line 8) | type quickSort struct
method partition (line 17) | func (q *quickSort) partition(nums []int, left, right int) int {
method quickSort (line 36) | func (q *quickSort) quickSort(nums []int, left, right int) {
type quickSortMedian (line 11) | type quickSortMedian struct
method medianThree (line 49) | func (q *quickSortMedian) medianThree(nums []int, left, mid, right int...
method partition (line 61) | func (q *quickSortMedian) partition(nums []int, left, right int) int {
method quickSort (line 84) | func (q *quickSortMedian) quickSort(nums []int, left, right int) {
type quickSortTailCall (line 14) | type quickSortTailCall struct
method partition (line 97) | func (q *quickSortTailCall) partition(nums []int, left, right int) int {
method quickSort (line 116) | func (q *quickSortTailCall) quickSort(nums []int, left, right int) {
FILE: codes/go/chapter_sorting/quick_sort_test.go
function TestQuickSort (line 13) | func TestQuickSort(t *testing.T) {
function TestQuickSortMedian (line 21) | func TestQuickSortMedian(t *testing.T) {
function TestQuickSortTailCall (line 29) | func TestQuickSortTailCall(t *testing.T) {
FILE: codes/go/chapter_sorting/radix_sort.go
function digit (line 10) | func digit(num, exp int) int {
function countingSortDigit (line 16) | func countingSortDigit(nums []int, exp int) {
function radixSort (line 44) | func radixSort(nums []int) {
FILE: codes/go/chapter_sorting/radix_sort_test.go
function TestRadixSort (line 12) | func TestRadixSort(t *testing.T) {
FILE: codes/go/chapter_sorting/selection_sort.go
function selectionSort (line 8) | func selectionSort(nums []int) {
FILE: codes/go/chapter_sorting/selection_sort_test.go
function TestSelectionSort (line 12) | func TestSelectionSort(t *testing.T) {
FILE: codes/go/chapter_stack_and_queue/array_deque.go
type arrayDeque (line 10) | type arrayDeque struct
method size (line 28) | func (q *arrayDeque) size() int {
method isEmpty (line 33) | func (q *arrayDeque) isEmpty() bool {
method index (line 38) | func (q *arrayDeque) index(i int) int {
method pushFirst (line 46) | func (q *arrayDeque) pushFirst(num int) {
method pushLast (line 60) | func (q *arrayDeque) pushLast(num int) {
method popFirst (line 73) | func (q *arrayDeque) popFirst() any {
method popLast (line 85) | func (q *arrayDeque) popLast() any {
method peekFirst (line 95) | func (q *arrayDeque) peekFirst() any {
method peekLast (line 103) | func (q *arrayDeque) peekLast() any {
method toSlice (line 113) | func (q *arrayDeque) toSlice() []int {
function newArrayDeque (line 18) | func newArrayDeque(queCapacity int) *arrayDeque {
FILE: codes/go/chapter_stack_and_queue/array_queue.go
type arrayQueue (line 8) | type arrayQueue struct
method size (line 26) | func (q *arrayQueue) size() int {
method isEmpty (line 31) | func (q *arrayQueue) isEmpty() bool {
method push (line 36) | func (q *arrayQueue) push(num int) {
method pop (line 50) | func (q *arrayQueue) pop() any {
method peek (line 63) | func (q *arrayQueue) peek() any {
method toSlice (line 71) | func (q *arrayQueue) toSlice() []int {
function newArrayQueue (line 16) | func newArrayQueue(queCapacity int) *arrayQueue {
FILE: codes/go/chapter_stack_and_queue/array_stack.go
type arrayStack (line 8) | type arrayStack struct
method size (line 21) | func (s *arrayStack) size() int {
method isEmpty (line 26) | func (s *arrayStack) isEmpty() bool {
method push (line 31) | func (s *arrayStack) push(v int) {
method pop (line 37) | func (s *arrayStack) pop() any {
method peek (line 44) | func (s *arrayStack) peek() any {
method toSlice (line 53) | func (s *arrayStack) toSlice() []int {
function newArrayStack (line 13) | func newArrayStack() *arrayStack {
FILE: codes/go/chapter_stack_and_queue/deque_test.go
function TestDeque (line 15) | func TestDeque(t *testing.T) {
function TestArrayDeque (line 52) | func TestArrayDeque(t *testing.T) {
function TestLinkedListDeque (line 95) | func TestLinkedListDeque(t *testing.T) {
function BenchmarkLinkedListDeque (line 132) | func BenchmarkLinkedListDeque(b *testing.B) {
FILE: codes/go/chapter_stack_and_queue/linkedlist_deque.go
type linkedListDeque (line 12) | type linkedListDeque struct
method pushFirst (line 25) | func (s *linkedListDeque) pushFirst(value any) {
method pushLast (line 30) | func (s *linkedListDeque) pushLast(value any) {
method popFirst (line 35) | func (s *linkedListDeque) popFirst() any {
method popLast (line 45) | func (s *linkedListDeque) popLast() any {
method peekFirst (line 55) | func (s *linkedListDeque) peekFirst() any {
method peekLast (line 64) | func (s *linkedListDeque) peekLast() any {
method size (line 73) | func (s *linkedListDeque) size() int {
method isEmpty (line 78) | func (s *linkedListDeque) isEmpty() bool {
method toList (line 83) | func (s *linkedListDeque) toList() *list.List {
function newLinkedListDeque (line 18) | func newLinkedListDeque() *linkedListDeque {
FILE: codes/go/chapter_stack_and_queue/linkedlist_queue.go
type linkedListQueue (line 12) | type linkedListQueue struct
method push (line 25) | func (s *linkedListQueue) push(value any) {
method pop (line 30) | func (s *linkedListQueue) pop() any {
method peek (line 40) | func (s *linkedListQueue) peek() any {
method size (line 49) | func (s *linkedListQueue) size() int {
method isEmpty (line 54) | func (s *linkedListQueue) isEmpty() bool {
method toList (line 59) | func (s *linkedListQueue) toList() *list.List {
function newLinkedListQueue (line 18) | func newLinkedListQueue() *linkedListQueue {
FILE: codes/go/chapter_stack_and_queue/linkedlist_stack.go
type linkedListStack (line 12) | type linkedListStack struct
method push (line 25) | func (s *linkedListStack) push(value int) {
method pop (line 30) | func (s *linkedListStack) pop() any {
method peek (line 40) | func (s *linkedListStack) peek() any {
method size (line 49) | func (s *linkedListStack) size() int {
method isEmpty (line 54) | func (s *linkedListStack) isEmpty() bool {
method toList (line 59) | func (s *linkedListStack) toList() *list.List {
function newLinkedListStack (line 18) | func newLinkedListStack() *linkedListStack {
FILE: codes/go/chapter_stack_and_queue/queue_test.go
function TestQueue (line 15) | func TestQueue(t *testing.T) {
function TestArrayQueue (line 48) | func TestArrayQueue(t *testing.T) {
function TestLinkedListQueue (line 92) | func TestLinkedListQueue(t *testing.T) {
function BenchmarkArrayQueue (line 124) | func BenchmarkArrayQueue(b *testing.B) {
function BenchmarkLinkedQueue (line 137) | func BenchmarkLinkedQueue(b *testing.B) {
FILE: codes/go/chapter_stack_and_queue/stack_test.go
function TestStack (line 14) | func TestStack(t *testing.T) {
function TestArrayStack (line 47) | func TestArrayStack(t *testing.T) {
function TestLinkedListStack (line 78) | func TestLinkedListStack(t *testing.T) {
function BenchmarkArrayStack (line 109) | func BenchmarkArrayStack(b *testing.B) {
function BenchmarkLinkedListStack (line 121) | func BenchmarkLinkedListStack(b *testing.B) {
FILE: codes/go/chapter_tree/array_binary_tree.go
type arrayBinaryTree (line 8) | type arrayBinaryTree struct
method size (line 20) | func (abt *arrayBinaryTree) size() int {
method val (line 25) | func (abt *arrayBinaryTree) val(i int) any {
method left (line 34) | func (abt *arrayBinaryTree) left(i int) int {
method right (line 39) | func (abt *arrayBinaryTree) right(i int) int {
method parent (line 44) | func (abt *arrayBinaryTree) parent(i int) int {
method levelOrder (line 49) | func (abt *arrayBinaryTree) levelOrder() []any {
method dfs (line 61) | func (abt *arrayBinaryTree) dfs(i int, order string, res *[]any) {
method preOrder (line 83) | func (abt *arrayBinaryTree) preOrder() []any {
method inOrder (line 90) | func (abt *arrayBinaryTree) inOrder() []any {
method postOrder (line 97) | func (abt *arrayBinaryTree) postOrder() []any {
function newArrayBinaryTree (line 13) | func newArrayBinaryTree(arr []any) *arrayBinaryTree {
FILE: codes/go/chapter_tree/array_binary_tree_test.go
function TestArrayBinaryTree (line 14) | func TestArrayBinaryTree(t *testing.T) {
FILE: codes/go/chapter_tree/avl_tree.go
type aVLTree (line 10) | type aVLTree struct
method height (line 20) | func (t *aVLTree) height(node *TreeNode) int {
method updateHeight (line 29) | func (t *aVLTree) updateHeight(node *TreeNode) {
method balanceFactor (line 41) | func (t *aVLTree) balanceFactor(node *TreeNode) int {
method rightRotate (line 51) | func (t *aVLTree) rightRotate(node *TreeNode) *TreeNode {
method leftRotate (line 65) | func (t *aVLTree) leftRotate(node *TreeNode) *TreeNode {
method rotate (line 79) | func (t *aVLTree) rotate(node *TreeNode) *TreeNode {
method insert (line 110) | func (t *aVLTree) insert(val int) {
method insertHelper (line 115) | func (t *aVLTree) insertHelper(node *TreeNode, val int) *TreeNode {
method remove (line 137) | func (t *aVLTree) remove(val int) {
method removeHelper (line 142) | func (t *aVLTree) removeHelper(node *TreeNode, val int) *TreeNode {
method search (line 183) | func (t *aVLTree) search(val int) *TreeNode {
function newAVLTree (line 15) | func newAVLTree() *aVLTree {
FILE: codes/go/chapter_tree/avl_tree_test.go
function TestAVLTree (line 14) | func TestAVLTree(t *testing.T) {
function testInsert (line 44) | func testInsert(tree *aVLTree, val int) {
function testRemove (line 50) | func testRemove(tree *aVLTree, val int) {
FILE: codes/go/chapter_tree/binary_search_tree.go
type binarySearchTree (line 11) | type binarySearchTree struct
method getRoot (line 23) | func (bst *binarySearchTree) getRoot() *TreeNode {
method search (line 28) | func (bst *binarySearchTree) search(num int) *TreeNode {
method insert (line 48) | func (bst *binarySearchTree) insert(num int) {
method remove (line 79) | func (bst *binarySearchTree) remove(num int) {
method print (line 140) | func (bst *binarySearchTree) print() {
function newBinarySearchTree (line 15) | func newBinarySearchTree() *binarySearchTree {
FILE: codes/go/chapter_tree/binary_search_tree_test.go
function TestBinarySearchTree (line 12) | func TestBinarySearchTree(t *testing.T) {
FILE: codes/go/chapter_tree/binary_tree_bfs.go
function levelOrder (line 14) | func levelOrder(root *TreeNode) []any {
FILE: codes/go/chapter_tree/binary_tree_bfs_test.go
function TestLevelOrder (line 14) | func TestLevelOrder(t *testing.T) {
FILE: codes/go/chapter_tree/binary_tree_dfs.go
function preOrder (line 14) | func preOrder(node *TreeNode) {
function inOrder (line 25) | func inOrder(node *TreeNode) {
function postOrder (line 36) | func postOrder(node *TreeNode) {
FILE: codes/go/chapter_tree/binary_tree_dfs_test.go
function TestPreInPostOrderTraversal (line 14) | func TestPreInPostOrderTraversal(t *testing.T) {
FILE: codes/go/chapter_tree/binary_tree_test.go
function TestBinaryTree (line 14) | func TestBinaryTree(t *testing.T) {
FILE: codes/go/pkg/list_node.go
type ListNode (line 8) | type ListNode struct
function NewListNode (line 14) | func NewListNode(v int) *ListNode {
function ArrayToLinkedList (line 22) | func ArrayToLinkedList(arr []int) *ListNode {
FILE: codes/go/pkg/list_node_test.go
function TestListNode (line 11) | func TestListNode(t *testing.T) {
FILE: codes/go/pkg/print_utils.go
function PrintSlice (line 15) | func PrintSlice[T any](nums []T) {
function PrintList (line 21) | func PrintList(list *list.List) {
function PrintMap (line 37) | func PrintMap[K comparable, V any](m map[K]V) {
function PrintHeap (line 44) | func PrintHeap(h []any) {
function PrintLinkedList (line 53) | func PrintLinkedList(node *ListNode) {
function PrintTree (line 67) | func PrintTree(root *TreeNode) {
function printTreeHelper (line 74) | func printTreeHelper(root *TreeNode, prev *trunk, isRight bool) {
type trunk (line 99) | type trunk struct
function newTrunk (line 104) | func newTrunk(prev *trunk, str string) *trunk {
function showTrunk (line 111) | func showTrunk(t *trunk) {
FILE: codes/go/pkg/tree_node.go
type TreeNode (line 8) | type TreeNode struct
function NewTreeNode (line 16) | func NewTreeNode(v any) *TreeNode {
function SliceToTreeDFS (line 45) | func SliceToTreeDFS(arr []any, i int) *TreeNode {
function SliceToTree (line 56) | func SliceToTree(arr []any) *TreeNode {
function TreeToSliceDFS (line 61) | func TreeToSliceDFS(root *TreeNode, i int, res *[]any) {
function TreeToSlice (line 74) | func TreeToSlice(root *TreeNode) []any {
FILE: codes/go/pkg/tree_node_test.go
function TestTreeNode (line 12) | func TestTreeNode(t *testing.T) {
FILE: codes/go/pkg/vertex.go
type Vertex (line 8) | type Vertex struct
function NewVertex (line 13) | func NewVertex(val int) Vertex {
function ValsToVets (line 20) | func ValsToVets(vals []int) []Vertex {
function VetsToVals (line 29) | func VetsToVals(vets []Vertex) []int {
function DeleteSliceElms (line 38) | func DeleteSliceElms[T any](a []T, elms ...T) []T {
FILE: codes/java/chapter_array_and_linkedlist/array.java
class array (line 12) | public class array {
method randomAccess (line 14) | static int randomAccess(int[] nums) {
method extend (line 23) | static int[] extend(int[] nums, int enlarge) {
method insert (line 35) | static void insert(int[] nums, int num, int index) {
method remove (line 45) | static void remove(int[] nums, int index) {
method traverse (line 53) | static void traverse(int[] nums) {
method find (line 66) | static int find(int[] nums, int target) {
method main (line 75) | public static void main(String[] args) {
FILE: codes/java/chapter_array_and_linkedlist/linked_list.java
class linked_list (line 11) | public class linked_list {
method insert (line 13) | static void insert(ListNode n0, ListNode P) {
method remove (line 20) | static void remove(ListNode n0) {
method access (line 30) | static ListNode access(ListNode head, int index) {
method find (line 40) | static int find(ListNode head, int target) {
method main (line 52) | public static void main(String[] args) {
FILE: codes/java/chapter_array_and_linkedlist/list.java
class list (line 11) | public class list {
method main (line 12) | public static void main(String[] args) {
FILE: codes/java/chapter_array_and_linkedlist/my_list.java
class MyList (line 12) | class MyList {
method MyList (line 19) | public MyList() {
method size (line 24) | public int size() {
method capacity (line 29) | public int capacity() {
method get (line 34) | public int get(int index) {
method set (line 42) | public void set(int index, int num) {
method add (line 49) | public void add(int num) {
method insert (line 59) | public void insert(int index, int num) {
method remove (line 75) | public int remove(int index) {
method extendCapacity (line 90) | public void extendCapacity() {
method toArray (line 98) | public int[] toArray() {
class my_list (line 109) | public class my_list {
method main (line 111) | public static void main(String[] args) {
FILE: codes/java/chapter_backtracking/n_queens.java
class n_queens (line 11) | public class n_queens {
method backtrack (line 13) | public static void backtrack(int row, int n, List<List<String>> state,...
method nQueens (line 44) | public static List<List<List<String>>> nQueens(int n) {
method main (line 64) | public static void main(String[] args) {
FILE: codes/java/chapter_backtracking/permutations_i.java
class permutations_i (line 11) | public class permutations_i {
method backtrack (line 13) | public static void backtrack(List<Integer> state, int[] choices, boole...
method permutationsI (line 37) | static List<List<Integer>> permutationsI(int[] nums) {
method main (line 43) | public static void main(String[] args) {
FILE: codes/java/chapter_backtracking/permutations_ii.java
class permutations_ii (line 11) | public class permutations_ii {
method backtrack (line 13) | static void backtrack(List<Integer> state, int[] choices, boolean[] se...
method permutationsII (line 39) | static List<List<Integer>> permutationsII(int[] nums) {
method main (line 45) | public static void main(String[] args) {
FILE: codes/java/chapter_backtracking/preorder_traversal_i_compact.java
class preorder_traversal_i_compact (line 12) | public class preorder_traversal_i_compact {
method preOrder (line 16) | static void preOrder(TreeNode root) {
method main (line 28) | public static void main(String[] args) {
FILE: codes/java/chapter_backtracking/preorder_traversal_ii_compact.java
class preorder_traversal_ii_compact (line 12) | public class preorder_traversal_ii_compact {
method preOrder (line 17) | static void preOrder(TreeNode root) {
method main (line 33) | public static void main(String[] args) {
FILE: codes/java/chapter_backtracking/preorder_traversal_iii_compact.java
class preorder_traversal_iii_compact (line 12) | public class preorder_traversal_iii_compact {
method preOrder (line 17) | static void preOrder(TreeNode root) {
method main (line 34) | public static void main(String[] args) {
FILE: codes/java/chapter_backtracking/preorder_traversal_iii_template.java
class preorder_traversal_iii_template (line 12) | public class preorder_traversal_iii_template {
method isSolution (line 14) | static boolean isSolution(List<TreeNode> state) {
method recordSolution (line 19) | static void recordSolution(List<TreeNode> state, List<List<TreeNode>> ...
method isValid (line 24) | static boolean isValid(List<TreeNode> state, TreeNode choice) {
method makeChoice (line 29) | static void makeChoice(List<TreeNode> state, TreeNode choice) {
method undoChoice (line 34) | static void undoChoice(List<TreeNode> state, TreeNode choice) {
method backtrack (line 39) | static void backtrack(List<TreeNode> state, List<TreeNode> choices, Li...
method main (line 59) | public static void main(String[] args) {
FILE: codes/java/chapter_backtracking/subset_sum_i.java
class subset_sum_i (line 11) | public class subset_sum_i {
method backtrack (line 13) | static void backtrack(List<Integer> state, int target, int[] choices, ...
method subsetSumI (line 37) | static List<List<Integer>> subsetSumI(int[] nums, int target) {
method main (line 46) | public static void main(String[] args) {
FILE: codes/java/chapter_backtracking/subset_sum_i_naive.java
class subset_sum_i_naive (line 11) | public class subset_sum_i_naive {
method backtrack (line 13) | static void backtrack(List<Integer> state, int target, int total, int[...
method subsetSumINaive (line 35) | static List<List<Integer>> subsetSumINaive(int[] nums, int target) {
method main (line 43) | public static void main(String[] args) {
FILE: codes/java/chapter_backtracking/subset_sum_ii.java
class subset_sum_ii (line 11) | public class subset_sum_ii {
method backtrack (line 13) | static void backtrack(List<Integer> state, int target, int[] choices, ...
method subsetSumII (line 42) | static List<List<Integer>> subsetSumII(int[] nums, int target) {
method main (line 51) | public static void main(String[] args) {
FILE: codes/java/chapter_computational_complexity/iteration.java
class iteration (line 9) | public class iteration {
method forLoop (line 11) | static int forLoop(int n) {
method whileLoop (line 21) | static int whileLoop(int n) {
method whileLoopII (line 33) | static int whileLoopII(int n) {
method nestedForLoop (line 47) | static String nestedForLoop(int n) {
method main (line 60) | public static void main(String[] args) {
FILE: codes/java/chapter_computational_complexity/recursion.java
class recursion (line 11) | public class recursion {
method recur (line 13) | static int recur(int n) {
method forLoopRecur (line 24) | static int forLoopRecur(int n) {
method tailRecur (line 43) | static int tailRecur(int n, int res) {
method fib (line 52) | static int fib(int n) {
method main (line 63) | public static void main(String[] args) {
FILE: codes/java/chapter_computational_complexity/space_complexity.java
class space_complexity (line 12) | public class space_complexity {
method function (line 14) | static int function() {
method constant (line 20) | static void constant(int n) {
method linear (line 37) | static void linear(int n) {
method linearRecur (line 53) | static void linearRecur(int n) {
method quadratic (line 61) | static void quadratic(int n) {
method quadraticRecur (line 76) | static int quadraticRecur(int n) {
method buildTree (line 86) | static TreeNode buildTree(int n) {
method main (line 96) | public static void main(String[] args) {
FILE: codes/java/chapter_computational_complexity/time_complexity.java
class time_complexity (line 9) | public class time_complexity {
method constant (line 11) | static int constant(int n) {
method linear (line 20) | static int linear(int n) {
method arrayTraversal (line 28) | static int arrayTraversal(int[] nums) {
method quadratic (line 38) | static int quadratic(int n) {
method bubbleSort (line 50) | static int bubbleSort(int[] nums) {
method exponential (line 69) | static int exponential(int n) {
method expRecur (line 83) | static int expRecur(int n) {
method logarithmic (line 90) | static int logarithmic(int n) {
method logRecur (line 100) | static int logRecur(int n) {
method linearLogRecur (line 107) | static int linearLogRecur(int n) {
method factorialRecur (line 118) | static int factorialRecur(int n) {
method main (line 130) | public static void main(String[] args) {
FILE: codes/java/chapter_computational_complexity/worst_best_time_complexity.java
class worst_best_time_complexity (line 11) | public class worst_best_time_complexity {
method randomNumbers (line 13) | static int[] randomNumbers(int n) {
method findOne (line 30) | static int findOne(int[] nums) {
method main (line 41) | public static void main(String[] args) {
FILE: codes/java/chapter_divide_and_conquer/binary_search_recur.java
class binary_search_recur (line 9) | public class binary_search_recur {
method dfs (line 11) | static int dfs(int[] nums, int target, int i, int j) {
method binarySearch (line 31) | static int binarySearch(int[] nums, int target) {
method main (line 37) | public static void main(String[] args) {
FILE: codes/java/chapter_divide_and_conquer/build_tree.java
class build_tree (line 12) | public class build_tree {
method dfs (line 14) | static TreeNode dfs(int[] preorder, Map<Integer, Integer> inorderMap, ...
method buildTree (line 31) | static TreeNode buildTree(int[] preorder, int[] inorder) {
method main (line 41) | public static void main(String[] args) {
FILE: codes/java/chapter_divide_and_conquer/hanota.java
class hanota (line 11) | public class hanota {
method move (line 13) | static void move(List<Integer> src, List<Integer> tar) {
method dfs (line 21) | static void dfs(int i, List<Integer> src, List<Integer> buf, List<Inte...
method solveHanota (line 36) | static void solveHanota(List<Integer> A, List<Integer> B, List<Integer...
method main (line 42) | public static void main(String[] args) {
FILE: codes/java/chapter_dynamic_programming/climbing_stairs_backtrack.java
class climbing_stairs_backtrack (line 11) | public class climbing_stairs_backtrack {
method backtrack (line 13) | public static void backtrack(List<Integer> choices, int state, int n, ...
method climbingStairsBacktrack (line 29) | public static int climbingStairsBacktrack(int n) {
method main (line 38) | public static void main(String[] args) {
FILE: codes/java/chapter_dynamic_programming/climbing_stairs_constraint_dp.java
class climbing_stairs_constraint_dp (line 9) | public class climbing_stairs_constraint_dp {
method climbingStairsConstraintDP (line 11) | static int climbingStairsConstraintDP(int n) {
method main (line 30) | public static void main(String[] args) {
FILE: codes/java/chapter_dynamic_programming/climbing_stairs_dfs.java
class climbing_stairs_dfs (line 9) | public class climbing_stairs_dfs {
method dfs (line 11) | public static int dfs(int i) {
method climbingStairsDFS (line 21) | public static int climbingStairsDFS(int n) {
method main (line 25) | public static void main(String[] args) {
FILE: codes/java/chapter_dynamic_programming/climbing_stairs_dfs_mem.java
class climbing_stairs_dfs_mem (line 11) | public class climbing_stairs_dfs_mem {
method dfs (line 13) | public static int dfs(int i, int[] mem) {
method climbingStairsDFSMem (line 28) | public static int climbingStairsDFSMem(int n) {
method main (line 35) | public static void main(String[] args) {
FILE: codes/java/chapter_dynamic_programming/climbing_stairs_dp.java
class climbing_stairs_dp (line 9) | public class climbing_stairs_dp {
method climbingStairsDP (line 11) | public static int climbingStairsDP(int n) {
method climbingStairsDPComp (line 27) | public static int climbingStairsDPComp(int n) {
method main (line 39) | public static void main(String[] args) {
FILE: codes/java/chapter_dynamic_programming/coin_change.java
class coin_change (line 11) | public class coin_change {
method coinChangeDP (line 13) | static int coinChangeDP(int[] coins, int amt) {
method coinChangeDPComp (line 38) | static int coinChangeDPComp(int[] coins, int amt) {
method main (line 60) | public static void main(String[] args) {
FILE: codes/java/chapter_dynamic_programming/coin_change_ii.java
class coin_change_ii (line 9) | public class coin_change_ii {
method coinChangeIIDP (line 11) | static int coinChangeIIDP(int[] coins, int amt) {
method coinChangeIIDPComp (line 35) | static int coinChangeIIDPComp(int[] coins, int amt) {
method main (line 55) | public static void main(String[] args) {
FILE: codes/java/chapter_dynamic_programming/edit_distance.java
class edit_distance (line 11) | public class edit_distance {
method editDistanceDFS (line 13) | static int editDistanceDFS(String s, String t, int i, int j) {
method editDistanceDFSMem (line 35) | static int editDistanceDFSMem(String s, String t, int[][] mem, int i, ...
method editDistanceDP (line 61) | static int editDistanceDP(String s, String t) {
method editDistanceDPComp (line 87) | static int editDistanceDPComp(String s, String t) {
method main (line 115) | public static void main(String[] args) {
FILE: codes/java/chapter_dynamic_programming/knapsack.java
class knapsack (line 11) | public class knapsack {
method knapsackDFS (line 14) | static int knapsackDFS(int[] wgt, int[] val, int i, int c) {
method knapsackDFSMem (line 31) | static int knapsackDFSMem(int[] wgt, int[] val, int[][] mem, int i, in...
method knapsackDP (line 53) | static int knapsackDP(int[] wgt, int[] val, int cap) {
method knapsackDPComp (line 73) | static int knapsackDPComp(int[] wgt, int[] val, int cap) {
method main (line 90) | public static void main(String[] args) {
FILE: codes/java/chapter_dynamic_programming/min_cost_climbing_stairs_dp.java
class min_cost_climbing_stairs_dp (line 11) | public class min_cost_climbing_stairs_dp {
method minCostClimbingStairsDP (line 13) | public static int minCostClimbingStairsDP(int[] cost) {
method minCostClimbingStairsDPComp (line 30) | public static int minCostClimbingStairsDPComp(int[] cost) {
method main (line 43) | public static void main(String[] args) {
FILE: codes/java/chapter_dynamic_programming/min_path_sum.java
class min_path_sum (line 11) | public class min_path_sum {
method minPathSumDFS (line 13) | static int minPathSumDFS(int[][] grid, int i, int j) {
method minPathSumDFSMem (line 30) | static int minPathSumDFSMem(int[][] grid, int[][] mem, int i, int j) {
method minPathSumDP (line 52) | static int minPathSumDP(int[][] grid) {
method minPathSumDPComp (line 75) | static int minPathSumDPComp(int[][] grid) {
method main (line 96) | public static void main(String[] args) {
FILE: codes/java/chapter_dynamic_programming/unbounded_knapsack.java
class unbounded_knapsack (line 9) | public class unbounded_knapsack {
method unboundedKnapsackDP (line 11) | static int unboundedKnapsackDP(int[] wgt, int[] val, int cap) {
method unboundedKnapsackDPComp (line 31) | static int unboundedKnapsackDPComp(int[] wgt, int[] val, int cap) {
method main (line 50) | public static void main(String[] args) {
FILE: codes/java/chapter_graph/graph_adjacency_list.java
class GraphAdjList (line 13) | class GraphAdjList {
method GraphAdjList (line 18) | public GraphAdjList(Vertex[][] edges) {
method size (line 29) | public int size() {
method addEdge (line 34) | public void addEdge(Vertex vet1, Vertex vet2) {
method removeEdge (line 43) | public void removeEdge(Vertex vet1, Vertex vet2) {
method addVertex (line 52) | public void addVertex(Vertex vet) {
method removeVertex (line 60) | public void removeVertex(Vertex vet) {
method print (line 72) | public void print() {
class graph_adjacency_list (line 83) | public class graph_adjacency_list {
method main (line 84) | public static void main(String[] args) {
FILE: codes/java/chapter_graph/graph_adjacency_matrix.java
class GraphAdjMat (line 13) | class GraphAdjMat {
method GraphAdjMat (line 18) | public GraphAdjMat(int[] vertices, int[][] edges) {
method size (line 33) | public int size() {
method addVertex (line 38) | public void addVertex(int val) {
method removeVertex (line 55) | public void removeVertex(int index) {
method addEdge (line 70) | public void addEdge(int i, int j) {
method removeEdge (line 81) | public void removeEdge(int i, int j) {
method print (line 90) | public void print() {
class graph_adjacency_matrix (line 98) | public class graph_adjacency_matrix {
method main (line 99) | public static void main(String[] args) {
FILE: codes/java/chapter_graph/graph_bfs.java
class graph_bfs (line 12) | public class graph_bfs {
method graphBFS (line 15) | static List<Vertex> graphBFS(GraphAdjList graph, Vertex startVet) {
method main (line 40) | public static void main(String[] args) {
FILE: codes/java/chapter_graph/graph_dfs.java
class graph_dfs (line 12) | public class graph_dfs {
method dfs (line 14) | static void dfs(GraphAdjList graph, Set<Vertex> visited, List<Vertex> ...
method graphDFS (line 28) | static List<Vertex> graphDFS(GraphAdjList graph, Vertex startVet) {
method main (line 37) | public static void main(String[] args) {
FILE: codes/java/chapter_greedy/coin_change_greedy.java
class coin_change_greedy (line 11) | public class coin_change_greedy {
method coinChangeGreedy (line 13) | static int coinChangeGreedy(int[] coins, int amt) {
method main (line 31) | public static void main(String[] args) {
FILE: codes/java/chapter_greedy/fractional_knapsack.java
class Item (line 13) | class Item {
method Item (line 17) | public Item(int w, int v) {
class fractional_knapsack (line 23) | public class fractional_knapsack {
method fractionalKnapsack (line 25) | static double fractionalKnapsack(int[] wgt, int[] val, int cap) {
method main (line 50) | public static void main(String[] args) {
FILE: codes/java/chapter_greedy/max_capacity.java
class max_capacity (line 9) | public class max_capacity {
method maxCapacity (line 11) | static int maxCapacity(int[] ht) {
method main (line 31) | public static void main(String[] args) {
FILE: codes/java/chapter_greedy/max_product_cutting.java
class max_product_cutting (line 11) | public class max_product_cutting {
method maxProductCutting (line 13) | public static int maxProductCutting(int n) {
method main (line 33) | public static void main(String[] args) {
FILE: codes/java/chapter_hashing/array_hash_map.java
class Pair (line 12) | class Pair {
method Pair (line 16) | public Pair(int key, String val) {
class ArrayHashMap (line 23) | class ArrayHashMap {
method ArrayHashMap (line 26) | public ArrayHashMap() {
method hashFunc (line 35) | private int hashFunc(int key) {
method get (line 41) | public String get(int key) {
method put (line 50) | public void put(int key, String val) {
method remove (line 57) | public void remove(int key) {
method pairSet (line 64) | public List<Pair> pairSet() {
method keySet (line 74) | public List<Integer> keySet() {
method valueSet (line 84) | public List<String> valueSet() {
method print (line 94) | public void print() {
class array_hash_map (line 101) | public class array_hash_map {
method main (line 102) | public static void main(String[] args) {
FILE: codes/java/chapter_hashing/built_in_hash.java
class built_in_hash (line 12) | public class built_in_hash {
method main (line 13) | public static void main(String[] args) {
FILE: codes/java/chapter_hashing/hash_map.java
class hash_map (line 12) | public class hash_map {
method main (line 13) | public static void main(String[] args) {
FILE: codes/java/chapter_hashing/hash_map_chaining.java
class HashMapChaining (line 13) | class HashMapChaining {
method HashMapChaining (line 21) | public HashMapChaining() {
method hashFunc (line 33) | int hashFunc(int key) {
method loadFactor (line 38) | double loadFactor() {
method get (line 43) | String get(int key) {
method put (line 57) | void put(int key, String val) {
method remove (line 78) | void remove(int key) {
method extend (line 92) | void extend() {
method print (line 111) | void print() {
class hash_map_chaining (line 122) | public class hash_map_chaining {
method main (line 123) | public static void main(String[] args) {
FILE: codes/java/chapter_hashing/hash_map_open_addressing.java
class HashMapOpenAddressing (line 10) | class HashMapOpenAddressing {
method HashMapOpenAddressing (line 19) | public HashMapOpenAddressing() {
method hashFunc (line 25) | private int hashFunc(int key) {
method loadFactor (line 30) | private double loadFactor() {
method findBucket (line 35) | private int findBucket(int key) {
method get (line 62) | public String get(int key) {
method put (line 74) | public void put(int key, String val) {
method remove (line 92) | public void remove(int key) {
method extend (line 103) | private void extend() {
method print (line 119) | public void print() {
class hash_map_open_addressing (line 132) | public class hash_map_open_addressing {
method main (line 133) | public static void main(String[] args) {
FILE: codes/java/chapter_hashing/simple_hash.java
class simple_hash (line 9) | public class simple_hash {
method addHash (line 11) | static int addHash(String key) {
method mulHash (line 21) | static int mulHash(String key) {
method xorHash (line 31) | static int xorHash(String key) {
method rotHash (line 41) | static int rotHash(String key) {
method main (line 50) | public static void main(String[] args) {
FILE: codes/java/chapter_heap/heap.java
class heap (line 12) | public class heap {
method testPush (line 13) | public static void testPush(Queue<Integer> heap, int val) {
method testPop (line 19) | public static void testPop(Queue<Integer> heap) {
method main (line 25) | public static void main(String[] args) {
FILE: codes/java/chapter_heap/my_heap.java
class MaxHeap (line 13) | class MaxHeap {
method MaxHeap (line 18) | public MaxHeap(List<Integer> nums) {
method left (line 28) | private int left(int i) {
method right (line 33) | private int right(int i) {
method parent (line 38) | private int parent(int i) {
method swap (line 43) | private void swap(int i, int j) {
method size (line 50) | public int size() {
method isEmpty (line 55) | public boolean isEmpty() {
method peek (line 60) | public int peek() {
method push (line 65) | public void push(int val) {
method siftUp (line 73) | private void siftUp(int i) {
method pop (line 88) | public int pop() {
method siftDown (line 103) | private void siftDown(int i) {
method print (line 122) | public void print() {
class my_heap (line 129) | public class my_heap {
method main (line 130) | public static void main(String[] args) {
FILE: codes/java/chapter_heap/top_k.java
class top_k (line 12) | public class top_k {
method topKHeap (line 14) | static Queue<Integer> topKHeap(int[] nums, int k) {
method main (line 32) | public static void main(String[] args) {
FILE: codes/java/chapter_searching/binary_search.java
class binary_search (line 9) | public class binary_search {
method binarySearch (line 11) | static int binarySearch(int[] nums, int target) {
method binarySearchLCRO (line 29) | static int binarySearchLCRO(int[] nums, int target) {
method main (line 46) | public static void main(String[] args) {
FILE: codes/java/chapter_searching/binary_search_edge.java
class binary_search_edge (line 9) | public class binary_search_edge {
method binarySearchLeftEdge (line 11) | static int binarySearchLeftEdge(int[] nums, int target) {
method binarySearchRightEdge (line 23) | static int binarySearchRightEdge(int[] nums, int target) {
method main (line 36) | public static void main(String[] args) {
FILE: codes/java/chapter_searching/binary_search_insertion.java
class binary_search_insertion (line 9) | class binary_search_insertion {
method binarySearchInsertionSimple (line 11) | static int binarySearchInsertionSimple(int[] nums,
Copy disabled (too large)
Download .json
Condensed preview — 7125 files, each showing path, character count, and a content snippet. Download the .json file for the full structured content (20,933K chars).
[
{
"path": ".gitattributes",
"chars": 508,
"preview": "*.py linguist-language=Python\n*.cpp linguist-language=C++\n*.hpp linguist-language=C++\n*.java linguist-language=Java\n*.go"
},
{
"path": ".github/pull_request_template.md",
"chars": 978,
"preview": "If this pull request (PR) pertains to **Chinese-to-English translation**, please confirm that you have read the contribu"
},
{
"path": ".github/workflows/c.yml",
"chars": 3369,
"preview": "# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if y"
},
{
"path": ".github/workflows/cpp.yml",
"chars": 3407,
"preview": "# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if y"
},
{
"path": ".github/workflows/dart.yml",
"chars": 1044,
"preview": "# This workflow will install Dart SDK, run format, analyze and build with Dart\n\nname: Dart\n\non:\n push:\n branches: [\""
},
{
"path": ".github/workflows/dotnet.yml",
"chars": 1261,
"preview": "# This workflow will build a .NET project\r\n# For more information see: https://docs.github.com/en/actions/automating-bui"
},
{
"path": ".github/workflows/go.yml",
"chars": 974,
"preview": "name: Go\n\non:\n push:\n branches: [\"main\"]\n paths:\n - \"codes/go/**/*.go\"\n - \"en/codes/go/**/*.go\"\n pull_"
},
{
"path": ".github/workflows/java.yml",
"chars": 861,
"preview": "# # This workflow will install OpenJDK and build the Java project\n# For more information see: https://github.com/actions"
},
{
"path": ".github/workflows/javascript.yml",
"chars": 773,
"preview": "name: JavaScript\n\non:\n push:\n branches: [\"main\"]\n paths:\n - \"codes/javascript/**/*.js\"\n - \"en/codes/jav"
},
{
"path": ".github/workflows/kotlin.yml",
"chars": 653,
"preview": "name: Kotlin\n\non:\n push:\n branches: [\"main\"]\n paths:\n - \"codes/kotlin/**/*.kt\"\n - \"en/codes/kotlin/**/*"
},
{
"path": ".github/workflows/python.yml",
"chars": 1299,
"preview": "# This workflow will install Python dependencies, run tests and lint with Python\n# For more information see: https://doc"
},
{
"path": ".github/workflows/ruby.yml",
"chars": 1194,
"preview": "# This workflow uses actions that are not certified by GitHub.\n# They are provided by a third-party and are governed by "
},
{
"path": ".github/workflows/rust.yml",
"chars": 856,
"preview": "name: Rust\n\non:\n push:\n branches: [\"main\"]\n paths:\n - \"codes/rust/**/*.rs\"\n - \"codes/rust/Cargo.toml\"\n "
},
{
"path": ".github/workflows/swift.yml",
"chars": 761,
"preview": "# This workflow will build a Swift project\n# For more information see: https://docs.github.com/en/actions/automating-bui"
},
{
"path": ".github/workflows/typescript.yml",
"chars": 780,
"preview": "name: TypeScript\n\non:\n push:\n branches: [\"main\"]\n paths:\n - \"codes/typescript/**/*.ts\"\n - \"en/codes/typ"
},
{
"path": ".gitignore",
"chars": 63,
"preview": ".DS_Store\n\n.vscode/\n/node_modules\n\n# build\n/build\n/site\n/utils\n"
},
{
"path": "Dockerfile",
"chars": 963,
"preview": "FROM python:3.10.0-alpine\n\n# Official PyPI is preferred when reachable.\nENV PIP_INDEX_URL=https://pypi.org/simple\n\n# Use"
},
{
"path": "LICENSE",
"chars": 20845,
"preview": "Attribution-NonCommercial-ShareAlike 4.0 International\n\n================================================================"
},
{
"path": "README.md",
"chars": 4142,
"preview": "<p align=\"center\">\n <a href=\"https://www.hello-algo.com/\">\n <img src=\"https://www.hello-algo.com/index.assets/hello_"
},
{
"path": "codes/Dockerfile",
"chars": 1242,
"preview": "FROM ubuntu:latest\n\n# Use Ubuntu image from Aliyun\nRUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sourc"
},
{
"path": "codes/c/.gitignore",
"chars": 91,
"preview": "# Ignore all\n*\n# Unignore all with extensions\n!*.*\n# Unignore all dirs\n!*/\n*.dSYM/\n\nbuild/\n"
},
{
"path": "codes/c/CMakeLists.txt",
"chars": 619,
"preview": "cmake_minimum_required(VERSION 3.10)\nproject(hello_algo C)\n\nset(CMAKE_C_STANDARD 11)\n\ninclude_directories(./include)\n\nad"
},
{
"path": "codes/c/chapter_array_and_linkedlist/CMakeLists.txt",
"chars": 105,
"preview": "add_executable(array array.c)\nadd_executable(linked_list linked_list.c)\nadd_executable(my_list my_list.c)"
},
{
"path": "codes/c/chapter_array_and_linkedlist/array.c",
"chars": 2508,
"preview": "/**\r\n * File: array.c\r\n * Created Time: 2022-12-20\r\n * Author: MolDuM (moldum@163.com)\r\n */\r\n\r\n#include \"../utils/common"
},
{
"path": "codes/c/chapter_array_and_linkedlist/linked_list.c",
"chars": 1775,
"preview": "/**\n * File: linked_list.c\n * Created Time: 2023-01-12\n * Author: Zero (glj0@outlook.com)\n */\n\n#include \"../utils/common"
},
{
"path": "codes/c/chapter_array_and_linkedlist/my_list.c",
"chars": 3431,
"preview": "/**\n * File: my_list.c\n * Created Time: 2023-01-12\n * Author: Zero (glj0@outlook.com)\n */\n\n#include \"../utils/common.h\"\n"
},
{
"path": "codes/c/chapter_backtracking/CMakeLists.txt",
"chars": 595,
"preview": "add_executable(permutations_i permutations_i.c)\nadd_executable(permutations_ii permutations_ii.c)\nadd_executable(preorde"
},
{
"path": "codes/c/chapter_backtracking/n_queens.c",
"chars": 2705,
"preview": "/**\n * File : n_queens.c\n * Created Time: 2023-09-25\n * Author : lucas (superrat6@gmail.com)\n */\n\n#include \"../utils/com"
},
{
"path": "codes/c/chapter_backtracking/permutations_i.c",
"chars": 2003,
"preview": "/**\n * File: permutations_i.c\n * Created Time: 2023-06-04\n * Author: Gonglja (glj0@outlook.com), krahets (krahets@163.co"
},
{
"path": "codes/c/chapter_backtracking/permutations_ii.c",
"chars": 2121,
"preview": "/**\n * File: permutations_ii.c\n * Created Time: 2023-10-17\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/"
},
{
"path": "codes/c/chapter_backtracking/preorder_traversal_i_compact.c",
"chars": 932,
"preview": "/**\n * File: preorder_traversal_i_compact.c\n * Created Time: 2023-05-10\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#incl"
},
{
"path": "codes/c/chapter_backtracking/preorder_traversal_ii_compact.c",
"chars": 1270,
"preview": "/**\n * File: preorder_traversal_ii_compact.c\n * Created Time: 2023-05-28\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#inc"
},
{
"path": "codes/c/chapter_backtracking/preorder_traversal_iii_compact.c",
"chars": 1316,
"preview": "/**\n * File: preorder_traversal_iii_compact.c\n * Created Time: 2023-06-04\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#in"
},
{
"path": "codes/c/chapter_backtracking/preorder_traversal_iii_template.c",
"chars": 1986,
"preview": "/**\n * File: preorder_traversal_iii_template.c\n * Created Time: 2023-06-04\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#i"
},
{
"path": "codes/c/chapter_backtracking/subset_sum_i.c",
"chars": 1847,
"preview": "/**\n * File: subset_sum_i.c\n * Created Time: 2023-07-29\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#include \"../utils/co"
},
{
"path": "codes/c/chapter_backtracking/subset_sum_i_naive.c",
"chars": 1602,
"preview": "/**\n * File: subset_sum_i_naive.c\n * Created Time: 2023-07-28\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#include \"../ut"
},
{
"path": "codes/c/chapter_backtracking/subset_sum_ii.c",
"chars": 1939,
"preview": "/**\n * File: subset_sum_ii.c\n * Created Time: 2023-07-29\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#include \"../utils/c"
},
{
"path": "codes/c/chapter_computational_complexity/CMakeLists.txt",
"chars": 250,
"preview": "add_executable(iteration iteration.c)\nadd_executable(recursion recursion.c)\nadd_executable(time_complexity time_complexi"
},
{
"path": "codes/c/chapter_computational_complexity/iteration.c",
"chars": 1642,
"preview": "/**\n * File: iteration.c\n * Created Time: 2023-09-09\n * Author: Gonglja (glj0@outlook.com), MwumLi (mwumli@hotmail.com)\n"
},
{
"path": "codes/c/chapter_computational_complexity/recursion.c",
"chars": 1368,
"preview": "/**\n * File: recursion.c\n * Created Time: 2023-09-09\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#include \"../utils/commo"
},
{
"path": "codes/c/chapter_computational_complexity/space_complexity.c",
"chars": 2627,
"preview": "/**\n * File: space_complexity.c\n * Created Time: 2023-04-15\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#include \"../util"
},
{
"path": "codes/c/chapter_computational_complexity/time_complexity.c",
"chars": 3673,
"preview": "/**\n * File: time_complexity.c\n * Created Time: 2023-01-03\n * Author: codingonion (coderonion@gmail.com)\n */\n\n#include \""
},
{
"path": "codes/c/chapter_computational_complexity/worst_best_time_complexity.c",
"chars": 1340,
"preview": "/**\n * File: worst_best_time_complexity.c\n * Created Time: 2023-01-03\n * Author: codingonion (coderonion@gmail.com)\n */\n"
},
{
"path": "codes/c/chapter_divide_and_conquer/CMakeLists.txt",
"chars": 130,
"preview": "add_executable(binary_search_recur binary_search_recur.c)\nadd_executable(build_tree build_tree.c)\nadd_executable(hanota "
},
{
"path": "codes/c/chapter_divide_and_conquer/binary_search_recur.c",
"chars": 1027,
"preview": "/**\n * File: binary_search_recur.c\n * Created Time: 2023-10-01\n * Author: Zuoxun (845242523@qq.com)\n */\n\n#include \"../ut"
},
{
"path": "codes/c/chapter_divide_and_conquer/build_tree.c",
"chars": 1667,
"preview": "/**\n * File : build_tree.c\n * Created Time: 2023-10-16\n * Author : lucas (superrat6@gmail.com)\n */\n\n#include \"../utils/c"
},
{
"path": "codes/c/chapter_divide_and_conquer/hanota.c",
"chars": 1729,
"preview": "/**\n * File: hanota.c\n * Created Time: 2023-10-01\n * Author: Zuoxun (845242523@qq.com), lucas(superrat6@gmail.com)\n */\n\n"
},
{
"path": "codes/c/chapter_dynamic_programming/CMakeLists.txt",
"chars": 424,
"preview": "add_executable(climbing_stairs_constraint_dp climbing_stairs_constraint_dp.c)\nadd_executable(min_cost_climbing_stairs_dp"
},
{
"path": "codes/c/chapter_dynamic_programming/climbing_stairs_backtrack.c",
"chars": 1115,
"preview": "/**\r\n * File: climbing_stairs_backtrack.c\r\n * Created Time: 2023-09-22\r\n * Author: huawuque404 (huawuque404@163.com)\r\n *"
},
{
"path": "codes/c/chapter_dynamic_programming/climbing_stairs_constraint_dp.c",
"chars": 948,
"preview": "/**\n * File: climbing_stairs_constraint_dp.c\n * Created Time: 2023-10-02\n * Author: Zuoxun (845242523@qq.com)\n */\n\n#incl"
},
{
"path": "codes/c/chapter_dynamic_programming/climbing_stairs_dfs.c",
"chars": 576,
"preview": "/**\r\n * File: climbing_stairs_dfs.c\r\n * Created Time: 2023-09-19\r\n * Author: huawuque404 (huawuque404@163.com)\r\n */\r\n\r\n#"
},
{
"path": "codes/c/chapter_dynamic_programming/climbing_stairs_dfs_mem.c",
"chars": 930,
"preview": "/**\r\n * File: climbing_stairs_dfs_mem.c\r\n * Created Time: 2023-09-19\r\n * Author: huawuque404 (huawuque404@163.com)\r\n */\r"
},
{
"path": "codes/c/chapter_dynamic_programming/climbing_stairs_dp.c",
"chars": 1035,
"preview": "/**\r\n * File: climbing_stairs_dp.c\r\n * Created Time: 2023-09-19\r\n * Author: huawuque404 (huawuque404@163.com)\r\n */\r\n\r\n#i"
},
{
"path": "codes/c/chapter_dynamic_programming/coin_change.c",
"chars": 2147,
"preview": "/**\n * File: coin_change.c\n * Created Time: 2023-10-02\n * Author: Zuoxun (845242523@qq.com)\n */\n\n#include \"../utils/comm"
},
{
"path": "codes/c/chapter_dynamic_programming/coin_change_ii.c",
"chars": 1894,
"preview": "/**\n * File: coin_change_ii.c\n * Created Time: 2023-10-02\n * Author: Zuoxun (845242523@qq.com)\n */\n\n#include \"../utils/c"
},
{
"path": "codes/c/chapter_dynamic_programming/edit_distance.c",
"chars": 4180,
"preview": "/**\n * File: edit_distance.c\n * Created Time: 2023-10-02\n * Author: Zuoxun (845242523@qq.com)\n */\n\n#include \"../utils/co"
},
{
"path": "codes/c/chapter_dynamic_programming/knapsack.c",
"chars": 3472,
"preview": "/**\n * File: knapsack.c\n * Created Time: 2023-10-02\n * Author: Zuoxun (845242523@qq.com)\n */\n\n#include \"../utils/common."
},
{
"path": "codes/c/chapter_dynamic_programming/min_cost_climbing_stairs_dp.c",
"chars": 1407,
"preview": "/**\n * File: min_cost_climbing_stairs_dp.c\n * Created Time: 2023-10-02\n * Author: Zuoxun (845242523@qq.com)\n */\n\n#includ"
},
{
"path": "codes/c/chapter_dynamic_programming/min_path_sum.c",
"chars": 3344,
"preview": "/**\n * File: min_path_sum.c\n * Created Time: 2023-10-02\n * Author: Zuoxun (845242523@qq.com)\n */\n\n#include \"../utils/com"
},
{
"path": "codes/c/chapter_dynamic_programming/unbounded_knapsack.c",
"chars": 1942,
"preview": "/**\n * File: unbounded_knapsack.c\n * Created Time: 2023-10-02\n * Author: Zuoxun (845242523@qq.com)\n */\n\n#include \"../uti"
},
{
"path": "codes/c/chapter_graph/CMakeLists.txt",
"chars": 210,
"preview": "add_executable(graph_adjacency_matrix graph_adjacency_matrix.c)\nadd_executable(graph_adjacency_list_test graph_adjacency"
},
{
"path": "codes/c/chapter_graph/graph_adjacency_list.c",
"chars": 4251,
"preview": "/**\n * File: graph_adjacency_list.c\n * Created Time: 2023-07-07\n * Author: NI-SW (947743645@qq.com)\n */\n\n#include \"../ut"
},
{
"path": "codes/c/chapter_graph/graph_adjacency_list_test.c",
"chars": 1326,
"preview": "/**\n * File: graph_adjacency_list_test.c\n * Created Time: 2023-07-11\n * Author: NI-SW (947743645@qq.com)\n */\n\n#include \""
},
{
"path": "codes/c/chapter_graph/graph_adjacency_matrix.c",
"chars": 3555,
"preview": "/**\n * File: graph_adjacency_matrix.c\n * Created Time: 2023-07-06\n * Author: NI-SW (947743645@qq.com)\n */\n\n#include \"../"
},
{
"path": "codes/c/chapter_graph/graph_bfs.c",
"chars": 2960,
"preview": "/**\n * File: graph_bfs.c\n * Created Time: 2023-07-11\n * Author: NI-SW (947743645@qq.com)\n */\n\n#include \"graph_adjacency_"
},
{
"path": "codes/c/chapter_graph/graph_dfs.c",
"chars": 1858,
"preview": "/**\n * File: graph_dfs.c\n * Created Time: 2023-07-13\n * Author: NI-SW (947743645@qq.com)\n */\n\n#include \"graph_adjacency_"
},
{
"path": "codes/c/chapter_greedy/CMakeLists.txt",
"chars": 319,
"preview": "add_executable(coin_change_greedy coin_change_greedy.c)\nadd_executable(fractional_knapsack fractional_knapsack.c)\nadd_ex"
},
{
"path": "codes/c/chapter_greedy/coin_change_greedy.c",
"chars": 1431,
"preview": "/**\n * File: coin_change_greedy.c\n * Created Time: 2023-09-07\n * Author: lwbaptx (lwbaptx@gmail.com)\n */\n\n#include \"../u"
},
{
"path": "codes/c/chapter_greedy/fractional_knapsack.c",
"chars": 1483,
"preview": "/**\n * File: fractional_knapsack.c\n * Created Time: 2023-09-14\n * Author: xianii (xianyi.xia@outlook.com)\n */\n\n#include "
},
{
"path": "codes/c/chapter_greedy/max_capacity.c",
"chars": 897,
"preview": "/**\n * File: max_capacity.c\n * Created Time: 2023-09-15\n * Author: xianii (xianyi.xia@outlook.com)\n */\n\n#include \"../uti"
},
{
"path": "codes/c/chapter_greedy/max_product_cutting.c",
"chars": 715,
"preview": "/**\n * File: max_product_cutting.c\n * Created Time: 2023-09-15\n * Author: xianii (xianyi.xia@outlook.com)\n */\n\n#include "
},
{
"path": "codes/c/chapter_hashing/CMakeLists.txt",
"chars": 212,
"preview": "add_executable(array_hash_map array_hash_map.c)\nadd_executable(hash_map_chaining hash_map_chaining.c)\nadd_executable(has"
},
{
"path": "codes/c/chapter_hashing/array_hash_map.c",
"chars": 4671,
"preview": "/**\n * File: array_hash_map.c\n * Created Time: 2023-03-18\n * Author: Guanngxu (446678850@qq.com)\n */\n\n#include \"../utils"
},
{
"path": "codes/c/chapter_hashing/hash_map_chaining.c",
"chars": 5210,
"preview": "/**\n * File: hash_map_chaining.c\n * Created Time: 2023-10-13\n * Author: SenMing (1206575349@qq.com), krahets (krahets@16"
},
{
"path": "codes/c/chapter_hashing/hash_map_open_addressing.c",
"chars": 5932,
"preview": "/**\n * File: hash_map_open_addressing.c\n * Created Time: 2023-10-6\n * Author: lclc6 (w1929522410@163.com)\n */\n\n#include "
},
{
"path": "codes/c/chapter_hashing/simple_hash.c",
"chars": 1366,
"preview": "/**\n * File: simple_hash.c\n * Created Time: 2023-09-09\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#include \"../utils/com"
},
{
"path": "codes/c/chapter_heap/CMakeLists.txt",
"chars": 74,
"preview": "add_executable(my_heap_test my_heap_test.c)\nadd_executable(top_k top_k.c)\n"
},
{
"path": "codes/c/chapter_heap/my_heap.c",
"chars": 3088,
"preview": "/**\n * File: my_heap.c\n * Created Time: 2023-01-15\n * Author: Reanon (793584285@qq.com)\n */\n\n#include \"../utils/common.h"
},
{
"path": "codes/c/chapter_heap/my_heap_test.c",
"chars": 855,
"preview": "/**\n * File: my_heap_test.c\n * Created Time: 2023-01-15\n * Author: Reanon (793584285@qq.com)\n */\n\n#include \"my_heap.c\"\n\n"
},
{
"path": "codes/c/chapter_heap/top_k.c",
"chars": 1535,
"preview": "/**\n * File: top_k.c\n * Created Time: 2023-10-26\n * Author: krahets (krahets163.com)\n */\n\n#include \"my_heap.c\"\n\n/* 元素入堆 "
},
{
"path": "codes/c/chapter_searching/CMakeLists.txt",
"chars": 202,
"preview": "add_executable(binary_search binary_search.c)\nadd_executable(two_sum two_sum.c)\nadd_executable(binary_search_edge binary"
},
{
"path": "codes/c/chapter_searching/binary_search.c",
"chars": 1503,
"preview": "/**\n * File: binary_search.c\n * Created Time: 2023-03-18\n * Author: Guanngxu (446678850@qq.com)\n */\n\n#include \"../utils/"
},
{
"path": "codes/c/chapter_searching/binary_search_edge.c",
"chars": 1834,
"preview": "/**\n * File: binary_search_edge.c\n * Created Time: 2023-09-09\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#include \"../ut"
},
{
"path": "codes/c/chapter_searching/binary_search_insertion.c",
"chars": 2046,
"preview": "/**\n * File: binary_search_insertion.c\n * Created Time: 2023-09-09\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#include \""
},
{
"path": "codes/c/chapter_searching/two_sum.c",
"chars": 2085,
"preview": "/**\n * File: two_sum.c\n * Created Time: 2023-01-19\n * Author: Reanon (793584285@qq.com)\n */\n\n#include \"../utils/common.h"
},
{
"path": "codes/c/chapter_sorting/CMakeLists.txt",
"chars": 384,
"preview": "add_executable(bubble_sort bubble_sort.c)\nadd_executable(insertion_sort insertion_sort.c)\nadd_executable(quick_sort quic"
},
{
"path": "codes/c/chapter_sorting/bubble_sort.c",
"chars": 1418,
"preview": "/**\n * File: bubble_sort.c\n * Created Time: 2022-12-26\n * Author: Listening (https://github.com/L-Super)\n */\n\n#include \""
},
{
"path": "codes/c/chapter_sorting/bucket_sort.c",
"chars": 1445,
"preview": "/**\n * File: bucket_sort.c\n * Created Time: 2023-05-30\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#include \"../utils/com"
},
{
"path": "codes/c/chapter_sorting/counting_sort.c",
"chars": 2180,
"preview": "/**\n * File: counting_sort.c\n * Created Time: 2023-03-20\n * Author: Reanon (793584285@qq.com), Guanngxu (446678850@qq.co"
},
{
"path": "codes/c/chapter_sorting/heap_sort.c",
"chars": 1285,
"preview": "/**\n * File: heap_sort.c\n * Created Time: 2023-05-30\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#include \"../utils/commo"
},
{
"path": "codes/c/chapter_sorting/insertion_sort.c",
"chars": 781,
"preview": "/**\n * File: insertion_sort.c\n * Created Time: 2022-12-29\n * Author: Listening (https://github.com/L-Super)\n */\n\n#includ"
},
{
"path": "codes/c/chapter_sorting/merge_sort.c",
"chars": 1522,
"preview": "/**\n * File: merge_sort.c\n * Created Time: 2022-03-21\n * Author: Guanngxu (446678850@qq.com)\n */\n\n#include \"../utils/com"
},
{
"path": "codes/c/chapter_sorting/quick_sort.c",
"chars": 3431,
"preview": "/**\n * File: quick_sort.c\n * Created Time: 2023-01-18\n * Author: Reanon (793584285@qq.com)\n */\n\n#include \"../utils/commo"
},
{
"path": "codes/c/chapter_sorting/radix_sort.c",
"chars": 1990,
"preview": "/**\n * File: radix_sort.c\n * Created Time: 2023-01-18\n * Author: Reanon (793584285@qq.com)\n */\n\n#include \"../utils/commo"
},
{
"path": "codes/c/chapter_sorting/selection_sort.c",
"chars": 752,
"preview": "/**\n * File: selection_sort.c\n * Created Time: 2023-05-31\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#include \"../utils/"
},
{
"path": "codes/c/chapter_stack_and_queue/CMakeLists.txt",
"chars": 282,
"preview": "add_executable(array_stack array_stack.c)\nadd_executable(linkedlist_stack linkedlist_stack.c)\nadd_executable(array_queue"
},
{
"path": "codes/c/chapter_stack_and_queue/array_deque.c",
"chars": 4049,
"preview": "/**\n * File: array_deque.c\n * Created Time: 2023-03-13\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#include \"../utils/com"
},
{
"path": "codes/c/chapter_stack_and_queue/array_queue.c",
"chars": 2943,
"preview": "/**\n * File: array_queue.c\n * Created Time: 2023-01-28\n * Author: Zero (glj0@outlook.com)\n */\n\n#include \"../utils/common"
},
{
"path": "codes/c/chapter_stack_and_queue/array_stack.c",
"chars": 1861,
"preview": "/**\n * File: array_stack.c\n * Created Time: 2023-01-12\n * Author: Zero (glj0@outlook.com)\n */\n\n#include \"../utils/common"
},
{
"path": "codes/c/chapter_stack_and_queue/linkedlist_deque.c",
"chars": 4977,
"preview": "/**\n * File: linkedlist_deque.c\n * Created Time: 2023-03-13\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#include \"../util"
},
{
"path": "codes/c/chapter_stack_and_queue/linkedlist_queue.c",
"chars": 2675,
"preview": "/**\n * File: linkedlist_queue.c\n * Created Time: 2023-03-13\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#include \"../util"
},
{
"path": "codes/c/chapter_stack_and_queue/linkedlist_stack.c",
"chars": 2012,
"preview": "/**\n * File: linkedlist_stack.c\n * Created Time: 2023-01-12\n * Author: Zero (glj0@outlook.com)\n */\n\n#include \"../utils/c"
},
{
"path": "codes/c/chapter_tree/CMakeLists.txt",
"chars": 288,
"preview": "add_executable(avl_tree avl_tree.c)\nadd_executable(binary_tree binary_tree.c)\nadd_executable(binary_tree_bfs binary_tree"
},
{
"path": "codes/c/chapter_tree/array_binary_tree.c",
"chars": 3909,
"preview": "/**\n * File: array_binary_tree.c\n * Created Time: 2023-07-29\n * Author: Gonglja (glj0@outlook.com)\n */\n\n#include \"../uti"
},
{
"path": "codes/c/chapter_tree/avl_tree.c",
"chars": 5820,
"preview": "/**\n * File: avl_tree.c\n * Created Time: 2023-01-15\n * Author: Reanon (793584285@qq.com)\n */\n\n#include \"../utils/common."
},
{
"path": "codes/c/chapter_tree/binary_search_tree.c",
"chars": 3884,
"preview": "/**\n * File: binary_search_tree.c\n * Created Time: 2023-01-11\n * Author: Reanon (793584285@qq.com)\n */\n\n#include \"../uti"
},
{
"path": "codes/c/chapter_tree/binary_tree.c",
"chars": 811,
"preview": "/**\n * File: binary_tree.c\n * Created Time: 2023-01-11\n * Author: Reanon (793584285@qq.com)\n */\n\n#include \"../utils/comm"
},
{
"path": "codes/c/chapter_tree/binary_tree_bfs.c",
"chars": 1509,
"preview": "/**\n * File: binary_tree_bfs.c\n * Created Time: 2023-01-11\n * Author: Reanon (793584285@qq.com)\n */\n\n#include \"../utils/"
},
{
"path": "codes/c/chapter_tree/binary_tree_dfs.c",
"chars": 1509,
"preview": "/**\n * File: binary_tree_dfs.c\n * Created Time: 2023-01-11\n * Author: Reanon (793584285@qq.com)\n */\n\n#include \"../utils/"
},
{
"path": "codes/c/utils/CMakeLists.txt",
"chars": 122,
"preview": "add_executable(utils\n common_test.c\n common.h print_util.h\n list_node.h tree_node.h\n uthash."
},
{
"path": "codes/c/utils/common.h",
"chars": 527,
"preview": "/**\n * File: common.h\n * Created Time: 2022-12-20\n * Author: MolDuM (moldum@163.com)、Reanon (793584285@qq.com)\n */\n\n#ifn"
},
{
"path": "codes/c/utils/common_test.c",
"chars": 751,
"preview": "/**\n * File: include_test.c\n * Created Time: 2023-01-10\n * Author: Reanon (793584285@qq.com)\n */\n\n#include \"common.h\"\n\nv"
},
{
"path": "codes/c/utils/list_node.h",
"chars": 1059,
"preview": "/**\n * File: list_node.h\n * Created Time: 2023-01-09\n * Author: Reanon (793584285@qq.com)\n */\n\n#ifndef LIST_NODE_H\n#defi"
},
{
"path": "codes/c/utils/print_util.h",
"chars": 2628,
"preview": "/**\n * File: print_util.h\n * Created Time: 2022-12-21\n * Author: MolDum (moldum@163.com), Reanon (793584285@qq.com)\n */\n"
},
{
"path": "codes/c/utils/tree_node.h",
"chars": 2271,
"preview": "/**\n * File: tree_node.h\n * Created Time: 2023-01-09\n * Author: Reanon (793584285@qq.com)\n */\n\n#ifndef TREE_NODE_H\n#defi"
},
{
"path": "codes/c/utils/uthash.h",
"chars": 73912,
"preview": "/*\nCopyright (c) 2003-2022, Troy D. Hanson https://troydhanson.github.io/uthash/\nAll rights reserved.\n\nRedistribution a"
},
{
"path": "codes/c/utils/vector.h",
"chars": 5868,
"preview": "/**\n * File: vector.h\n * Created Time: 2023-07-13\n * Author: Zuoxun (845242523@qq.com)、Gonglja (glj0@outlook.com)\n */\n\n#"
},
{
"path": "codes/c/utils/vertex.h",
"chars": 870,
"preview": "/**\n * File: vertex.h\n * Created Time: 2023-10-28\n * Author: krahets (krahets@163.com)\n */\n\n#ifndef VERTEX_H\n#define VER"
},
{
"path": "codes/cpp/.gitignore",
"chars": 92,
"preview": "# Ignore all\n*\n# Unignore all with extensions\n!*.*\n# Unignore all dirs\n!*/\n\n*.dSYM/\n\nbuild/\n"
},
{
"path": "codes/cpp/CMakeLists.txt",
"chars": 623,
"preview": "cmake_minimum_required(VERSION 3.10)\nproject(hello_algo CXX)\n\nset(CMAKE_CXX_STANDARD 11)\n\ninclude_directories(./include)"
},
{
"path": "codes/cpp/chapter_array_and_linkedlist/CMakeLists.txt",
"chars": 142,
"preview": "add_executable(array array.cpp)\nadd_executable(linked_list linked_list.cpp)\nadd_executable(list list.cpp)\nadd_executable"
},
{
"path": "codes/cpp/chapter_array_and_linkedlist/array.cpp",
"chars": 2343,
"preview": "/**\n * File: array.cpp\n * Created Time: 2022-11-25\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/common.h"
},
{
"path": "codes/cpp/chapter_array_and_linkedlist/linked_list.cpp",
"chars": 1799,
"preview": "/**\n * File: linked_list.cpp\n * Created Time: 2022-11-25\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/co"
},
{
"path": "codes/cpp/chapter_array_and_linkedlist/list.cpp",
"chars": 1463,
"preview": "/**\n * File: list.cpp\n * Created Time: 2022-11-25\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/common.hp"
},
{
"path": "codes/cpp/chapter_array_and_linkedlist/my_list.cpp",
"chars": 3741,
"preview": "/**\n * File: my_list.cpp\n * Created Time: 2022-11-25\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/common"
},
{
"path": "codes/cpp/chapter_backtracking/CMakeLists.txt",
"chars": 616,
"preview": "add_executable(preorder_traversal_i_compact preorder_traversal_i_compact.cpp)\nadd_executable(preorder_traversal_ii_compa"
},
{
"path": "codes/cpp/chapter_backtracking/n_queens.cpp",
"chars": 1890,
"preview": "/**\n * File: n_queens.cpp\n * Created Time: 2023-05-04\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/commo"
},
{
"path": "codes/cpp/chapter_backtracking/permutations_i.cpp",
"chars": 1286,
"preview": "/**\n * File: permutations_i.cpp\n * Created Time: 2023-04-24\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils"
},
{
"path": "codes/cpp/chapter_backtracking/permutations_ii.cpp",
"chars": 1440,
"preview": "/**\n * File: permutations_ii.cpp\n * Created Time: 2023-04-24\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../util"
},
{
"path": "codes/cpp/chapter_backtracking/preorder_traversal_i_compact.cpp",
"chars": 747,
"preview": "/**\n * File: preorder_traversal_i_compact.cpp\n * Created Time: 2023-04-16\n * Author: krahets (krahets@163.com)\n */\n\n#inc"
},
{
"path": "codes/cpp/chapter_backtracking/preorder_traversal_ii_compact.cpp",
"chars": 922,
"preview": "/**\n * File: preorder_traversal_ii_compact.cpp\n * Created Time: 2023-04-16\n * Author: krahets (krahets@163.com)\n */\n\n#in"
},
{
"path": "codes/cpp/chapter_backtracking/preorder_traversal_iii_compact.cpp",
"chars": 968,
"preview": "/**\n * File: preorder_traversal_iii_compact.cpp\n * Created Time: 2023-04-16\n * Author: krahets (krahets@163.com)\n */\n\n#i"
},
{
"path": "codes/cpp/chapter_backtracking/preorder_traversal_iii_template.cpp",
"chars": 1927,
"preview": "/**\n * File: preorder_traversal_iii_template.cpp\n * Created Time: 2023-04-16\n * Author: krahets (krahets@163.com)\n */\n\n#"
},
{
"path": "codes/cpp/chapter_backtracking/subset_sum_i.cpp",
"chars": 1500,
"preview": "/**\n * File: subset_sum_i.cpp\n * Created Time: 2023-06-21\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/c"
},
{
"path": "codes/cpp/chapter_backtracking/subset_sum_i_naive.cpp",
"chars": 1381,
"preview": "/**\n * File: subset_sum_i_naive.cpp\n * Created Time: 2023-06-21\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../u"
},
{
"path": "codes/cpp/chapter_backtracking/subset_sum_ii.cpp",
"chars": 1676,
"preview": "/**\n * File: subset_sum_ii.cpp\n * Created Time: 2023-06-21\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/"
},
{
"path": "codes/cpp/chapter_computational_complexity/CMakeLists.txt",
"chars": 259,
"preview": "add_executable(iteration iteration.cpp)\nadd_executable(recursion recursion.cpp)\nadd_executable(space_complexity space_co"
},
{
"path": "codes/cpp/chapter_computational_complexity/iteration.cpp",
"chars": 1418,
"preview": "/**\n * File: iteration.cpp\n * Created Time: 2023-08-24\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/comm"
},
{
"path": "codes/cpp/chapter_computational_complexity/recursion.cpp",
"chars": 1401,
"preview": "/**\n * File: recursion.cpp\n * Created Time: 2023-08-24\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/comm"
},
{
"path": "codes/cpp/chapter_computational_complexity/space_complexity.cpp",
"chars": 1987,
"preview": "/**\n * File: space_complexity.cpp\n * Created Time: 2022-11-25\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../uti"
},
{
"path": "codes/cpp/chapter_computational_complexity/time_complexity.cpp",
"chars": 3544,
"preview": "/**\n * File: time_complexity.cpp\n * Created Time: 2022-11-25\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../util"
},
{
"path": "codes/cpp/chapter_computational_complexity/worst_best_time_complexity.cpp",
"chars": 1118,
"preview": "/**\n * File: worst_best_time_complexity.cpp\n * Created Time: 2022-11-25\n * Author: krahets (krahets@163.com)\n */\n\n#inclu"
},
{
"path": "codes/cpp/chapter_divide_and_conquer/CMakeLists.txt",
"chars": 135,
"preview": "add_executable(binary_search_recur binary_search_recur.cpp)\nadd_executable(build_tree build_tree.cpp)\nadd_executable(han"
},
{
"path": "codes/cpp/chapter_divide_and_conquer/binary_search_recur.cpp",
"chars": 984,
"preview": "/**\n * File: binary_search_recur.cpp\n * Created Time: 2023-07-17\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../"
},
{
"path": "codes/cpp/chapter_divide_and_conquer/build_tree.cpp",
"chars": 1287,
"preview": "/**\n * File: build_tree.cpp\n * Created Time: 2023-07-17\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/com"
},
{
"path": "codes/cpp/chapter_divide_and_conquer/hanota.cpp",
"chars": 1328,
"preview": "/**\n * File: hanota.cpp\n * Created Time: 2023-07-17\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/common."
},
{
"path": "codes/cpp/chapter_dynamic_programming/CMakeLists.txt",
"chars": 579,
"preview": "add_executable(climbing_stairs_backtrack climbing_stairs_backtrack.cpp)\nadd_executable(climbing_stairs_dfs climbing_stai"
},
{
"path": "codes/cpp/chapter_dynamic_programming/climbing_stairs_backtrack.cpp",
"chars": 952,
"preview": "\n/**\n * File: climbing_stairs_backtrack.cpp\n * Created Time: 2023-06-30\n * Author: krahets (krahets@163.com)\n */\n\n#inclu"
},
{
"path": "codes/cpp/chapter_dynamic_programming/climbing_stairs_constraint_dp.cpp",
"chars": 788,
"preview": "/**\n * File: climbing_stairs_constraint_dp.cpp\n * Created Time: 2023-07-01\n * Author: krahets (krahets@163.com)\n */\n\n#in"
},
{
"path": "codes/cpp/chapter_dynamic_programming/climbing_stairs_dfs.cpp",
"chars": 560,
"preview": "/**\n * File: climbing_stairs_dfs.cpp\n * Created Time: 2023-06-30\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../"
},
{
"path": "codes/cpp/chapter_dynamic_programming/climbing_stairs_dfs_mem.cpp",
"chars": 787,
"preview": "/**\n * File: climbing_stairs_dfs_mem.cpp\n * Created Time: 2023-06-30\n * Author: krahets (krahets@163.com)\n */\n\n#include "
},
{
"path": "codes/cpp/chapter_dynamic_programming/climbing_stairs_dp.cpp",
"chars": 954,
"preview": "/**\n * File: climbing_stairs_dp.cpp\n * Created Time: 2023-06-30\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../u"
},
{
"path": "codes/cpp/chapter_dynamic_programming/coin_change.cpp",
"chars": 1707,
"preview": "/**\n * File: coin_change.cpp\n * Created Time: 2023-07-11\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/co"
},
{
"path": "codes/cpp/chapter_dynamic_programming/coin_change_ii.cpp",
"chars": 1591,
"preview": "/**\n * File: coin_change_ii.cpp\n * Created Time: 2023-07-11\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils"
},
{
"path": "codes/cpp/chapter_dynamic_programming/edit_distance.cpp",
"chars": 3737,
"preview": "/**\n * File: edit_distance.cpp\n * Created Time: 2023-07-13\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/"
},
{
"path": "codes/cpp/chapter_dynamic_programming/knapsack.cpp",
"chars": 2891,
"preview": "#include <algorithm>\n#include <iostream>\n#include <vector>\n\nusing namespace std;\n\n/* 0-1 背包:暴力搜索 */\nint knapsackDFS(vect"
},
{
"path": "codes/cpp/chapter_dynamic_programming/min_cost_climbing_stairs_dp.cpp",
"chars": 1211,
"preview": "/**\n * File: min_cost_climbing_stairs_dp.cpp\n * Created Time: 2023-06-30\n * Author: krahets (krahets@163.com)\n */\n\n#incl"
},
{
"path": "codes/cpp/chapter_dynamic_programming/min_path_sum.cpp",
"chars": 3023,
"preview": "/**\n * File: min_path_sum.cpp\n * Created Time: 2023-07-10\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/c"
},
{
"path": "codes/cpp/chapter_dynamic_programming/unbounded_knapsack.cpp",
"chars": 1617,
"preview": "/**\n * File: unbounded_knapsack.cpp\n * Created Time: 2023-07-11\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../u"
},
{
"path": "codes/cpp/chapter_graph/CMakeLists.txt",
"chars": 282,
"preview": "add_executable(graph_bfs graph_bfs.cpp)\nadd_executable(graph_dfs graph_dfs.cpp)\n# add_executable(graph_adjacency_list gr"
},
{
"path": "codes/cpp/chapter_graph/graph_adjacency_list.cpp",
"chars": 2311,
"preview": "/**\n * File: graph_adjacency_list.cpp\n * Created Time: 2023-02-09\n * Author: what-is-me (whatisme@outlook.jp), krahets ("
},
{
"path": "codes/cpp/chapter_graph/graph_adjacency_list_test.cpp",
"chars": 1142,
"preview": "/**\n * File: graph_adjacency_list_test.cpp\n * Created Time: 2023-02-09\n * Author: what-is-me (whatisme@outlook.jp), krah"
},
{
"path": "codes/cpp/chapter_graph/graph_adjacency_matrix.cpp",
"chars": 3057,
"preview": "/**\n * File: graph_adjacency_matrix.cpp\n * Created Time: 2023-02-09\n * Author: what-is-me (whatisme@outlook.jp)\n */\n\n#in"
},
{
"path": "codes/cpp/chapter_graph/graph_bfs.cpp",
"chars": 1646,
"preview": "/**\n * File: graph_bfs.cpp\n * Created Time: 2023-03-02\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/comm"
},
{
"path": "codes/cpp/chapter_graph/graph_dfs.cpp",
"chars": 1431,
"preview": "/**\n * File: graph_dfs.cpp\n * Created Time: 2023-03-02\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/comm"
},
{
"path": "codes/cpp/chapter_greedy/CMakeLists.txt",
"chars": 163,
"preview": "add_executable(coin_change_greedy coin_change_greedy.cpp)\nadd_executable(fractional_knapsack fractional_knapsack.cpp)\nad"
},
{
"path": "codes/cpp/chapter_greedy/coin_change_greedy.cpp",
"chars": 1472,
"preview": "/**\n * File: coin_change_greedy.cpp\n * Created Time: 2023-07-20\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../u"
},
{
"path": "codes/cpp/chapter_greedy/fractional_knapsack.cpp",
"chars": 1283,
"preview": "/**\n * File: fractional_knapsack.cpp\n * Created Time: 2023-07-20\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../"
},
{
"path": "codes/cpp/chapter_greedy/max_capacity.cpp",
"chars": 718,
"preview": "/**\n * File: max_capacity.cpp\n * Created Time: 2023-07-21\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/c"
},
{
"path": "codes/cpp/chapter_greedy/max_product_cutting.cpp",
"chars": 730,
"preview": "/**\n * File: max_product_cutting.cpp\n * Created Time: 2023-07-21\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../"
},
{
"path": "codes/cpp/chapter_hashing/CMakeLists.txt",
"chars": 315,
"preview": "add_executable(hash_map hash_map.cpp)\nadd_executable(array_hash_map_test array_hash_map_test.cpp)\nadd_executable(hash_ma"
},
{
"path": "codes/cpp/chapter_hashing/array_hash_map.cpp",
"chars": 2201,
"preview": "/**\n * File: array_hash_map.cpp\n * Created Time: 2022-12-14\n * Author: msk397 (machangxinq@gmail.com)\n */\n\n#include \"../"
},
{
"path": "codes/cpp/chapter_hashing/array_hash_map_test.cpp",
"chars": 1141,
"preview": "/**\n * File: array_hash_map_test.cpp\n * Created Time: 2022-12-14\n * Author: msk397 (machangxinq@gmail.com)\n */\n\n#include"
},
{
"path": "codes/cpp/chapter_hashing/built_in_hash.cpp",
"chars": 730,
"preview": "/**\n * File: built_in_hash.cpp\n * Created Time: 2023-06-21\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/"
},
{
"path": "codes/cpp/chapter_hashing/hash_map.cpp",
"chars": 1067,
"preview": "/**\n * File: hash_map.cpp\n * Created Time: 2022-12-14\n * Author: msk397 (machangxinq@gmail.com)\n */\n\n#include \"../utils/"
},
{
"path": "codes/cpp/chapter_hashing/hash_map_chaining.cpp",
"chars": 3583,
"preview": "/**\n * File: hash_map_chaining.cpp\n * Created Time: 2023-06-13\n * Author: krahets (krahets@163.com)\n */\n\n#include \"./arr"
},
{
"path": "codes/cpp/chapter_hashing/hash_map_open_addressing.cpp",
"chars": 4486,
"preview": "/**\n * File: hash_map_open_addressing.cpp\n * Created Time: 2023-06-13\n * Author: krahets (krahets@163.com)\n */\n\n#include"
},
{
"path": "codes/cpp/chapter_hashing/simple_hash.cpp",
"chars": 1296,
"preview": "/**\n * File: simple_hash.cpp\n * Created Time: 2023-06-21\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/co"
},
{
"path": "codes/cpp/chapter_heap/CMakeLists.txt",
"chars": 98,
"preview": "add_executable(heap heap.cpp)\nadd_executable(my_heap my_heap.cpp)\nadd_executable(top_k top_k.cpp)\n"
},
{
"path": "codes/cpp/chapter_heap/heap.cpp",
"chars": 1466,
"preview": "/**\n * File: heap.cpp\n * Created Time: 2023-01-19\n * Author: LoneRanger(836253168@qq.com)\n */\n\n#include \"../utils/common"
},
{
"path": "codes/cpp/chapter_heap/my_heap.cpp",
"chars": 3248,
"preview": "/**\n * File: my_heap.cpp\n * Created Time: 2023-02-04\n * Author: LoneRanger (836253168@qq.com), what-is-me (whatisme@outl"
},
{
"path": "codes/cpp/chapter_heap/top_k.cpp",
"chars": 869,
"preview": "/**\n * File: top_k.cpp\n * Created Time: 2023-06-12\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/common.h"
},
{
"path": "codes/cpp/chapter_searching/CMakeLists.txt",
"chars": 210,
"preview": "add_executable(binary_search binary_search.cpp)\nadd_executable(binary_search_insertion binary_search_insertion.cpp)\nadd_"
},
{
"path": "codes/cpp/chapter_searching/binary_search.cpp",
"chars": 1527,
"preview": "/**\n * File: binary_search.cpp\n * Created Time: 2022-11-25\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/"
},
{
"path": "codes/cpp/chapter_searching/binary_search_edge.cpp",
"chars": 1673,
"preview": "/**\n * File: binary_search_edge.cpp\n * Created Time: 2023-08-04\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../u"
},
{
"path": "codes/cpp/chapter_searching/binary_search_insertion.cpp",
"chars": 1783,
"preview": "/**\n * File: binary_search_insertion.cpp\n * Created Time: 2023-08-04\n * Author: krahets (krahets@163.com)\n */\n\n#include "
},
{
"path": "codes/cpp/chapter_searching/hashing_search.cpp",
"chars": 1341,
"preview": "/**\n * File: hashing_search.cpp\n * Created Time: 2022-11-25\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils"
},
{
"path": "codes/cpp/chapter_searching/linear_search.cpp",
"chars": 1078,
"preview": "/**\n * File: linear_search.cpp\n * Created Time: 2022-11-25\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/"
},
{
"path": "codes/cpp/chapter_searching/two_sum.cpp",
"chars": 1235,
"preview": "/**\n * File: two_sum.cpp\n * Created Time: 2022-11-25\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/common"
},
{
"path": "codes/cpp/chapter_sorting/CMakeLists.txt",
"chars": 267,
"preview": "add_executable(selection_sort selection_sort.cpp)\nadd_executable(bubble_sort bubble_sort.cpp)\nadd_executable(insertion_s"
},
{
"path": "codes/cpp/chapter_sorting/bubble_sort.cpp",
"chars": 1393,
"preview": "/**\n * File: bubble_sort.cpp\n * Created Time: 2022-11-25\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/co"
},
{
"path": "codes/cpp/chapter_sorting/bucket_sort.cpp",
"chars": 1043,
"preview": "/**\n * File: bucket_sort.cpp\n * Created Time: 2023-03-30\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/co"
},
{
"path": "codes/cpp/chapter_sorting/counting_sort.cpp",
"chars": 1800,
"preview": "/**\n * File: counting_sort.cpp\n * Created Time: 2023-03-17\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/"
},
{
"path": "codes/cpp/chapter_sorting/heap_sort.cpp",
"chars": 1192,
"preview": "/**\n * File: heap_sort.cpp\n * Created Time: 2023-05-26\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/comm"
},
{
"path": "codes/cpp/chapter_sorting/insertion_sort.cpp",
"chars": 692,
"preview": "/**\n * File: insertion_sort.cpp\n * Created Time: 2022-11-25\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils"
},
{
"path": "codes/cpp/chapter_sorting/merge_sort.cpp",
"chars": 1415,
"preview": "/**\n * File: merge_sort.cpp\n * Created Time: 2022-11-25\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/com"
},
{
"path": "codes/cpp/chapter_sorting/quick_sort.cpp",
"chars": 4417,
"preview": "/**\n * File: quick_sort.cpp\n * Created Time: 2022-11-25\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/com"
},
{
"path": "codes/cpp/chapter_sorting/radix_sort.cpp",
"chars": 1725,
"preview": "/**\n * File: radix_sort.cpp\n * Created Time: 2023-03-26\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils/com"
},
{
"path": "codes/cpp/chapter_sorting/selection_sort.cpp",
"chars": 689,
"preview": "/**\n * File: selection_sort.cpp\n * Created Time: 2023-05-23\n * Author: krahets (krahets@163.com)\n */\n\n#include \"../utils"
},
{
"path": "codes/cpp/chapter_stack_and_queue/CMakeLists.txt",
"chars": 390,
"preview": "add_executable(array_deque array_deque.cpp)\nadd_executable(array_queue array_queue.cpp)\nadd_executable(array_stack array"
}
]
// ... and 6925 more files (download for full content)
About this extraction
This page contains the full source code of the krahets/hello-algo GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 7125 files (15.6 MB), approximately 4.5M tokens, and a symbol index with 22693 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.