Skip to content

Over 500 solved problems with test cases and all common structures from https://leetcode.com on Ruby

Notifications You must be signed in to change notification settings

fartem/leetcode-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

leetcode-ruby

About

Some solved problems from LeetCode on Ruby.

Links

Profile on LeetCode: fartem.

Solutions

Easy

Name Link to LeetCode Link to solution Link to tests
1. Two Sum Link Link Link
9. Palindrome Number Link Link Link
13. Roman to Integer Link Link Link
14. Longest Common Prefix Link Link Link
20. Valid Parentheses Link Link Link
21. Merge Two Sorted Lists Link Link Link
26. Remove Duplicates from Sorted Array Link Link Link
27. Remove Element Link Link Link
28. Find the Index of the First Occurrence in a String Link Link Link
35. Search Insert Position Link Link Link
58. Length of Last Word Link Link Link
66. Plus One Link Link Link
67. Add Binary Link Link Link
69. Sqrt(x) Link Link Link
70. Climbing Stairs Link Link Link
83. Remove Duplicates from Sorted List Link Link Link
88. Merge Sorted Array Link Link Link
94. Binary Tree Inorder Traversal Link Link Link
100. Same Tree Link Link Link
101. Symmetric Tree Link Link Link
104. Maximum Depth of Binary Tree Link Link Link
108. Convert Sorted Array to Binary Search Tree Link Link Link
110. Balanced Binary Tree Link Link Link
111. Minimum Depth of Binary Tree Link Link Link
112. Path Sum Link Link Link
118. Pascal's Triangle Link Link Link
119. Pascal's Triangle II Link Link Link
121. Best Time to Buy and Sell Stock Link Link Link
125. Valid Palindrome Link Link Link
136. Single Number Link Link Link
141. Linked List Cycle Link Link Link
144. Binary Tree Preorder Traversal Link Link Link
145. Binary Tree Postorder Traversal Link Link Link
160. Intersection of Two Linked Lists Link Link Link
168. Excel Sheet Column Title Link Link Link
169. Majority Element Link Link Link
171. Excel Sheet Column Number Link Link Link
190. Reverse Bits Link Link Link
191. Number of 1 Bits Link Link Link
202. Happy Number Link Link Link
203. Remove Linked List Elements Link Link Link
205. Isomorphic Strings Link Link Link
206. Reverse Linked List Link Link Link
217. Contains Duplicate Link Link Link
219. Contains Duplicate II Link Link Link
225. Implement Stack using Queues Link Link Link
226. Invert Binary Tree Link Link Link
228. Summary Ranges Link Link Link
231. Power of Two Link Link Link
232. Implement Queue using Stacks Link Link Link
234. Palindrome Linked List Link Link Link
242. Valid Anagram Link Link Link
257. Binary Tree Paths Link Link Link
258. Add Digits Link Link Link
263. Ugly Number Link Link Link
268. Missing Number Link Link Link
278. First Bad Version Link Link Link
283. Move Zeroes Link Link Link
290. Word Pattern Link Link Link
292. Nim Game Link Link Link
303. Range Sum Query - Immutable Link Link Link
326. Power of Three Link Link Link
338. Counting Bits Link Link Link
342. Power of Four Link Link Link
344. Reverse String Link Link Link
345. Reverse Vowels of a String Link Link Link
349. Intersection of Two Arrays Link Link Link
350. Intersection of Two Arrays II Link Link Link
367. Valid Perfect Square Link Link Link
374. Guess Number Higher or Lower Link Link Link
383. Ransom Note Link Link Link
387. First Unique Character in a String Link Link Link
389. Find the Difference Link Link Link
392. Is Subsequence Link Link Link
404. Sum of Left Leaves Link Link Link
405. Convert a Number to Hexadecimal Link Link Link
409. Longest Palindrome Link Link Link
412. Fizz Buzz Link Link Link
414. Third Maximum Number Link Link Link
415. Add Strings Link Link Link
434. Number of Segments in a String Link Link Link
441. Arranging Coins Link Link Link
448. Find All Numbers Disappeared in an Array Link Link Link
455. Assign Cookies Link Link Link
459. Repeated Substring Pattern Link Link Link
461. Hamming Distance Link Link Link
463. Island Perimeter Link Link Link
476. Number Complement Link Link Link
482. License Key Formatting Link Link Link
485. Max Consecutive Ones Link Link Link
492. Construct the Rectangle Link Link Link
496. Next Greater Element I Link Link Link
500. Keyboard Row Link Link Link
501. Find Mode in Binary Search Tree Link Link Link
504. Base 7 Link Link Link
506. Relative Ranks Link Link Link
507. Perfect Number Link Link Link
509. Fibonacci Number Link Link Link
520. Detect Capital Link Link Link
521. Longest Uncommon Subsequence I Link Link Link
530. Minimum Absolute Difference in BST Link Link Link
543. Diameter of Binary Tree Link Link Link
551. Student Attendance Record I Link Link Link
557. Reverse Words in a String III Link Link Link
559. Maximum Depth of N-ary Tree Link Link Link
561. Array Partition Link Link Link
563. Binary Tree Tilt Link Link Link
566. Reshape the Matrix Link Link Link
572. Subtree of Another Tree Link Link Link
589. N-ary Tree Preorder Traversal Link Link Link
590. N-ary Tree Postorder Traversal Link Link Link
594. Longest Harmonious Subsequence Link Link Link
599. Minimum Index Sum of Two Lists Link Link Link
606. Construct String from Binary Tree Link Link Link
617. Merge Two Binary Trees Link Link Link
628. Maximum Product of Three Numbers Link Link Link
637. Average of Levels in Binary Tree Link Link Link
643. Maximum Average Subarray I Link Link Link
645. Set Mismatch Link Link Link
653. Two Sum IV - Input is a BST Link Link Link
657. Robot Return to Origin Link Link Link
671. Second Minimum Node In a Binary Tree Link Link Link
674. Longest Continuous Increasing Subsequence Link Link Link
680. Valid Palindrome II Link Link Link
682. Baseball Game Link Link Link
693. Binary Number with Alternating Bits Link Link Link
700. Search in a Binary Search Tree Link Link Link
703. Kth Largest Element in a Stream Link Link Link
704. Binary Search Link Link Link
705. Design HashSet Link Link Link
706. Design HashMap Link Link Link
709. To Lower Case Link Link Link
717. 1-bit and 2-bit Characters Link Link Link
724. Find Pivot Index Link Link Link
728. Self Dividing Numbers Link Link Link
733. Flood Fill Link Link Link
744. Find Smallest Letter Greater Than Target Link Link Link
746. Min Cost Climbing Stairs Link Link Link
747. Largest Number At Least Twice of Others Link Link Link
762. Prime Number of Set Bits in Binary Representation Link Link Link
766. Toeplitz Matrix Link Link Link
771. Jewels and Stones Link Link Link
783. Minimum Distance Between BST Nodes Link Link Link
796. Rotate String Link Link Link
804. Unique Morse Code Words Link Link Link
806. Number of Lines To Write String Link Link Link
812. Largest Triangle Area Link Link Link
819. Most Common Word Link Link Link
821. Shortest Distance to a Character Link Link Link
830. Positions of Large Groups Link Link Link
832. Flipping an Image Link Link Link
844. Backspace String Compare Link Link Link
859. Buddy Strings Link Link Link
860. Lemonade Change Link Link Link
867. Transpose Matrix Link Link Link
868. Binary Gap Link Link Link
872. Leaf-Similar Trees Link Link Link
876. Middle of the Linked List Link Link Link
884. Uncommon Words from Two Sentences Link Link Link
896. Monotonic Array Link Link Link
897. Increasing Order Search Tree Link Link Link
905. Sort Array By Parity Link Link Link
908. Smallest Range I Link Link Link
917. Reverse Only Letters Link Link Link
922. Sort Array By Parity II Link Link Link
925. Long Pressed Name Link Link Link
929. Unique Email Addresses Link Link Link
933. Number of Recent Calls Link Link Link
938. Range Sum of BST Link Link Link
941. Valid Mountain Array Link Link Link
942. DI String Match Link Link Link
944. Delete Columns to Make Sorted Link Link Link
953. Verifying an Alien Dictionary Link Link Link
961. N-Repeated Element in Size 2N Array Link Link Link
965. Univalued Binary Tree Link Link Link
976. Largest Perimeter Triangle Link Link Link
977. Squares of a Sorted Array Link Link Link
989. Add to Array-Form of Integer Link Link Link
993. Cousins in Binary Tree Link Link Link
997. Find the Town Judge Link Link Link
1002. Find Common Characters Link Link Link
1005. Maximize Sum Of Array After K Negations Link Link Link
1009. Complement of Base 10 Integer Link Link Link
1018. Binary Prefix Divisible By 5 Link Link Link
1021. Remove Outermost Parentheses Link Link Link
1022. Sum of Root To Leaf Binary Numbers Link Link Link
1025. Divisor Game Link Link Link
1046. Last Stone Weight Link Link Link
1047. Remove All Adjacent Duplicates In String Link Link Link
1051. Height Checker Link Link Link
1071. Greatest Common Divisor of Strings Link Link Link
1078. Occurrences After Bigram Link Link Link
1089. Duplicate Zeros Link Link Link
1103. Distribute Candies to People Link Link Link
1108. Defanging an IP Address Link Link Link
1137. N-th Tribonacci Number Link Link Link
1154. Day of the Year Link Link Link
1160. Find Words That Can Be Formed by Characters Link Link Link
1184. Distance Between Bus Stops Link Link Link
1185. Day of the Week Link Link Link
1189. Maximum Number of Balloons Link Link Link
1200. Minimum Absolute Difference Link Link Link
1207. Unique Number of Occurrences Link Link Link
1217. Minimum Cost to Move Chips to The Same Position Link Link Link
1221. Split a String in Balanced Strings Link Link Link
1232. Check If It Is a Straight Line Link Link Link
1252. Cells with Odd Values in a Matrix Link Link Link
1266. Minimum Time Visiting All Points Link Link Link
1275. Find Winner on a Tic Tac Toe Game Link Link Link
1281. Subtract the Product and Sum of Digits of an Integer Link Link Link
1287. Element Appearing More Than 25% In Sorted Array Link Link Link
1290. Convert Binary Number in a Linked List to Integer Link Link Link
1295. Find Numbers with Even Number of Digits Link Link Link
1299. Replace Elements with Greatest Element on Right Side Link Link Link
1304. Find N Unique Integers Sum up to Zero Link Link Link
1309. Decrypt String from Alphabet to Integer Mapping Link Link Link
1313. Decompress Run-Length Encoded List Link Link Link
1317. Convert Integer to the Sum of Two No-Zero Integers Link Link Link
1323. Maximum 69 Number Link Link Link
1332. Remove Palindromic Subsequences Link Link Link
1337. The K Weakest Rows in a Matrix Link Link Link
1342. Number of Steps to Reduce a Number to Zero Link Link Link
1346. Check If N and Its Double Exist Link Link Link
1351. Count Negative Numbers in a Sorted Matrix Link Link Link
1356. Sort Integers by The Number of 1 Bits Link Link Link
1360. Number of Days Between Two Dates Link Link Link
1365. How Many Numbers Are Smaller Than the Current Number Link Link Link
1370. Increasing Decreasing String Link Link Link
1374. Generate a String With Characters That Have Odd Counts Link Link Link
1385. Find the Distance Value Between Two Arrays Link Link Link
1389. Create Target Array in the Given Order Link Link Link
1399. Count Largest Group Link Link Link
1403. Minimum Subsequence in Non-Increasing Order Link Link Link
1408. String Matching in an Array Link Link Link
1413. Minimum Value to Get Positive Step by Step Sum Link Link Link
1417. Reformat The String Link Link Link
1422. Maximum Score After Splitting a String Link Link Link
1431. Kids With the Greatest Number of Candies Link Link Link
1436. Destination City Link Link Link
1437. Check If All 1's Are at Least Length K Places Away Link Link Link
1446. Consecutive Characters Link Link Link
1450. Number of Students Doing Homework at a Given Time Link Link Link
1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence Link Link Link
1460. Make Two Arrays Equal by Reversing Subarrays Link Link Link
1464. Maximum Product of Two Elements in an Array Link Link Link
1470. Shuffle the Array Link Link Link
1475. Final Prices With a Special Discount in a Shop Link Link Link
1480. Running Sum of 1d Array Link Link Link
1486. XOR Operation in an Array Link Link Link
1491. Average Salary Excluding the Minimum and Maximum Salary Link Link Link
1496. Path Crossing Link Link Link
1502. Can Make Arithmetic Progression From Sequence Link Link Link
1507. Reformat Date Link Link Link
1512. Number of Good Pairs Link Link Link
1518. Water Bottle Link Link Link
1523. Count Odd Numbers in an Interval Range Link Link Link
1528. Shuffle String Link Link Link
1534. Count Good Triplets Link Link Link
1539. Kth Missing Positive Number Link Link Link
1544. Make The String Great Link Link Link
1550. Three Consecutive Odds Link Link Link
1556. Thousand Separator Link Link Link
1566. Detect Pattern of Length M Repeated K or More Times Link Link Link
1572. Matrix Diagonal Sum Link Link Link
1576. Replace All ?'s to Avoid Consecutive Repeating Characters Link Link Link
1582. Special Positions in a Binary Matrix Link Link Link
1588. Sum of All Odd Length Subarrays Link Link Link
1592. Rearrange Spaces Between Words Link Link Link
1598. Crawler Log Folder Link Link Link
1603. Design Parking System Link Link Link
1608. Special Array With X Elements Greater Than or Equal X Link Link Link
1614. Maximum Nesting Depth of the Parentheses Link Link Link
1619. Mean of Array After Removing Some Elements Link Link Link
1624. Largest Substring Between Two Equal Characters Link Link Link
1629. Slowest Key Link Link Link
1636. Sort Array by Increasing Frequency Link Link Link
1646. Get Maximum in Generated Array Link Link Link
1652. Defuse the Bomb Link Link Link
1662. Check If Two String Arrays are Equivalent Link Link Link
1668. Maximum Repeating Substring Link Link Link
1672. Richest Customer Wealth Link Link Link
1678. Goal Parser Interpretation Link Link Link
1684. Count the Number of Consistent Strings Link Link Link
1688. Count of Matches in Tournament Link Link Link
1694. Reformat Phone Number Link Link Link
1700. Number of Students Unable to Eat Lunch Link Link Link
1704. Determine if String Halves Are Alike Link Link Link
1710. Maximum Units on a Truck Link Link Link
1716. Calculate Money in Leetcode Bank Link Link Link
1720. Decode XORed Array Link Link Link
1725. Number Of Rectangles That Can Form The Largest Square Link Link Link
1732. Find the Highest Altitude Link Link Link
1736. Latest Time by Replacing Hidden Digits Link Link Link
1748. Sum of Unique Elements Link Link Link
1752. Check if Array Is Sorted and Rotated Link Link Link
1768. Merge Strings Alternately Link Link Link
1773. Count Items Matching a Rule Link Link Link
1779. Find Nearest Point That Has the Same X or Y Coordinate Link Link Link
1784. Check if Binary String Has at Most One Segment of Ones Link Link Link
1790. Check if One String Swap Can Make Strings Equal Link Link Link
1791. Find Center of Star Graph Link Link Link
1796. Second Largest Digit in a String Link Link Link
1800. Maximum Ascending Subarray Sum Link Link Link
1805. Number of Different Integers in a String Link Link Link
1812. Determine Color of a Chessboard Square Link Link Link
1816. Truncate Sentence Link Link Link
1822. Sign of the Product of an Array Link Link Link
1827. Minimum Operations to Make the Array Increasing Link Link Link
1832. Check if the Sentence Is Pangram Link Link Link
1837. Sum of Digits in Base K Link Link Link
1844. Replace All Digits with Characters Link Link Link
1848. Minimum Distance to the Target Element Link Link Link
1859. Sorting the Sentence Link Link Link
1863. Sum of All Subset XOR Totals Link Link Link
1869. Longer Contiguous Segments of Ones than Zeros Link Link Link
1876. Substrings of Size Three with Distinct Characters Link Link Link
1880. Check if Word Equals Summation of Two Words Link Link Link
1886. Determine Whether Matrix Can Be Obtained By Rotation Link Link Link
1893. Check if All the Integers in a Range Are Covered Link Link Link
1897. Redistribute Characters to Make All Strings Equal Link Link Link
1903. Largest Odd Number in String Link Link Link
1909. Remove One Element to Make the Array Strictly Increasing Link Link Link
1913. Maximum Product Difference Between Two Pairs Link Link Link
1920. Build Array from Permutation Link Link Link
1925. Count Square Sum Triples Link Link Link
1929. Concatenation of Array Link Link Link
1935. Maximum Number of Words You Can Type Link Link Link
1941. Check if All Characters Have Equal Number of Occurrences Link Link Link
1952. Three Divisors Link Link Link
1957. Delete Characters to Make Fancy String Link Link Link
1961. Check If String Is a Prefix of Array Link Link Link
1967. Number of Strings That Appear as Substrings in Word Link Link Link
1971. Find if Path Exists in Graph Link Link Link
1974. Minimum Time to Type Word Using Special Typewriter Link Link Link
1979. Find Greatest Common Divisor of Array Link Link Link
1984. Minimum Difference Between Highest and Lowest of K Scores Link Link Link
1991. Find the Middle Index in Array Link Link Link
1995. Count Special Quadruplets Link Link Link
2000. Reverse Prefix of Word Link Link Link
2006. Count Number of Pairs With Absolute Difference K Link Link Link
2011. Final Value of Variable After Performing Operations Link Link Link
2016. Maximum Difference Between Increasing Elements Link Link Link
2022. Convert 1D Array Into 2D Array Link Link Link
2027. Minimum Moves to Convert String Link Link Link
2032. Two Out of Three Link Link Link
2037. Minimum Number of Moves to Seat Everyone Link Link Link
2042. Check if Numbers Are Ascending in a Sentence Link Link Link
2047. Number of Valid Words in a Sentence Link Link Link
2053. Kth Distinct String in an Array Link Link Link
2057. Smallest Index With Equal Value Link Link Link
2062. Count Vowel Substrings of a String Link Link Link
2068. Check Whether Two Strings are Almost Equivalent Link Link Link
2073. Time Needed to Buy Tickets Link Link Link
2078. Two Furthest Houses With Different Colors Link Link Link
2085. Count Common Words With One Occurrence Link Link Link
2089. Find Target Indices After Sorting Array Link Link Link
2094. Finding 3-Digit Even Numbers Link Link Link
2099. Find Subsequence of Length K With the Largest Sum Link Link Link
2103. Rings and Rods Link Link Link
2108. Find First Palindromic String in the Array Link Link Link
2114. Maximum Number of Words Found in Sentences Link Link Link
2119. A Number After a Double Reversal Link Link Link
2124. Check if All A's Appears Before All B's Link Link Link
2129. Capitalize the Title Link Link Link
2133. Check if Every Row and Column Contains All Numbers Link Link Link
2138. Divide a String Into Groups of Size k Link Link Link
2148. Count Elements With Strictly Smaller and Greater Elements Link Link Link
2154. Keep Multiplying Found Values by Two Link Link Link
2160. Minimum Sum of Four Digit Number After Splitting Digits Link Link Link
2164. Sort Even and Odd Indices Independently Link Link Link
2169. Count Operations to Obtain Zero Link Link Link
2176. Count Equal and Divisible Pairs in an Array Link Link Link
2180. Count Integers With Even Digit Sum Link Link Link
2185. Counting Words With a Given Prefix Link Link Link
2190. Most Frequent Number Following Key In an Array Link Link Link
2194. Cells in a Range on an Excel Sheet Link Link Link
2206. Divide Array Into Equal Pairs Link Link Link
2210. Count Hills and Valleys in an Array Link Link Link
2215. Find the Difference of Two Arrays Link Link Link
2220. Minimum Bit Flips to Convert Number Link Link Link
2231. Largest Number After Digit Swaps by Parity Link Link Link
2235. Add Two Integers Link Link Link
2236. Root Equals Sum of Children Link Link Link
2239. Find Closest Number to Zero Link Link Link
2243. Calculate Digit Sum of a String Link Link Link
2248. Intersection of Multiple Arrays Link Link Link
2255. Count Prefixes of a Given String Link Link Link
2259. Remove Digit From Number to Maximize Result Link Link Link
2264. Largest 3-Same-Digit Number in String Link Link Link
2278. Percentage of Letter in String Link Link Link
2283. Check if Number Has Equal Digit Count and Digit Value Link Link Link
2287. Rearrange Characters to Make Target String Link Link Link
2293. Min Max Game Link Link Link
2299. Strong Password Checker II Link Link Link
2303. Calculate Amount Paid in Taxes Link Link Link
2309. Greatest English Letter in Upper and Lower Case Link Link Link
2315. Count Asterisks Link Link Link
2319. Check if Matrix Is X-Matrix Link Link Link
2325. Decode the Message Link Link Link
2331. Evaluate Boolean Binary Tree Link Link Link
2335. Minimum Amount of Time to Fill Cups Link Link Link
2341. Maximum Number of Pairs in Array Link Link Link
2347. Best Poker Hand Link Link Link
2351. First Letter to Appear Twice Link Link Link
2357. Make Array Zero by Subtracting Equal Amounts Link Link Link
2363. Merge Similar Items Link Link Link
2367. Number of Arithmetic Triplets Link Link Link
2373. Largest Local Values in a Matrix Link Link Link
2379. Minimum Recolors to Get K Consecutive Black Blocks Link Link Link
2383. Minimum Hours of Training to Win a Competition Link Link Link
2389. Longest Subsequence With Limited Sum Link Link Link
2395. Find Subarrays With Equal Sum Link Link Link
2399. Check Distances Between Same Letters Link Link Link
2404. Most Frequent Even Element Link Link Link
2413. Smallest Even Multiple Link Link Link
2418. Sort the People Link Link Link
2423. Remove Letter To Equalize Frequency Link Link Link
2427. Number of Common Factors Link Link Link
2432. The Employee That Worked on the Longest Task Link Link Link
2441. Largest Positive Integer That Exists With Its Negative Link Link Link
2446. Determine if Two Events Have Conflict Link Link Link
2455. Average Value of Even Numbers That Are Divisible by Three Link Link Link
2460. Apply Operations to an Array Link Link Link
2469. Convert the Temperature Link Link Link
2475. Number of Unequal Triplets in Array Link Link Link
2481. Minimum Cuts to Divide a Circle Link Link Link
2485. Find the Pivot Integer Link Link Link
2490. Circular Sentence Link Link Link
2496. Maximum Value of a String in an Array Link Link Link
2500. Delete Greatest Value in Each Row Link Link Link
2506. Count Pairs Of Similar Strings Link Link Link
2511. Maximum Enemy Forts That Can Be Captured Link Link Link
2515. Shortest Distance to Target String in a Circular Array Link Link Link
2520. Count the Digits That Divide a Number Link Link Link
2525. Categorize Box According to Criteria Link Link Link
2529. Maximum Count of Positive Integer and Negative Integer Link Link Link
2535. Difference Between Element Sum and Digit Sum of an Array Link Link Link
2540. Minimum Common Value Link Link Link
2544. Alternating Digit Sum Link Link Link
2549. Count Distinct Numbers on Board Link Link Link

