leetcode
This page is an attempt to solve leetcode problems with Rust. The whole page is synced per day with my personal fork of leetcode-sync, note we only kept the latest submission, and to simplify the process, I write the intuition as comment in submissions.
I tries to write the solution in the most elegant and idiomatic way as possible after referring to others’ solutions, although sometimes leetcode doesn’t make it easy.
problems
- 0001 - Two Sum
- 0002 - Add Two Numbers
- 0003 - Longest Substring Without Repeating Characters
- 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
- 0028 - Find the Index of the First Occurrence in a String
- 0034 - Find First and Last Position of Element in Sorted Array
- 0035 - Search Insert Position
- 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
- 0637 - Average of Levels in Binary Tree
- 0680 - Valid Palindrome II
- 0763 - Partition Labels
- 0957 - Prison Cells After N Days
- 0976 - Largest Perimeter Triangle
- 1024 - Video Stitching
- 1091 - Shortest Path in Binary Matrix
- 1221 - Split a String in Balanced Strings
- 1304 - Find N Unique Integers Sum up to Zero
- 1317 - Convert Integer to the Sum of Two No-Zero Integers
- 1342 - Number of Steps to Reduce a Number to Zero
- 1381 - Design a Stack With Increment Operation
- 1488 - Avoid Flood in The City
- 1513 - Number of Substrings With Only 1s
- 1518 - Water Bottles
- 1525 - Number of Good Ways to Split a String
- 1526 - Minimum Number of Increments on Subarrays to Form a Target Array
- 1550 - Three Consecutive Odds
- 1578 - Minimum Time to Make Rope Colorful
- 1614 - Maximum Nesting Depth of the Parentheses
- 1689 - Partitioning Into Minimum Number Of Deci-Binary Numbers
- 1716 - Calculate Money in Leetcode Bank
- 1876 - Substrings of Size Three with Distinct Characters
- 1898 - Maximum Number of Removable Characters
- 1935 - Maximum Number of Words You Can Type
- 1962 - Remove Stones to Minimize the Total
- 2011 - Final Value of Variable After Performing Operations
- 2043 - Simple Bank System
- 2053 - Kth Distinct String in an Array
- 2125 - Number of Laser Beams in a Bank
- 2169 - Count Operations to Obtain Zero
- 2257 - Count Unguarded Cells in the Grid
- 2275 - Largest Combination With Bitwise AND Greater Than Zero
- 2295 - Replace Elements in an Array
- 2300 - Successful Pairs of Spells and Potions
- 2315 - Count Asterisks
- 2566 - Maximum Difference by Remapping a Digit
- 2578 - Split With Minimum Sum
- 2894 - Divisible and Non-divisible Sums Difference
- 2942 - Find Words Containing Character
- 3100 - Water Bottles II
- 3101 - Count Alternating Subarrays
- 3147 - Taking Maximum Energy From the Mystic Dungeon
- 3217 - Delete Nodes From Linked List Present in Array
- 3228 - Maximum Number of Operations to Move Ones to the End
- 3289 - The Two Sneaky Numbers of Digitville
- 3318 - Find X-Sum of All K-Long Subarrays I
- 3354 - Make Array Elements Equal to Zero
- 3370 - Smallest Number With All Set Bits
- 3423 - Maximum Difference Between Adjacent Elements in a Circular Array
- 3461 - Check If Digits Are Equal in String After Operations I
- 3516 - Find Closest Person
- 3612 - Process String with Special Operations I
- 3622 - Check Divisibility by Digit Sum and Product
- 3693 - Climbing Stairs II