leetcode
This page documents my attempts at solving LeetCode problems using Rust. It’s synced weekly through leech; I keep only the latest submission for each problem, and to keep things simple I write the solution intuition directly as a comment in the code. I aim to craft each solution in the most elegant and idiomatic Rust I can manage after studying others’ approaches, though LeetCode doesn’t always make that easy.
problems
- 0001 - Two Sum
- 0002 - Add Two Numbers
- 0009 - Palindrome Number
- 0011 - Container With Most Water
- 0014 - Longest Common Prefix
- 0020 - Valid Parentheses
- 0021 - Merge Two Sorted Lists
- 0022 - Generate Parentheses
- 0023 - Merge k Sorted Lists
- 0026 - Remove Duplicates from Sorted Array
- 0027 - Remove Element
- 0035 - Search Insert Position
- 0041 - First Missing Positive
- 0042 - Trapping Rain Water
- 0045 - Jump Game II
- 0048 - Rotate Image
- 0053 - Maximum Subarray
- 0055 - Jump Game
- 0056 - Merge Intervals
- 0058 - Length of Last Word
- 0069 - Sqrt(x)
- 0070 - Climbing Stairs
- 0072 - Edit Distance
- 0083 - Remove Duplicates from Sorted List
- 0088 - Merge Sorted Array
- 0100 - Same Tree
- 0101 - Symmetric Tree
- 0102 - Binary Tree Level Order Traversal
- 0103 - Binary Tree Zigzag Level Order Traversal
- 0104 - Maximum Depth of Binary Tree
- 0112 - Path Sum
- 0118 - Pascal's Triangle
- 0121 - Best Time to Buy and Sell Stock
- 0122 - Best Time to Buy and Sell Stock II
- 0125 - Valid Palindrome
- 0136 - Single Number
- 0137 - Single Number II
- 0169 - Majority Element
- 0190 - Reverse Bits
- 0191 - Number of 1 Bits
- 0258 - Add Digits
- 0260 - Single Number III
- 0309 - Best Time to Buy and Sell Stock with Cooldown
- 0396 - Rotate Function
- 0406 - Queue Reconstruction by Height
- 0502 - IPO
- 0575 - Distribute Candies
- 0637 - Average of Levels in Binary Tree
- 0680 - Valid Palindrome II
- 0717 - 1-bit and 2-bit Characters
- 0740 - Delete and Earn
- 0763 - Partition Labels
- 0877 - Stone Game
- 0957 - Prison Cells After N Days
- 0965 - Univalued Binary Tree
- 0976 - Largest Perimeter Triangle
- 1015 - Smallest Integer Divisible by K
- 1018 - Binary Prefix Divisible By 5
- 1091 - Shortest Path in Binary Matrix
- 1221 - Split a String in Balanced Strings
- 1262 - Greatest Sum Divisible by Three
- 1304 - Find N Unique Integers Sum up to Zero
- 1342 - Number of Steps to Reduce a Number to Zero
- 1437 - Check If All 1's Are at Least Length K Places Away
- 1488 - Avoid Flood in The City
- 1513 - Number of Substrings With Only 1s
- 1518 - Water Bottles
- 1526 - Minimum Number of Increments on Subarrays to Form a Target Array
- 1550 - Three Consecutive Odds
- 1578 - Minimum Time to Make Rope Colorful
- 1689 - Partitioning Into Minimum Number Of Deci-Binary Numbers
- 1716 - Calculate Money in Leetcode Bank
- 1720 - Decode XORed Array
- 1759 - Count Number of Homogenous Substrings
- 1898 - Maximum Number of Removable Characters
- 1935 - Maximum Number of Words You Can Type
- 2037 - Minimum Number of Moves to Seat Everyone
- 2053 - Kth Distinct String in an Array
- 2125 - Number of Laser Beams in a Bank
- 2154 - Keep Multiplying Found Values by Two
- 2169 - Count Operations to Obtain Zero
- 2275 - Largest Combination With Bitwise AND Greater Than Zero
- 2300 - Successful Pairs of Spells and Potions
- 2315 - Count Asterisks
- 2554 - Maximum Number of Integers to Choose From a Range I
- 2578 - Split With Minimum Sum
- 2611 - Mice and Cheese
- 2696 - Minimum String Length After Removing Substrings
- 2894 - Divisible and Non-divisible Sums Difference
- 2942 - Find Words Containing Character
- 3101 - Count Alternating Subarrays
- 3147 - Taking Maximum Energy From the Mystic Dungeon
- 3190 - Find Minimum Operations to Make All Elements Divisible by Three
- 3217 - Delete Nodes From Linked List Present in Array
- 3318 - Find X-Sum of All K-Long Subarrays I
- 3370 - Smallest Number With All Set Bits
- 3423 - Maximum Difference Between Adjacent Elements in a Circular Array
- 3432 - Count Partitions with Even Sum Difference
- 3461 - Check If Digits Are Equal in String After Operations I
- 3658 - GCD of Odd and Even Sums
- 3693 - Climbing Stairs II