Medium

Name Link to LeetCode Link to solution Link to tests
2. Add Two Numbers Link Link Link
3. Longest Substring Without Repeating Characters Link Link Link
5. Longest Palindromic Substring Link Link Link
7. Reverse Integer Link Link Link
8. String to Integer (atoi) Link Link Link
11. Container With Most Water Link Link Link
12. Integer to Roman Link Link Link
15. 3Sum Link Link Link
16. 3Sum Closest Link Link Link
17. Letter Combinations of a Phone Number Link Link Link
19. Remove Nth Node From End of List Link Link Link
22. Generate Parentheses Link Link Link
24. Swap Nodes in Pairs Link Link Link
29. Divide Two Integers Link Link Link
33. Search in Rotated Sorted Array Link Link Link
34. Find First and Last Position of Element in Sorted Array Link Link Link
36. Valid Sudoku Link Link Link
38. Count and Say Link Link Link
39. Combination Sum Link Link Link
43. Multiply Strings Link Link Link
46. Permutations Link Link Link
48. Rotate Image Link Link Link
49. Group Anagrams Link Link Link
53. Maximum Subarray Link Link Link
54. Spiral Matrix Link Link Link
55. Jump Game Link Link Link
56. Merge Intervals Link Link Link
57. Insert Interval Link Link Link
59. Spiral Matrix II Link Link Link
61. Rotate List Link Link Link
62. Unique Paths Link Link Link
71. Simplify Path Link Link Link
74. Search a 2D Matrix Link Link Link
75. Sort Colors Link Link Link
78. Subsets Link Link Link
82. Remove Duplicates from Sorted List II Link Link Link
86. Partition List Link Link Link
92. Reverse Linked List II Link Link Link
95. Unique Binary Search Trees II Link Link Link
96. Unique Binary Search Trees Link Link Link
98. Validate Binary Search Tree Link Link Link
99. Recover Binary Search Tree Link Link Link
102. Binary Tree Level Order Traversal Link Link Link
103. Binary Tree Zigzag Level Order Traversal Link Link Link
105. Construct Binary Tree from Preorder and Inorder Traversal Link Link Link
106. Construct Binary Tree from Inorder and Postorder Traversal Link Link Link
107. Binary Tree Level Order Traversal II Link Link Link
109. Convert Sorted List to Binary Search Tree Link Link Link
113. Path Sum II Link Link Link
114. Flatten Binary Tree to Linked List Link Link Link
116. Populating Next Right Pointers in Each Node Link Link Link
117. Populating Next Right Pointers in Each Node II Link Link Link
120. Triangle Link Link Link
128. Longest Consecutive Sequence Link Link Link
129. Sum Root to Leaf Numbers Link Link Link
133. Clone Graph Link Link Link
134. Gas Station Link Link Link
138. Copy List with Random Pointer Link Link Link
142. Linked List Cycle II Link Link Link
143. Reorder List Link Link Link
146. LRU Cache Link Link Link
147. Insertion Sort List Link Link Link
148. Sort List Link Link Link
150. Evaluate Reverse Polish Notation Link Link Link
151. Reverse Words in a String Link Link Link
155. Min Stack Link Link Link
165. Compare Version Numbers Link Link Link
167. Two Sum II - Input Array Is Sorted Link Link Link
173. Binary Search Tree Iterator Link Link Link
179. Largest Number Link Link Link
187. Repeated DNA Sequences Link Link Link
189. Rotate Array Link Link Link
199. Binary Tree Right Side View Link Link Link
200. Number of Islands Link Link Link
204. Count Primes Link Link Link
208. Implement Trie (Prefix Tree) Link Link Link
209. Minimum Size Subarray Sum Link Link Link
215. Kth Largest Element in an Array Link Link Link
227. Basic Calculator II Link Link Link
230. Kth Smallest Element in a BST Link Link Link
235. Lowest Common Ancestor of a Binary Search Tree Link Link Link
236. Lowest Common Ancestor of a Binary Tree Link Link Link
237. Delete Node in a Linked List Link Link Link
238. Product of Array Except Self Link Link Link
240. Search a 2D Matrix II Link Link Link
284. Peeking Iterator Link Link Link
287. Find the Duplicate Number Link Link Link
299. Bulls and Cows Link Link Link
300. Longest Increasing Subsequence Link Link Link
304. Range Sum Query 2D - Immutable Link Link Link
316. Remove Duplicate Letters Link Link Link
318. Maximum Product of Word Lengths Link Link Link
328. Odd Even Linked List Link Link Link
331. Verify Preorder Serialization of a Binary Tree Link Link Link
334. Increasing Triplet Subsequence Link Link Link
341. Flatten Nested List Iterator Link Link Link
347. Top K Frequent Elements Link Link Link
371. Sum of Two Integers Link Link Link
377. Combination Sum IV Link Link Link
378. Kth Smallest Element in a Sorted Matrix Link Link Link
380. Insert Delete GetRandom O(1) Link Link Link
382. Linked List Random Node Link Link Link
388. Longest Absolute File Path Link Link Link
394. Decode String Link Link Link
398. Random Pick Index Link Link Link
400. Nth Digit Link Link Link
402. Remove K Digits Link Link Link
417. Pacific Atlantic Water Flow Link Link Link
424. Longest Repeating Character Replacement Link Link Link
429. N-ary Tree Level Order Traversal Link Link Link
435. Non-overlapping Intervals Link Link Link
437. Path Sum III Link Link Link
438. Find All Anagrams in a String Link Link Link
442. Find All Duplicates in an Array Link Link Link
443. String Compression Link Link Link
445. Add Two Numbers II Link Link Link

About

Over 500 solved problems with test cases and all common structures from https://leetcode.com on Ruby

Topics

Resources

Stars

Watchers

Forks

Languages