Python数据结构和算法
Python3中数据结构和算法的最小且干净的示例实现
贡献
感谢您对投稿的兴趣!有很多方式可以为这个项目做出贡献。Get started here
测试
使用单元测试
要运行所有测试,请写下:
$ python3 -m unittest discover tests
要运行某些特定测试,您可以执行以下操作(例如:排序):
$ python3 -m unittest tests.test_sort
使用pytest
要运行所有测试,请写下:
$ python3 -m pytest tests
安装
如果您想在代码中使用API算法,只需如下所示:
$ pip3 install algorithms
您可以通过创建一个python文件进行测试:(例如:USEmerge_sort
在……里面sort
)
from algorithms.sort import merge_sort
if __name__ == "__main__":
my_list = [1, 8, 3, 5, 6]
my_list = merge_sort(my_list)
print(my_list)
卸载
如果要卸载算法,只需执行以下操作:
$ pip3 uninstall -y algorithms
实现列表
- arrays
- automata
- backtrack
- bfs
- bit
- compression
- dfs
- distribution
- dp
- buy_sell_stock
- climbing_stairs
- coin_change
- combination_sum
- egg_drop
- house_robber
- int_divide
- job_scheduling
- knapsack
- longest_increasing
- matrix_chain_order
- max_product_subarray
- max_subarray
- min_cost_path
- num_decodings
- regex_matching
- rod_cut
- word_break
- fibonacci
- hosoya triangle
- K-Factor_strings
- planting_trees
- graph
- heap
- linkedlist
- map
- maths
- base_conversion
- chinese_remainder_theorem
- combination
- cosine_similarity
- decimal_to_binary_ip
- diffie_hellman_key_exchange
- euler_totient
- extended_gcd
- factorial
- find_order
- find_primitive_root
- gcd/lcm
- generate_strobogrammtic
- hailstone
- is_strobogrammatic
- krishnamurthy_number
- magic_number
- modular_exponential
- modular_inverse
- next_bigger
- next_perfect_square
- nth_digit
- polynomial
- power
- prime_check
- primes_sieve_of_eratosthenes
- pythagoras
- rabin_miller
- recursive_binomial_coefficient
- rsa
- sqrt_precision_factor
- summing_digits
- symmetry_group_cycle_index
- matrix
- queues
- search
- set
- sort
- stack
- streaming
- strings
- fizzbuzz
- delete_reoccurring
- strip_url_params
- validate_coordinates
- domain_extractor
- merge_string_checker
- add_binary
- breaking_bad
- decode_string
- encode_decode
- group_anagrams
- int_to_roman
- is_palindrome
- license_number
- make_sentence
- multiply_strings
- one_edit_distance
- rabin_karp
- reverse_string
- reverse_vowel
- reverse_words
- roman_to_int
- word_squares
- unique_morse
- judge_circle
- strong_password
- caesar_cipher
- check_pangram
- contain_string
- count_binary_substring
- repeat_string
- min_distance
- longest_common_prefix
- rotate
- first_unique_char
- repeat_substring
- longest_palindromic_substring
- knuth_morris_pratt
- panagram
- tree
- bst
- [Fenwick_tree](算法/树/Fenwick_tree)
- fenwick_tree
- red_black_tree
- segment_tree
- traversal
- trie
- b_tree
- binary_tree_paths
- bin_tree_to_list
- construct_tree_preorder_postorder
- deepest_left
- invert_tree
- is_balanced
- is_subtree
- is_symmetric
- longest_consecutive
- lowest_common_ancestor
- max_height
- max_path_sum
- min_height
- path_sum
- path_sum2
- pretty_print
- same_tree
- tree
- unix
- unionfind
贡献者
感谢all the contributors帮助建立回购的人