LeetCode-Alg: 針對(duì)LeetCode解題開發(fā)的基于python的數(shù)據(jù)結(jié)構(gòu)和算法庫
github:?https://github.com/Jintao-Huang/LeetCode-Py
經(jīng)過一個(gè)月的斷斷續(xù)續(xù)的開發(fā), 終于把這個(gè)庫的第一版開發(fā)出來啦.?`leetcode_alg==0.1.0`
介紹
LeetCode-Py倉庫只要包含兩大內(nèi)容: 算法庫leetcode_alg, 以及基于leetcode_alg的大量leetcode題目的python解答(將會(huì)收集1k題以上, 持續(xù)更新中)
LeetCode-Py的習(xí)題解答風(fēng)格: 最優(yōu)復(fù)雜度, 最簡(jiǎn)潔最優(yōu)雅的代碼(盡量避免過多的細(xì)節(jié)優(yōu)化), 時(shí)間性能上保證打敗85%的代碼.?
leetcode_alg庫的設(shè)計(jì)哲學(xué): 以通用性為核心, 并以最大可能進(jìn)行性能優(yōu)化.?
性能和功能
answer/中時(shí)間擊敗: (持續(xù)更新中)
100%:?1, 16, 18, 39, 42, 72, 84, 146, 167, 200, 300, 354, 416, 518, 1143, 1349, 2096, 2203
95%: 2, 11, 28, 40, 51, 52, 102, 107, 112, 113, 124, 153, 204, 207, 210, 322, 454, 496, 503, 704, 875, 1044, o51
85%: 4, 15, 19, 85, 92, 208, 215, 307, 876, 1584, o40
其他:?
leetcode_alg已有的功能: (持續(xù)更新中)
算法:?
array: unique, partition, partition2, merge, merge2, diff, quick_select, two_sum
dp: LIS, LIS2, LCS, LCS2, edit_distance, matrix_chain, matrix_chain2
graph: dijkstra, dijkstra2, dijkstra3, kruskal, prim, prim2, topo_sort, Dinic, hungarian
greed: merge_intervals, merge_intervals2
knapsack: knapsack, knapsackV, knapsack_C, knapsackV_C
linkedlist: reverse_list, find_mid_node, find_last_kth_node
math: is_prime, find_primes
monotone_deque: monotone_deque, monotone_deque2
monotone_stack: monotone_stack, monotone_stack2, monotone_stack3, largest_rect, largest_rect2
search: lower_bound, upper_bound, n_queens
string: build_nextval, kmp
tree: find_path, find_common_ancestor, inorder_traversal, level_order_traversal
unimportant:?reverse, euclidean_dist, manhattan_dist, prefix_sum,?bisect_left, bisect_right, binary_search,?gcd, lcm, fast_pow,?randperm,?quick_sort, merge_sort, heap_sort, heap_sort2
數(shù)據(jù)結(jié)構(gòu):?
binary_indexed_tree: BinaryIndexedTree, BinaryIndexedTree2
heap: Heap, Heap2
linkedlist: LinkedListNode, LinkedList
segment_tree: SegmentTree, SegmentTree2
sorted_list: SimpleSortedList
string_hasher: StringHasher, StringHasher2
trie: TrieTreeNode, Trie
union_find: UnionFind
unimportant:?OrderedDict
LeetCode Tools:?
數(shù)據(jù)結(jié)構(gòu): ListNode, TreeNode
tools: to_linkedlist, from_linkedlist, to_tree, from_tree, call_callable_list
安裝和使用
安裝: `pip install leetcode-alg`? (from pypi)
使用: 可以查看answer/