欢迎光临散文网 会员登陆 & 注册

LeetCode-Alg: 针对LeetCode解题开发的基于python的数据结构和算法库

2023-03-19 11:03 作者:努力学习计算机  | 我要投稿

github: https://github.com/Jintao-Huang/LeetCode-Py

经过一个月的断断续续的开发, 终于把这个库的第一版开发出来啦. `leetcode_alg==0.1.0`

介绍

  1. LeetCode-Py仓库只要包含两大内容: 算法库leetcode_alg, 以及基于leetcode_alg的大量leetcode题目的python解答(将会收集1k题以上, 持续更新中)

  2. LeetCode-Py的习题解答风格: 最优复杂度, 最简洁最优雅的代码(尽量避免过多的细节优化), 时间性能上保证打败85%的代码. 

  3. leetcode_alg库的设计哲学: 以通用性为核心, 并以最大可能进行性能优化. 

性能和功能

  1. answer/中时间击败: (持续更新中)

    1. 100%: 1, 16, 18, 39, 42, 72, 84, 146, 167, 200, 300, 354, 416, 518, 1143, 1349, 2096, 2203

    2. 95%: 2, 11, 28, 40, 51, 52, 102, 107, 112, 113, 124, 153, 204, 207, 210, 322, 454, 496, 503, 704, 875, 1044, o51

    3. 85%: 4, 15, 19, 85, 92, 208, 215, 307, 876, 1584, o40

    4. 其他: 

  2. leetcode_alg已有的功能: (持续更新中)

    1. 算法: 

      1. array: unique, partition, partition2, merge, merge2, diff, quick_select, two_sum

      2. dp: LIS, LIS2, LCS, LCS2, edit_distance, matrix_chain, matrix_chain2

      3. graph: dijkstra, dijkstra2, dijkstra3, kruskal, prim, prim2, topo_sort, Dinic, hungarian

      4. greed: merge_intervals, merge_intervals2

      5. knapsack: knapsack, knapsackV, knapsack_C, knapsackV_C

      6. linkedlist: reverse_list, find_mid_node, find_last_kth_node

      7. math: is_prime, find_primes

      8. monotone_deque: monotone_deque, monotone_deque2

      9. monotone_stack: monotone_stack, monotone_stack2, monotone_stack3, largest_rect, largest_rect2

      10. search: lower_bound, upper_bound, n_queens

      11. string: build_nextval, kmp

      12. tree: find_path, find_common_ancestor, inorder_traversal, level_order_traversal

      13. 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

    2. 数据结构: 

      1. binary_indexed_tree: BinaryIndexedTree, BinaryIndexedTree2

      2. heap: Heap, Heap2

      3. linkedlist: LinkedListNode, LinkedList

      4. segment_tree: SegmentTree, SegmentTree2

      5. sorted_list: SimpleSortedList

      6. string_hasher: StringHasher, StringHasher2

      7. trie: TrieTreeNode, Trie

      8. union_find: UnionFind

      9. unimportant: OrderedDict

    3. LeetCode Tools: 

      1. 数据结构: ListNode, TreeNode

      2. tools: to_linkedlist, from_linkedlist, to_tree, from_tree, call_callable_list

安装和使用

  1. 安装: `pip install leetcode-alg`  (from pypi)

  2. 使用: 可以查看answer/


LeetCode-Alg: 针对LeetCode解题开发的基于python的数据结构和算法库的评论 (共 条)

分享到微博请遵守国家法律