Skip to content

leetcode/codeforces Rust solution with unittest, leetcode-rust and codeforces-rust

Notifications You must be signed in to change notification settings

pymongo/leetcode-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

some interesting topic about Rust on leetcode

use rustc source code to solve leetcode

leetcode-rust package require rustc_private feature to enable rustc relative API

e.g. use rustc_span::lev_distance::lev_distance(&a, &b) one line to solve leetcode edit-distance (Unfortunately we can't use nightly and rustc-dev in leetcode)

use rustc_graphviz visualize leetcode binary tree

graphviz_leetcode_binary_tree.png


codeforces_solutions

Problem Solution
1A - Theatre Square Rust
4A - Watermelon Rust
71A - Way Too Long Words Rust
158A - Next Round Rust
231A - Team Rust

leetcode_solutions

(problem number with 🔒 suffix need leetcode VIP to unlock)

# Problem Solutions Category/Comment
1 Two Sum Rust, Java bitwise
2 Add Two Numbers Rust, Java, Go linked_list
3 Longest Substring Without Repeating Char... Rust sliding_window
4 Median of Two Sorted Arrays Rust, Python binary_search
5 Longest Palindromic Substring Rust, Python manacher, suffix_array
6 ZigZag Conversion Rust
7 Reverse Integer Rust
8 String to Integer (atoi) Python
9 Palindromic Number Rust
10 Regular Expression Matching Python
11 Container With Most Water Rust
12 Integer to Roman Rust
13 Roman to Integer Rust
14 Longest Common Prefix Python
15 3Sum Python two_pointers, two_sum
16 3Sum Closest Python two_sum
17 Letter Combinations of a Phone Number Rust BFS
18 4Sum Python two_pointers, two_sum
19 Remove Nth Node From End of List Rust sliding_window
20 Valid Parentheses Python stack
21 Merge Two Sorted Lists Rust, Python
22 Generate Parentheses Python backtracking
23 Merge k Sorted Lists Python
24 Swap Nodes in Pairs Rust
26 Remove Duplicates from Sorted Array Rust
27 Remove Element Rust
28 Implement strStr() Rust, Python kmp, dfa
31 Next Permutation Python
33 Search in Rotated Sorted Array Python binary_search
34 Find First and Last Position of Element ... Rust
35 Search Insert Position Rust
36 Valid Sudoku Python
37 Soduku Solver Python
38 Count And Say Rust
39 Combination Sum Python, Rust
40 Combination Sum II Python, Rust
42 Trapping Rain Water Rust
44 Wildcard Matching Python
45 Jump Game II Rust greedy
46 Permutations Rust
47 Permutations II Rust
48 Rotate Image Rust
49 Group Anagrams Rust
50 Pow(x, n) Rust
51 N Queens Python, Rust
52 N Queens II Python, Rust
53 Maximum Subarray Rust
54 Spiral Matrix Rust
55 Jump Game Python greedy, dp
58 Length of Last Word Rust
59 Spiral Matrix II Rust
60 Permutation Sequence Python
62 Unique Paths Rust, Go combination
63 Unique Paths II Python
64 Minimum Path Sum Python
65 Valid Number Rust
66 Plus One Rust
67 Add Binary C++
69 Sqrt(x) Rust
70 Climb Stairs Rust fibonacci
72 Edit Distance Rust
73 Set Matrix Zeroes Rust
74 Search a 2D Matrix Rust
75 Sort Colors Python three_pointers, partition_array
77 Combinations Rust
78 Subsets Rust
79 Word Search Python
81 Search in Rotated Sorted Array II Python binary_search
82 Remove Duplicates from Sorted List II C++
83 Remove Duplicates from Sorted List C++
86 Partition List Rust
88 Merge Sorted Array Rust, Python merge_sort
89 Gray Code Rust
90 Subsets II Python
91 Decode Ways Python
92 Reverse Linked List II Python
93 Restore IP Addresses Rust
94 Binary Tree Inorder Traversal Python DFS, stack
98 Validate Binary Search Tree Rust
99 Recover Binary Search Tree Python
100 Same Tree Rust
102 Binary Tree Level Order Traversal Rust, Python
103 Binary Tree Zigzag Level Order Traversal Rust
104 Maximum Depth of Binary Tree Rust
105 Construct Binary Tree from Preorder and Inorder Traversal Python DFS, stack
106 Construct Binary Tree from Inorder and Postorder Traversal Python DFS
107 Binary Tree Level Order Traversal II Rust
108 Convert Sorted Array to Binary Search Tree Python divide_and_conquer
109 Convert Sorted List to Binary Search Tree Python divide_and_conquer
110 Balanced Binary Tree Python divide_and_conquer
111 Minimum Depth of Binary Tree Python divide_and_conquer, BFS
114 Flatten Binary Tree to Linked List Python
118 Pascals Triangle Python
119 Pascals Triangle II Python
120 Triangle Rust
121 Best Time to Buy and Sell Stock Python
122 Best Time to Buy and Sell Stock II Python
123 Best Time to Buy and Sell Stock III Python
124 Binary Tree Maximum Path Sum Python
125 Valid Palindrome Python two_pointers
126 Word Ladder II Python BFS+DFS
127 Word Ladder Python 双向BFS
128 Longest Consecutive Sequence Python 并查集
129 Sum Root to Leaf Numbers Rust
130 Surrounded Regions Rust
133 Clone Graph Python DFS, BFS
134 Gas Station Rust
135 Candy Rust
136 Single Number Rust
137 Single Number II Rust
138 Copy List with Random Pointer Python
139 Word Break Python 完全背包问题
140 Word Break II Python
141 Linked List Cycle Python
142 Linked List Cycle II Python
144 Binary Tree Preorder Traversal Rust
145 Binary Tree Postorder Traversal Python DFS, stack
146 LRU Cache Python double_linked_list, OrderedDict
147 Insertion Sort List Rust
148 Sort List Rust
150 Evaluate Reverse Polish Notation Rust
151 Reverse Words in a String Rust
153 Find Minimum in Rotated Sorted Array Python binary_search
154 Find Minimum in Rotated Sorted Array II Python binary_search
155 Min Stack Python
160 Intersection of Two Linked Lists Python
164 Maximum Gap Rust
165 Compare Version Numbers Rust
167 Two Sum II - Input array is sorted Python two_pointers
168 Excel Sheet Column Title Rust
169 Majority Element Rust
170🔒 Two Sum III - Data structure design Python two_pointers
171 Excel Sheet Column Number Rust
172 Factorial Trailing Zeroes Rust
173 Binary Search Tree Iterator Python
174 Dungeon Game Rust
175 Combine Two Tables
176 Second Highest Salary SQL
181 Employees Earning More Than Their Managers SQL
182 Duplicate Emails SQL
183 Customers Who Never Order sql
188 Best Time to Buy and Sell Stock IV Python
189 Rotate Array Rust
190 Reverse Bits Rust
191 Number of 1 Bits Rust
198 House Robber Python
200 Number of Islands Python special_data_structure.union_find, DFS, BFS
202 Happy Number Python
203 Remove Linked List Elements Python
204 Count Primes Rust
206 Reverse Linked List Python, Rust
208 Implement Trie (Prefix Tree) Rust
207 Course Schedule same as 210
209 Minimum Size Subarray Sum Python sliding_window
210 Course Schedule II Rust, Python
211 Design Add and Search Words.. Rust
212 Word Search II Python 前缀树
213 House Robber II Python
215 Kth Largest Element in an Array Python quick_select, quick_sort, heap
216 Combination Sum III Rust
217 Contains Duplicate Rust
219 Contains Duplicate II Rust
222 Count Complete Tree Nodes Rust
224 Basic Calculator Rust
225 Implement Stack using Queues Python
226 Invert Binary Tree Rust
227 Basic Calculator II Rust
228 Summary Ranges Rust
230 Kth Smallest Element in a BST Python DFS, stack
231 Power of Two Rust
232 Implement Queue using Stacks Python
234 Palindrome Linked List Rust
235 Lowest Common Ancestor of a Binary Search Tree Python
236 Lowest Common Ancestor of a Binary Tree Python divide_and_conquer
238 Product of Array Except Self Rust
239 Sliding Window Maximum Rust
240 Search a 2D Matrix II Python
242 Valid Anagram Rust
257 Binary Tree Paths Python DFS, backtracking
258 Add Digits Rust
260 Single Number III Rust
263 Ugly Number Rust
264 Ugly Number II Python
266🔒 Palindrome Permutation Python greedy
269🔒 Alien Dictionary Python heapq, topological_sorting
270🔒 Closest Binary Search Tree Value Python
272🔒 Closest Binary Search Tree Value II Python
278 First Bad Version Rust
279 Perfect Squares Rust
283 Move Zeros Rust
287 Find the Duplicate Number Python 快慢双指针
290 Word Pattern Rust
291🔒 Word Pattern II Python DFS
292 Nim Game Rust
295 Find Median from Data Stream Rust
297 Serialize and Deserialize Binary Tree Python serialize
300 Longest Increasing Subsequence Python 接龙型动态规划
302🔒 Smallest Rectangle Enclosing Black Pixels Python
303 Range Sum Query - Immutable Rust
304 Range Sum Query 2D - Immutable Rust
307 Range Sum Query - Mutable Python
309 Best Time to Buy and Sell Stock with Cooldown Python
311🔒 Sparse Matrix Multiplication Rust
312 Burst Balloons Rust
322 Coin Change Rust
326 Power of Three Rust
328 Odd Even Linked List Python
337 House Robber III Python
338 Counting Bits Rust
341 Flatten Nested List Iterator Rust
342 Power of Four Rust
343 Integer Break Python 划分类DP
344 Reverse String Rust
345 Reverse Vowels of a String Rust
347 Top K Frequent Elements Rust
349 Intersection of Two Arrays Python
350 Intersection of Two Arrays II Python
354 Russian Doll Envelopes Python
355 Design Twitter Rust
359🔒 Logger Rate Limiter Rust
367 Valid Perfect Square Rust
368 Largest Divisible Subset Python
369🔒 Plus One Linked List Rust
371❌ Sum of Two Integers Python binary_addition
374 Guess Number Higher Or Lower Rust
377 Combination Sum IV Rust
380 Insert Delete GetRandom O(1) Python
381 Insert Delete GetRandom O(1) - Duplicates allowed Python
383 Ransom Note Rust
386 Lexicographical Numbers Rust
387 First Unique Character in a String Rust
389 Find The Difference Rust
398 Random Pick Index Rust
404 Sum of Left Leaves Rust
406 Queue Reconstruction by Height Rust
409 Longest Palindrome Python dp(greedy)
412 Fizz Buzz Rust
413 Arithmetic Slices Rust
415 Add String C++
416 Partition Equal Subset Sum Python 0-1背包问题
426 Longest Repeating Character Replacement Python
429 N-ary Tree Level Order Traversal C++
448 Find All Numbers Disappeared in an Array Rust
449 Serialize and Deserialize BST Python DFS, stack
451 Sort Characters By Frequency Rust
454 4Sum II Rust
455 Assign Cookies Rust
457 Circular Array Loop Rust
461 Hamming Distance Rust
463 Island Perimeter Rust
470 impl rand10 using rand7 Rust
474 Ones and Zeroes Python 完全背包问题
477 Total Hamming Distance Rust
480 Sliding Window Median Rust
485 Max Consecutive Ones Rust
486 Validate IP Address Rust
490🔒 The Maze Rust
494 Target Sum Python 0-1背包问题
498 Diagonal Traverse Rust
500 Keyboard Row Rust
503 Next Greater Element II Rust
504 Base 7 Rust
507 Perfect Number Rust
509 Fibonacci Number Rust
514 Freedom Trail Rust
515 Find Largest Value... Rust
518 Coin Change 2 Rust
523 Continuous Subarray Sum Rust
525 Contiguous Array Rust
535 Encode and Decode TinyURL very_easy
536🔒 Construct Binary Tree from String Python
538 Convert BST to Greater Tree Python
540 Single Element in a Sorted Array Rust
541 Reverse String II Rust
547 Friend Circles Rust
554 Brick Wall Rust
557 Reverse Words in a String III Rust
559 Maximum Depth of N-ary Tree C++
566 Reshape the Matrix Rust
575 Distribute Candies Rust
589 N-ary Tree Preorder Traversal Python
590 N-ary Tree Postorder Traversal Python
593 Valid Square Rust
595 Big Countries sql
606 Construct String from Binary Tree Python
617 Merge Two Binary Trees Rust
605 Can Place Flowers Rust
610🔒 Triangle Judgement SQL
611 Valid Triangle Number Rust
613🔒 Shortest Distance in a Line SQL
620 Not Boring Movies SQL
625🔒 Minimum Factorization Python greedy
627 Swap Salary SQL
628 Maximum Product of Three Numbers Rust
633 Average of Levels in Binary Tree Python
643 Maximum Average Subarray I Rust
645 Set Mismatch Rust
650 2 Keys Keyboard Rust
653 Tow Sum IV - Input is a BST Python
657 Robot Return to Origin Rust
658 Find K Closest Elements Rust, Python binary_search
661 Image Smoother Rust
669 Trim A Binary Search Tree Python
674 Longest Continuous Increasing Subsequence Python
680 Valid Palindrome II Python two_pointers, greedy
682 Baseball Game Rust
690 Employee Importance java
692 Top K Frequent Words Rust
693 Binary Number With Alternating Bits Rust
695 Max Area of Island Rust
696 Count Binary Substrings Rust
700 Search in a Binary Search Tree Rust
702🔒 Search in a Sorted Array of Unknown Size Python binary_search_first, 倍增法
703 Kth Largest Element in a Stream Rust
704 Binary Search Rust
705 Design HashSet Python
706 Design HashMap Python
709 To Lower Case Rust
713 1-bit and 2-bit Characters Rust
714 Best Time to Buy and Sell Stock with Transaction Fee Python
716🔒 Max Stack Python
724 Find Pivot Index Rust
728 Self Dividing Numbers Rust
743 Network Delay Time Rust
746 Min Cost Climbing Stairs Rust
760🔒 Find Anagram Mappings Rust
763 Partition Labels Rust
766 Toeplitz Matrix Rust
771 Jewels and Stones Rust
787 Cheapest Flights Within K Stops Rust
788 Rotated Digits Rust
796 Rotate String Python Rabin-Karp(rolling_hash), kmp
797 All Paths From Source to Target Rust
807 Max Increase to Keep City Skyline Rust
830 Positions of Large Groups Rust
832 Flipping an Image Rust
841 Keys and Rooms Rust
844 Backspace String Compare Rust
845 Longest Mountain in Array Python mountain_array
852 Peak Index in a Mountain Array Rust
860 Lemonade Change Rust
861 Score After Flipping Matrix Python greedy
867 Transpose Matrix Rust, Go
869 Reordered Power of 2 Python permutation
872 Leaf Similar Trees Rust
875 Koko Eating Bananas Python
876 Middle of the Linked List Rust
877 Stone Game Rust
881 Boats to Save People Rust
887 Super Egg Drop Rust
888 Fair Candy Swap Rust
889 Construct Binary Tree from Preorder and Postorder... Python DFS
905 Sort Array By Parity Rust
912 Sort An Array Python
914 Partition Array Into Disjoint... Rust
922 Sort Array By Parity II Rust
925 Long Pressed Name Rust
930 Binary Subarrays With Sum Rust
938 Range Sum of BST Rust
941 Valid Mountain Array Python mountain_array
942 DI String Match Rust
944 Delete Columns to Make Sorted Rust
950 Reveal Cards In Increasing Order Rust
953 Verifying an Alien Dictionary Python
961 N-Repeated Element in Size 2N Array Rust
965 Univalued Binary Tree Rust
973 K Closest Points to Origin Rust quick_select
976 Largest Perimeter Triangle Rust
977 Squares of a Sorted Array Rust
989 Add to Array-Form of Integer Rust
993 Cousins In Binary Tree Rust
1002 Find Common Characters Rust
1006 Clumsy Factorial Rust
1018 Binary Prefix Divisible By 5 Rust
1030 Matrix Cells in Distance Order Rust
1038 Binary Search Tree to Greater Sum Tree Python
1046 Last Stone Weight Python
1049 Last Stone Weight II Python 0-1背包问题
1051 Height Checker Rust
1068🔒 Product Sales Analysis I SQL
1069🔒 Product Sales Analysis II SQL
1079 Letter Tile Possibilities/ Rust
1089 Duplicate Zeros Rust
1095 Find in Mountain Array Python binary_search, mountain_array
1099🔒 Two Sum Less Than K Python two_pointers
1108 Defanging an IP Address Rust
1128 Number of Equivalent Domino Pairs Rust
1109 Corporate Flight Bookings Rust
1119🔒 Remove Vowels from a String Rust
1134🔒 Armstrong Number Rust
1143 Longest Common Subsequence Python
1160 Find Words That Can Be Formed by Ch... Rust
1167🔒 Minimum Cost To Connect Sticks Rust
1180🔒 Count Substrings with Only One Distinct Letter Rust
1189 Maximum Number of Balloons Rust
1207 Unique Number of Occurrences Rust
1213🔒 Intersection of Three Sorted Arrays Rust
1221 Split a String In.. Rust
1226 The Dining Philosophers C++
1227 Airplane Seat Assignment Probability Rust
1232 Check If It Is a Straight Line Rust
1248 Count Number of Nice Subarrays Rust
1251🔒 Average Selling Price SQL
1252 Cells with Odd Values in a Matrix Rust
1260 Shift 2D Grid Rust
1265🔒 Print Immutable Linked List in Reverse C
1266 Minimum Time Visiting All Points Rust
1269 Number of Ways to Stay in the Same... Rust
1281 Subtract the Product and Sum of Digits... Rust
1282 Group the people... Rust
1295 Find Numbers with Even Number of Digits Rust
1299 Replace Elements with Greatest Element on Right... Rust
1302 Deepest Leaves Sum Rust
1303🔒 Find the Team Size SQL
1313 Decompress Run-Length Encoded List Python
1329 Sort The Matrix Diagonally Rust
1331 Rank Transform Of An Array Rust
1337 The K Weakest Rows in a Matrix Rust
1342 Number of Steps to Reduce a Number to Zero Rust
1346 Check If N and Its Double Exist Rust
1351 Count Negative Numbers in a Sorted Matrix Rust
1356 Sort Integers by The Number of 1 Bits Rust
1365 How Many Numbers Are Smaller Than the Current Number Rust
1370 Increasing Decreasing String Rust
1374 Generate a String With Characters That Have Odd Counts Rust
1379 Find a Corresponding Node of a Binary Tree ... Python
1380 Lucky Numbers in a Matrix Rust
1389 Create Target Array in the Given Order Rust
1395 Count Number of Teams Rust
1403 Minimum Subsequence... Rust
1409 Queries on a Permutation With Key Rust
1418 Display Table Of Food Order.. Rust
1429🔒 First Unique Number Python
1431 Kids With the Greatest Number of Candies Rust
1436 Destination City Rust
1441 Build An Array With Stack Op... Rust
1445🔒 Apples Oranges SQL
1450 Number of Students Doing Homework at ... Rust
1464 Maximum Product of Two Elements in an Array Rust
1470 Shuffle the Array Rust
1475 Final Prices With a Special Discount... Rust
1476 Subrectangle Queries Rust
1480 Running Sum of 1d Array Rust
1486 XOR Operation in an Array Rust, Racket
1502 Can Make Arithmetic Progression From Sequence Rust
1512 Number of Good Pairs Rust
1528 Shuffle String Rust
1534 Count Good Triplets Rust
1551 Minimum Operations to Make Array Equal Rust
1570 Dot Product of Two Sparse Vectors Rust
1572 Matrix Diagonal Sum Rust
1576 Replace All ?'s to Avoid Consecutive ... Rust
1577 Number of Ways Where Square of ... Rust
1578 Minimum Deletion Cost to Avoid Repeating ... Rust
1582 Special Positions in a Binary Matrix Rust
1584 Min Cost to Connect All Points Rust
1588 Sum of All Odd Length Subarrays Rust
1592 Rearrange Spaces Between Words Rust
1598 Crawler Log Folder Rust
1601 Design Parking System Rust
1614 Maximum Nesting Depth of the Parentheses Rust
1619 Mean Of Array... Rust
1636 Sort Array by Increasing Frequency Rust
1637 Widest Vertical Area Between Two Points ... Rust
1640 Check Array Formation Through Concatenation Rust
1641 Count Sorted Vowel... Rust
1646 Get Maximum In Gen... Rust
1656 Design an Ordered Stream Rust
1658 Defuse The Bomb Rust
1662 Check If Two String Arrays are Equivalent Rust
1668 Maximum Repeating Substring Rust
1672 Richest Customer Wealth Rust
1678 Goal Parser Interpretation Rust
1683🔒 Invalid Tweets SQL
1684 Count the Number of Consistent Strings Rust
1688 Count of Matches in Tournament Rust
1694 Reformat Phone Number Rust
1700 Number of Students Unable to Eat Lunch Rust
1704 Determine If String... Rust
1710 Maximum Units on a Truck Rust
1711 Count Good Meals Rust
1716 Calculate Money in Leetcode Bank Rust
1720 Decode XORed Array Rust
1725 Number Of Rectangles That Can ... Rust
1732 Find the Highest Altitude Rust
1736 Latest Time by Replacing ... Rust
1741🔒 Find Total Time Spent by Each Employee SQL
1742 Maximum Number of Ball... Rust
1744 Can You Eat Your Favorite Candy... Rust
1748 Sum of Unique Elements Rust
1752 Check if Array Is Sorted and Rotated Rust
1753 Maximum Score From Removing Stones Rust
1754 Largest Merge Of Two Strings Rust
1773 Count Items Matching a Rule Rust
1779 Find Nearest... Rust
1790 Check if One String Swap Can Make String... Rust
1791 Find Center of Star Graph Rust
1796 Second Largest... Rust
1805 Number Of Diff... Rust
1812 Determine Color... Rust
1816 Truncate Sentence Rust
1822 Sign Of The Product... Rust
1828 Queries on Number of Points Inside a Circle Rust
1832 Check if the Sentence Is Pangram Rust
1833 Maximum Ice Cream Bars Rust
1834 Single Threaded Cpu Rust
1837 Sum of Digits in Base K Rust
1839 Longest Substring Of All Vowels in Order Rust
1844 Replace All Digits with Characters Rust
1845 Seat Reservation Manager Rust
1848 Minimum Distance to the...t Rust
1854 Maximum Population Year Rust
1863 Sum of All Subset XOR Totals Rust
1877 Minimize Maximum Pair... Rust
1880 Check if Word Equals... Rust
1893 Check if All The Integer... Rust
1913 Maximum Product Diff... Rust
1920 Build Array from Permutation Rust
1925 Count Square Sum Triples Rust
1929 Concatenation of Array Rust
1952 Three Divisors Rust
1984 Minimum Difference Between... Rust
1985 Find The Kth Large... Rust
1995 Count Special Quadruplets Rust
2000 Count Special Quadruplets Rust
2011 Find Value Of... Rust
2027 Minimum moves... Rust
2032 Two Out Of Three Rust
2042 Check If Numbers... Rust
2057 Smallest Index With Equal Value Rust
2114 Maximum Number of... Rust
2169 Count Operations to Obtain Zero Rust
2180 Count Integer... Rust
2283 Check If Number... Rust
2299 Strong Password Checker II Rust
2319 Check If Matrix... Rust
2325 Decode The Message Rust
2331 Evaluate Boolean Binary Tree Rust
2335 Minimum Amount of Time to Fill Cups Rust
2341 Maximum number of... Rust
2347 Best Poker Hand Rust
2357 Make Array... Rust
2367 Number Of... Rust
2404 Most Fre... Rust
2413 Smallest Even... Rust
2441 Largest Positive... Rust
2455 Average... Rust
2469 Convert The... Rust
2490 Circular Sentence Rust
2600 K Items... Rust

剑指Offer(lcof) && LCP(Leetcode Competition Programing)

# Title Solutions Category
LCP.7 传递信息Rust
59 队列的最大值 Python
60 n个骰子的点数 Python
61 扑克牌中的顺子 Python
62 圆圈中最后剩下的数字 Python 约瑟夫环

# Title Solutions Category
1 A + B Problem leetcode_372
3 Digit Counts Python
5 Kth Largest Element Python quick_select, heap
20 Dices Sum Python
31 Partition Array Python two_pointers
40 Implement Queue by Two Stacks Python
52 Next Permutation Python
76 Longest Increasing Subsequence Python 接龙型动态规划
77 Longest Common Subsequence Python
79 Longest Common Substring Python
80 Median Python quick_select
86 Binary Search Tree Iterator Python
88 Lowest Common Ancestor of a Binary Tree Python divide_and_conquer
90 k Sum II Python
92 Backpack Python
93 Balanced Binary Tree Python divide_and_conquer
95 Validate Binary Search Tree Python
105 Copy List with Random Pointer Python
106 Convert Sorted List to Binary Search Tree Python divide_and_conquer
107 Word Break Python 完全背包问题
110 Minimum Path Sum Python
124 Longest Consecutive Sequence Python 并查集
125 Backpack II Python
127 Topological Sorting Python BFS, topological_sorting
128 Hash Function Python
129 Rehashing Python
135 Combination Sum Python, Rust
137 Clone Graph Python DFS, BFS
138 Subarray Sum Python
143 Sort Colors II Python quick_sort, counting_sort
144 interleaving_positive_and_negative_numbers Python
147🔒 Narcissistic Number Python
148 Sort Colors Python three_pointers, partition_array
153 Combination Sum II Python, Rust
160 Find Minimum in Rotated Sorted Array II Python binary_search
161 Rotate Image Rust
168 Burst Balloons Python
171 Anagrams Python
177 Convert Sorted Array to Binary Search Tree With Minimal Height Python divide_and_conquer
183 Wood Cut Python greedy
190 Next Permutation II Python
192 Wildcard Matching Python
197 Permutation Index Python
235 Prime Factorization Python 分解质因数
249 Count of Smaller Number before itself Python sqrt_n
254 Drop Eggs Python sqrt_n
272🔒 Climbing Stairs II Python
376 Binary Tree Path Sum Python DFS, backtracking
380 Intersection of Two Linked Lists Python
386 Longest Substring with At Most K Distinct Characters Python
388 Permutation Sequence Python
393 Best Time to Buy and Sell Stock IV Python
397 Longest Continuous Increasing Subsequence Python
406 Minimum Size Subarray Sum Python sliding_window
415 Valid Palindrome Python two_pointers
437 Copy Books Python dp, binary_search
440🔒 Backpack III Python
443🔒 Two Sum - Greater than target Python two_pointers
447🔒 Search in a Big Sorted Array Python binary_search_first, 倍增法
453 Flatten Binary Tree to Linked List Python
461 Kth Smallest Numbers in Unsorted Array Python
464 Sort Integers II Python
466 Count Linked List Nodes too_easy
474🔒 Lowest Common Ancestor II Python
476 Stone Game(diff to leetcode) Python
480 Binary Tree Paths Python DFS, backtracking
486 Merge K Sorted Arrays Python
492 Implement Queue by Linked List Python
494 Implement Stack by Two Queues Python
495 Implement Stack Python
512 Decode Ways Python
521🔒 Remove Duplicate Numbers in Array Python partition_array
533🔒 Two Sum - Closest to target Python two_sum
544 Top k Largest Numbers Python min_heap
545 Top k Largest Numbers II Python min_heap
547 Intersection of Two Arrays Python
548 Intersection of Two Arrays II Python
562 Backpack IV Python 完全背包问题
563 Backpack V Python
577 Merge k Sorted Interval Lists Python
578 Lowest Common Ancestor III Python
584 Drop Eggs II Rust dp
587🔒 Two Sum - Unique pairs Python two_sum
588 Partition Equal Subset Sum Python 0-1背包问题
594 Implement strStr() II Python kmp, Rabin-Karp(rolling_hash)
596🔒 Minimum Subtree Python divide_and_conquer
600 Smallest Rectangle Enclosing Black Pixels Python
603 Largest Divisible Subset Python
606 Kth Largest Element II Python quick_select, quick_sort, heap
607 Two Sum III - Data structure design Python two_pointers
608 Two Sum II - Input array is sorted Python two_pointers
609 Two Sum - Less than or equal to target Python two_pointers
610 Two Sum - Difference equals to target Python two_pointers
611🔒 Knight Shortest Path Python bfs
627 Longest Palindromic Combination Python greedy
628 Maximum Subtree Python divide_and_conquer
630🔒 Knight Shortest Path II Python bfs
633 Find the Duplicate Number Python 快慢双指针
657 Insert Delete GetRandom O(1) Python
661 Convert BST to Greater Tree Python
667 Longest Palindromic Subsequence Python dp(greedy)
683 Word Break III Python
685 First Unique Number in Data Stream Python
691 Recover Binary Search Tree Python
701 Trim A Binary Search Tree Python
702 Russian Doll Envelopes Python
719 Calculate Maximum Value Python
724 Minimum Partition Python 0-1背包问题
741 Calculate Maximum Value II Python
749 John's backyard garden Python
793 Intersection of Arrays Python
802 Soduku Solver Python
816 Traveling Salesman Problem Python
839 Merge Two Sorted Interval Lists Python
841 String Replace Python
845 Greatest Common Divisor Python
859 Max Stack Python
871 Minimum Factorization Python greedy
891 Valid Palindrome II Python two_pointers, greedy
892 Alien Dictionary Python heapq, topological_sorting
900 Closest Binary Search Tree Value Python
901 Closest Binary Search Tree Value II Python
902 Kth Smallest Element in a BST Python DFS, stack
954 Insert Delete GetRandom O(1) - Duplicates allowed Python
995 Best Time ... Stock with Cooldown Python
1147 Work Plan Python
1208 Target Sum Python 0-1背包问题
1276 Sum of Two Integers Python binary_addition
1284 Integer Break Python 划分类DP
1311 Lowest Common Ancestor of a Binary Search Tree Python
1343 Sum of Two Strings Python
1359 Convert Sorted Array to Binary Search Tree Python divide_and_conquer
1375 Substring With At Least K Distinct Characters Python
1479 Can Reach The Endpoint Python bfs
1499 Reordered Power of 2 Python permutation
1508 Score After Flipping Matrix Python greedy
1790🔒 Rotate String II Python reverse, circle_shift
1870 number of substrings with all zeroes Python

todo_dp:

  • 划分型动态规划:戳气球、石子归并(dp/stone_game_merge.py)
  • 选或不选类DP: 打家劫舍系列/股票买卖系列
  • 计数型动态规划: k sum
  • 43/415 字符串整数相乘/相加
  • 415是经典面试题利用字符串模拟竖式加法进行大数相加
  • 有兴趣但是困难级别的题: 1. 推箱子 2. 华容道
  • [ ]最大直方图矩阵(Longest Histogram Rectangle), 单调栈O(n^3)->O(n)

some awesome leetcode rust solutions repos

other awesome leetcode repos I recommend

About

leetcode/codeforces Rust solution with unittest, leetcode-rust and codeforces-rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages