一系列的常用 Python 数据结构及算法

846 阅读1分钟
原文链接: github.com

Minimal and clean example implementations of data structures and algorithms in Python.

List of Implementations:

.
├── array
│   ├── circular_counter.py
│   ├── flatten.py
│   ├── garage.py
│   ├── longest_non_repeat.py
│   ├── merge_intervals.py
│   ├── missing_ranges.py
│   ├── plus_one.py
│   ├── rotate_array.py
│   ├── summary_ranges.py
│   ├── three_sum.py
│   └── two_sum.py
├── backtrack
│   ├── anagram.py
│   ├── array_sum_combinations.py
│   ├── combination_sum.py
│   ├── expression_add_operators.py
│   ├── factor_combinations.py
│   ├── general_solution.md
│   ├── generate_abbreviations.py
│   ├── generate_parenthesis.py
│   ├── letter_combination.py
│   ├── palindrome_partitioning.py
│   ├── pattern_match.py
│   ├── permute.py
│   ├── permute_unique.py
│   ├── subsets.py
│   └── subsets_unique.py
├── bfs
│   ├── shortest_distance_from_all_buildings.py
│   └── word_ladder.py
├── bit
│   ├── count_ones.py
│   ├── power_of_two.py
│   ├── reverse_bits.py
│   ├── single_number2.py
│   ├── single_number.py
│   └── subsets.py
├── design
│   ├── alarm_system.md
│   ├── all_o_one_ds.md
│   ├── calculator.md
│   ├── excel_table.md
│   ├── LRUcache.md
│   ├── nearby_drivers.md
│   ├── ride_sharing.md
│   ├── task_runner.md
│   └── twitter_feeds.md
├── dfs
│   ├── all_factors.py
│   ├── count_islands.py
│   ├── pacific_atlantic.py
│   ├── sudoku_solver.py
│   └── walls_and_gates.py
├── dp
│   ├── buy_sell_stock.py
│   ├── climbing_stairs.py
│   ├── combination_sum.py
│   ├── house_robber.py
│   ├── longest_increasing.py
│   ├── max_product_subarray.py
│   ├── max_subarray.py
│   ├── num_decodings.py
│   ├── regex_matching.py
│   └── word_break.py
├── graph
│   ├── clone_graph.py
│   ├── find_path.py
│   ├── graph.py
│   └── traversal.py
├── heap
│   ├── merge_sorted_k_lists.py
│   ├── skyline.py
│   └── sliding_window_max.py
├── linkedlist
│   ├── add_two_numbers.py
│   ├── copy_random_pointer.py
│   ├── delete_node.py
│   ├── first_cyclic_node.py
│   ├── is_cyclic.py
│   ├── is_palindrome.py
│   ├── kth_to_last.py
│   ├── linkedlist.py
│   ├── remove_duplicates.py
│   ├── reverse.py
│   ├── rotate_list.py
│   └── swap_in_pairs.py
├── map
│   ├── hashtable.py
│   ├── longest_common_subsequence.py
│   ├── randomized_set.py
│   └── valid_sudoku.py
├── math
|   ├── gcd.py
|   ├── prime_test.py
|   ├── primes_sieve_of_eratosthenes.py
│   ├── generate_strobogrammtic.py
│   ├── is_strobogrammatic.py
│   ├── nth_digit.py
│   ├── sqrt_precision_factor.py
│   └── pythagoras.py
├── matrix
│   ├── bomb_enemy.py
│   ├── matrix_rotation.txt
│   ├── rotate_image.py
│   ├── sparse_dot_vector.py
│   ├── sparse_mul.py
│   └── spiral_traversal.py
├── queue
│   ├── __init__.py
│   ├── max_sliding_window.py
│   ├── moving_average.py
│   ├── queue.py
│   ├── reconstruct_queue.py
│   └── zigzagiterator.py
├── README.md
├── search
│   ├── binary_search.py
│   ├── count_elem.py
│   ├── first_occurance.py
│   └── last_occurance.py
├── set
│   └── randomized_set.py
├── sort
│   ├── insertion_sort.py
│   ├── meeting_rooms.py
│   ├── merge_sort.py
│   ├── quick_sort.py
│   ├── selection_sort.py
│   ├── sort_colors.py
│   ├── topsort.py
│   └── wiggle_sort.py
├── stack
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── longest_abs_path.py
│   ├── __pycache__
│   │   ├── __init__.cpython-35.pyc
│   │   └── stack.cpython-35.pyc
│   ├── simplify_path.py
│   ├── stack.py
│   ├── stack.pyc
│   └── valid_parenthesis.py
├── string
│   ├── add_binary.py
│   ├── breaking_bad.py
│   ├── decode_string.py
│   ├── encode_decode.py
│   ├── group_anagrams.py
│   ├── int_to_roman.py
│   ├── is_palindrome.py
│   ├── license_number.py
│   ├── make_sentence.py
│   ├── multiply_strings.py
│   ├── one_edit_distance.py
│   ├── rabin_karp.py
│   ├── reverse_string.py
│   ├── reverse_vowel.py
│   ├── reverse_words.py
│   ├── roman_to_int.py
│   └── word_squares.py
├── tmp
│   └── temporary.md
├── tree
|   ├── Segment_Tree
|   |   ├── segment_tree.py
│   ├── binary_tree_paths.py
│   ├── bintree2list.py
│   ├── bst
│   │   ├── array2bst.py
│   │   ├── bst_closest_value.py
│   │   ├── BSTIterator.py
│   │   ├── delete_node.py
│   │   ├── is_bst.py
│   │   ├── kth_smallest.py
│   │   ├── lowest_common_ancestor.py
│   │   ├── predecessor.py
│   │   ├── serialize_deserialize.py
│   │   ├── successor.py
│   │   └── unique_bst.py
│   ├── deepest_left.py
│   ├── invert_tree.py
│   ├── is_balanced.py
│   ├── is_subtree.py
│   ├── is_symmetric.py
│   ├── longest_consecutive.py
│   ├── lowest_common_ancestor.py
│   ├── max_height.py
│   ├── max_path_sum.py
│   ├── min_height.py
│   ├── path_sum2.py
│   ├── path_sum.py
│   ├── pretty_print.py
│   ├── same_tree.py
│   ├── traversal
│   │   ├── inorder.py
│   │   ├── level_order.py
│   │   └── zigzag.py
│   ├── tree.py
│   └── trie
│       ├── add_and_search.py
│       └── trie.py
├── tree.md
└── union-find
    └── count_islands.py