algorithm
My LeetCode Solutions with Explanation and Time Complexity Analysis
File Explorer
Download Latest Version (.zip)- FUNDING.yml
- 1051. Height Checker.py
- 1085. Sum of Digits in the Minimum Number.py
- 1200. Minimum Absolute Difference.py
- 1233. Remove Sub-Folders from the Filesystem.py
- 128. Longest Consecutive Sequence.py
- 1295. Find Numbers with Even Number of Digits.py
- 1304. Find N Unique Integers Sum up to Zero.py
- 1313. Decompress Run-Length Encoded List.py
- 1365. How Many Numbers Are Smaller Than the Current Number.py
- 1380. Lucky Numbers in a Matrix.py
- 1426. Counting Elements.py
- 1470. Shuffle the Array.py
- 1476. Subrectangle Queries.py
- 1480. Running Sum of 1d Array.py
- 1502. Can Make Arithmetic Progression From Sequence.py
- 1512. Number of Good Pairs.py
- 153. Find Minimum in Rotated Sorted Array.cpp
- 1572. Matrix Diagonal Sum.py
- 163. Missing Ranges.py
- 169. Majority Element.cpp
- 189. Rotate Array.cpp
- 189. Rotate Array.py
- 1929. Concatenation of Array.py
- 238. Product of Array Except Self.cpp
- 26. Remove Duplicates from Sorted Array.cpp
- 349. Intersection of Two Arrays.py
- 41. First Missing Positive.py
- 422. Valid Word Square.py
- 442. Find All Duplicates in an Array.py
- 448. Find All Numbers Disappeared in an Array.py
- 48. Rotate Image.py
- 509. Fibonacci Number.py
- 56. Merge Intervals.cpp
- 561. Array Partition I.py
- 566. Reshape the Matrix.py
- 581. Shortest Unsorted Continuous Subarray.py
- 66. Plus One.py
- 674. Longest Continuous Increasing Subsequence.py
- 682. Baseball Game.py
- 724. Find Pivot Index.py
- 766. Toeplitz Matrix.py
- 821. Shortest Distance to a Character.py
- 832. Flipping an Image.cpp
- 896. Monotonic Array.py
- 922. Sort Array By Parity II.py
- 1342. Number of Steps to Reduce a Number to Zero.py
- 136. Single Number.cpp
- 1486. XOR Operation in an Array.py
- 191. Number of 1 Bits.cpp
- 268. Missing Number.cpp
- 338. Counting Bits.py
- 371. Sum of Two Integers.cpp
- 461. Hamming Distance.cpp
- 476. Number Complement.cpp
- 102. Binary Tree Level Order Traversal.py
- 103. Binary Tree Zigzag Level Order Traversal.py
- 107. Binary Tree Level Order Traversal II.py
- 1302. Deepest Leaves Sum.py
- 199. Binary Tree Right Side View.py
- 463. Island Perimeter.py
- 513. Find Bottom Left Tree Value.py
- 515. Find Largest Value in Each Tree Row.py
- 637. Average of Levels in Binary Tree.py
- 695. Max Area of Island.py
- 863. All Nodes Distance K in Binary Tree.py
- 994. Rotting Oranges.py
- 101. Symmetric Tree.cpp
- 112. Path Sum.py
- 113. Path Sum II.py
- 129. Sum Root to Leaf Numbers.py
- 1315. Sum of Nodes with Even-Valued Grandparent.py
- 17. Letter Combinations of a Phone Number.py
- 200. Number of Islands.py
- 22. Generate Parentheses.py
- 339. Nested List Weight Sum.py
- 366. Find Leaves of Binary Tree.py
- 46. Permutations.py
- 543. Diameter of Binary Tree.py
- 547. Number of Provinces.py
- 733. Flood Fill.py
- 78. Subsets.py
- 79. Word Search.py
- 938. Range Sum of BST.py
- backtrack.py
- 146. LRU Cache.py
- 155. Min Stack.py
- 1603. Design Parking System.py
- 208. Implement Trie (Prefix Tree).py
- 225. Implement Stack using Queues.py
- 232. Implement Queue using Stacks.py
- 251. Flatten 2D Vector.py
- 348. Design Tic-Tac-Toe.py
- 359. Logger Rate Limiter.py
- 362. Design Hit Counter.py
- 379. Design Phone Directory.py
- 380. Insert Delete GetRandom O(1).py
- 535. Encode and Decode TinyURL.py
- 716. Max Stack.py
- 215. Kth Largest Element in an Array.py
- 23. Merge k Sorted Lists.py
- 50. Pow(x, n).py
- 53. Maximum Subarray.py
- 1143. Longest Common Subsequence.py
- 118. Pascal's Triangle.py
- 119. Pascal's Triangle II.py
- 121. Best Time to Buy and Sell Stock.cpp
- 121. Best Time to Buy and Sell Stock.py
- 122. Best Time to Buy and Sell Stock II.py
- 1220. Count Vowels Permutation.py
- 139. Word Break.py
- 198. House Robber.py
- 221. Maximal Square.py
- 256. Paint House.py
- 300. Longest Increasing Subsequence.py
- 42. Trapping Rain Water.py
- 5. Longest Palindromic Substring.py
- 516. Longest Palindromic Subsequence.py
- 62. Unique Paths.py
- 64. Minimum Path Sum.py
- 647. Palindromic Substrings.py
- 70. Climbing Stairs.py
- 72. Edit Distance.py
- 133. Clone Graph.py
- 207. Course Schedule.py
- 134. Gas Station.py
- 406. Queue Reconstruction by Height.py
- 45. Jump Game II.py
- 55. Jump Game.py
- 763. Partition Labels.py
- 807. Max Increase to Keep City Skyline.py
- 944. Delete Columns to Make Sorted.py
- 1. Two Sum.py
- 1010. Pairs of Songs With Total Durations Divisible by 60.py
- 1133. Largest Unique Number.py
- 1160. Find Words That Can Be Formed by Characters.py
- 1165. Single-Row Keyboard.py
- 1198. Find Smallest Common Element in All Rows.py
- 1207. Unique Number of Occurrences.py
- 1213. Intersection of Three Sorted Arrays.py
- 1218. Longest Arithmetic Subsequence of Given Difference.py
- 1570. Dot Product of Two Sparse Vectors.py
- 170. Two Sum III - Data structure design.py
- 202. Happy Number.py
- 205. Isomorphic Strings.py
- 217. Contains Duplicate.py
- 234. Palindrome Linked List.py
- 242. Valid Anagram.py
- 266. Palindrome Permutation.py
- 290. Word Pattern.py
- 299. Bulls and Cows.py
- 347. Top K Frequent Elements.py
- 350. Intersection of Two Arrays II.py
- 387. First Unique Character in a String.py
- 388. Longest Absolute File Path.py
- 389. Find the Difference.cpp
- 409. Longest Palindrome.py
- 451. Sort Characters By Frequency.py
- 49. Group Anagrams.py
- 500. Keyboard Row.cpp
- 560. Subarray Sum Equals K.py
- 609. Find Duplicate File in System.py
- 760. Find Anagram Mappings.py
- 771. Jewels and Stones.cpp
- 811. Subdomain Visit Count.py
- 884. Uncommon Words from Two Sentences.py
- 953. Verifying an Alien Dictionary.py
- 957. Prison Cells After N Days.py
- 961. N-Repeated Element in Size 2N Array.py
- 1046. Last Stone Weight.py
- 1086. High Five.py
- 1167. Minimum Cost to Connect Sticks.py
- 253. Meeting Rooms II.py
- 347. Top K Frequent Elements.py
- 621. Task Scheduler.py
- 692. Top K Frequent Words.py
- 1019. Next Greater Node In Linked List.py
- 1290. Convert Binary Number in a Linked List to Integer.py
- 138. Copy List with Random Pointer.py
- 141. Linked List Cycle.cpp
- 142. Linked List Cycle II.py
- 160. Intersection of Two Linked Lists.py
- 2. Add Two Numbers.cpp
- 203. Remove Linked List Elements.py
- 206. Reverse Linked List.cpp
- 206. Reverse Linked List.py
- 21. Merge Two Sorted Lists.cpp
- 23. Merge k Sorted Lists.py
- 237. Delete Node in a Linked List.cpp
- 237. Delete Node in a Linked List.py
- 24. Swap Nodes in Pairs.py
- 328. Odd Even Linked List.py
- 445. Add Two Numbers II.py
- 61. Rotate List.py
- 82. Remove Duplicates from Sorted List II.cpp
- 83. Remove Duplicates from Sorted List.cpp
- 876. Middle of the Linked List.py
- 92. Reverse Linked List II.py
- 1134. Armstrong Number.py
- 1154. Day of the Year.py
- 1180. Count Substrings with Only One Distinct Letter.py
- 1217. Play with Chips.py
- 1232. Check If It Is a Straight Line.py
- 1323. Maximum 69 Number.py
- 1360. Number of Days Between Two Dates.py
- 171. Excel Sheet Column Number.cpp
- 171. Excel Sheet Column Number.py
- 172. Factorial Trailing Zeroes.py
- 204. Count Primes.py
- 231. Power of Two.py
- 258. Add Digits.cpp
- 342. Power of Four.py
- 728. Self Dividing Numbers.py
- 9. Palindrome Number.cpp
- 292. Nim Game.cpp
- 192. Word Frequency.sh
- 193. Valid Phone Numbers.sh
- 194. Transpose File.sh
- 195. Tenth Line.sh
- 933. Number of Recent Calls.py
- 1064. Fixed Point.py
- 1150. Check If a Number Is Majority Element in a Sorted Array.py
- 1337. The K Weakest Rows in a Matrix.py
- 153. Find Minimum in Rotated Sorted Array.py
- 1539. Kth Missing Positive Number.py
- 240. Search a 2D Matrix II.py
- 278. First Bad Version.py
- 33. Search in Rotated Sorted Array.py
- 34. Find First and Last Position of Element in Sorted Array.py
- 35. Search Insert Position.py
- 374. Guess Number Higher or Lower.py
- 69. Sqrt(x).py
- 704. Binary Search.py
- 74. Search a 2D Matrix.py
- 1100. Find K-Length Substrings With No Repeated Characters.py
- 1208. Get Equal Substrings Within Budget.py
- 219. Contains Duplicate II.py
- 239. Sliding Window Maximum.py
- 3. Longest Substring Without Repeating Characters.py
- 438. Find All Anagrams in a String.py
- 713. Subarray Product Less Than K.py
- 1122. Relative Sort Array.py
- 1329. Sort the Matrix Diagonally.py
- 1387. Sort Integers by The Power Value.py
- 162. Find Peak Element.py
- 1710. Maximum Units on a Truck.py
- 207. Course Schedule.py
- 252. Meeting Rooms.py
- 253. Meeting Rooms II.py
- 253. Meeting Rooms III.py
- 287. Find the Duplicate Number.py
- 56. Merge Intervals.py
- 973. K Closest Points to Origin.py
- Quick Sort.py
- 1050. Actors and Directors Who Cooperated At Least Three Times.sql
- 1068. Product Sales Analysis I.sql
- 1069. Product Sales Analysis II.sql
- 1075. Project Employees I.sql
- 1082. Sales Analysis I.sql
- 1148. Article Views I.sql
- 1173. Immediate Food Delivery I.sql
- 1179. Reformat Department Table.sql
- 1251. Average Selling Price.sql
- 1270. All People Report to the Given Manager.sql
- 1285. Find the Start and End Number of Continuous Ranges.sql
- 1303. Find the Team Size.sql
- 1350. Students With Invalid Departments.sql
- 1393. Capital Gain:Loss.sql
- 1445. Apples & Oranges.sql
- 1587. Bank Account Summary II.sql
- 1683. Invalid Tweets.sql
- 175. Combine Two Tables.sql
- 1757. Recyclable and Low Fat Products.sql
- 176. Second Highest Salary.sql
- 177. Nth Highest Salary.sql
- 181. Employees Earning More Than Their Managers.sql
- 182. Duplicate Emails.sql
- 1853. Convert Date Format.sql
- 1873. Calculate Special Bonus.sql
- 196. Delete Duplicate Emails.sql
- 197. Rising Temperature.sql
- 511. Game Play Analysis I.sql
- 584. Find Customer Referee.sql
- 586. Customer Placing the Largest Number of Orders.sql
- 595. Big Countries.sql
- 596. Classes More Than 5 Students.sql
- 627. Swap Salary.sql
- 1047. Remove All Adjacent Duplicates In String.py
- 1190. Reverse Substrings Between Each Pair of Parentheses.py
- 1209. Remove All Adjacent Duplicates in String II.py
- 20. Valid Parentheses.py
- 341. Flatten Nested List Iterator.py
- 394. Decode String.py
- 456. 132 Pattern.py
- 496. Next Greater Element I.py
- 503. Next Greater Element II.py
- 735. Asteroid Collision.py
- 739. Daily Temperatures.py
- 921. Minimum Add to Make Parentheses Valid.py
- 1002. Find Common Characters.py
- 1108. Defanging an IP Address.py
- 1119. Remove Vowels from a String.py
- 12. Integer to Roman.py
- 14. Longest Common Prefix.py
- 151. Reverse Words in a String.py
- 1528. Shuffle String.py
- 161. One Edit Distance.py
- 1614. Maximum Nesting Depth of the Parentheses.py
- 165. Compare Version Numbers.py
- 28. Implement strStr().py
- 38. Count and Say.py
- 412. Fizz Buzz.cpp
- 415. Add Strings.py
- 434. Number of Segments in a String.py
- 557. Reverse Words in a String III.py
- 58. Length of Last Word.py
- 6. Zigzag Conversion.py
- 657. Robot Return to Origin.py
- 67. Add Binary.py
- 680. Valid Palindrome II.py
- 8. String to Integer (atoi).py
- 804. Unique Morse Code Words.cpp
- 819. Most Common Word.py
- 824. Goat Latin.py
- 929. Unique Email Addresses.py
- 937. Reorder Log Files.py
- 102. Binary Tree Level Order Traversal.py
- 236. Lowest Common Ancestor of a Binary Tree.py
- 101. Symmetric Tree.py
- 102. Binary Tree Level Order Traversal.py
- 103. Binary Tree Zigzag Level Order Traversal.py
- 1038. Binary Search Tree to Greater Sum Tree.py
- 104. Maximum Depth of Binary Tree.py
- 105. Construct Binary Tree from Preorder and Inorder Traversal.py
- 106. Construct Binary Tree from Inorder and Postorder Traversal.py
- 108. Convert Sorted Array to Binary Search Tree.py
- 109. Convert Sorted List to Binary Search Tree.py
- 110. Balanced Binary Tree.py
- 111. Minimum Depth of Binary Tree.py
- 112. Path Sum.cpp
- 114. Flatten Binary Tree to Linked List.py
- 116. Populating Next Right Pointers in Each Node.py
- 117. Populating Next Right Pointers in Each Node II.py
- 1214. Two Sum BSTs.py
- 1265. Print Immutable Linked List in Reverse.py
- 1305. All Elements in Two Binary Search Trees.py
- 1325. Delete Leaves With a Given Value.py
- 1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree.py
- 144. Binary Tree Preorder Traversal.py
- 1448. Count Good Nodes in Binary Tree.py
- 145. Binary Tree Postorder Traversal.py
- 1469. Find All The Lonely Nodes.py
- 1490. Clone N-ary Tree.py
- 1506. Find Root of N-Ary Tree.py
- 173. Binary Search Tree Iterator.py
- 222. Count Complete Tree Nodes.py
- 226. Invert Binary Tree.py
- 230. Kth Smallest Element in a BST.py
- 235. Lowest Common Ancestor of a Binary Search Tree.cpp
- 235. Lowest Common Ancestor of a Binary Search Tree.py
- 236. Lowest Common Ancestor of a Binary Tree.cpp
- 250. Count Univalue Subtrees.py
- 257. Binary Tree Paths.py
- 270. Closest Binary Search Tree Value.cpp
- 270. Closest Binary Search Tree Value.py
- 285. Inorder Successor in BST.py
- 297. Serialize and Deserialize Binary Tree.py
- 298. Binary Tree Longest Consecutive Sequence.py
- 314. Binary Tree Vertical Order Traversal.py
- 404. Sum of Left Leaves.cpp
- 426. Convert Binary Search Tree to Sorted Doubly Linked List.py
- 429. N-ary Tree Level Order Traversal.py
- 450. Delete Node in a BST.cpp
- 538. Convert BST to Greater Tree.py
- 559. Maximum Depth of N-ary Tree.py
- 572. Subtree of Another Tree.py
- 589. N-ary Tree Preorder Traversal.py
- 590. N-ary Tree Postorder Traversal.py
- 617. Merge Two Binary Trees.cpp
- 700. Search in a Binary Search Tree.py
- 701. Insert into a Binary Search Tree.py
- 814. Binary Tree Pruning.cpp
- 814. Binary Tree Pruning.py
- 897. Increasing Order Search Tree.py
- 94. Binary Tree Inorder Traversal.py
- 965. Univalued Binary Tree.py
- 98. Validate Binary Search Tree.py
- 99. Recover Binary Search Tree.py
- hanoi.py
- 1. Two Sum.cpp
- 1. Two Sum.py
- 1099. Two Sum Less Than K.py
- 11. Container With Most Water.py
- 125. Valid Palindrome.py
- 15. 3Sum.cpp
- 16. 3Sum Closest.py
- 167. Two Sum II - Input array is sorted.cpp
- 18. 4Sum.py
- 19. Remove Nth Node From End of List.py
- 27. Remove Element.cpp
- 283. Move Zeroes.cpp
- 344. Reverse String.cpp
- 345. Reverse Vowels of a String.py
- 653. Two Sum IV - Input is a BST.py
- 75. Sort Colors.cpp
- 88. Merge Sorted Array.py
- 100. Remove Duplicates from Sorted Array.cpp
- 101. Remove Duplicates from Sorted Array II.cpp
- 1315. Summary Ranges.py
- 1355. Pascal's Triangle.py
- 1436. Flipping an Image.py
- 159. Find Minimum in Rotated Sorted Array.cpp
- 1709. Number of Recent Calls.py
- 172. Remove Element.cpp
- 1794. Count Duplicates.py
- 373. Paritition Array by Odd and Even.cpp
- 385. ArrayList.py
- 407. Plus One.py
- 46. Majority Number.cpp
- 484. Swap Two Integers in Array.py
- 6. Merge Two Sorted Arrays.cpp
- 64. Merge Sorted Array.cpp
- 181. Flip Bits.cpp
- 365. Count 1 in Binary.cpp
- 82. Single Number.cpp
- 835. Hamming Distance.cpp
- 1062. Flood Fill.py
- 1353. Sum Root to Leaf Numbers.py
- 1357. Path Sum II.py
- 480. Binary Tree Paths.py
- 1065. My Calendar I.cpp
- 1065. My Calendar I.py
- 12. Min Stack.py
- 1786. Pub Sub Pattern.py
- 204. Singleton.cpp
- 111. Climbing Stairs.cpp
- 114. Unique Paths.cpp
- 119. Edit Distance.cpp
- 149. Best Time to Buy and Sell Stock.cpp
- 150. Best Time to Buy and Sell Stock II.cpp
- 200. Longest Palindromic Substring.cpp
- 394. Coins in a Line.cpp
- 128. Hash Function.cpp
- 1281. Top K Frequent Elements.py
- 1598. Uncommon Words from Two Sentences.py
- 488. Happy Number.cpp
- 488. Happy Number.py
- 916. Palindrome Permutation.cpp
- 102. Linked List Cycle.cpp
- 112. Remove Duplicates from Sorted List.cpp
- 1292. Odd Even Linked List.py
- 165. Merge Two Sorted Lists.cpp
- 166. Nth to Last Node in List.cpp
- 167. Add Two Numbers.cpp
- 174. Remove Nth Node From End of List.cpp
- 217. Remove Duplicates from Unsorted List.py
- 219. Insert Node in Sorted Linked List.py
- 35. Reverse Linked List.cpp
- 372. Delete Node in the Middle of Singly Linked List.cpp
- 451. Swap Nodes in Pairs.py
- 452. Remove Linked List Elements.cpp
- 466. Count Linked List Nodes.cpp
- 904. Plus One Linked List.py
- 96. Partition List.py
- 2. Trailing Zeros.cpp
- 366. Fibonacci.cpp
- 517. Ugly Number.py
- 569. Add Digits.cpp
- 765. Valid Triangle.cpp
- 766. Leap Year.cpp
- 768. Yang Hui Triangle.py
- 845. Greatest Common Divisor.cpp
- 3. Digit Counts.py
- 9. Fizz Buzz.cpp
- 1. A + B Problem.cpp
- 37. Reverse 3-digit Integer.cpp
- 413. Reverse Integer.cpp
- 454. Rectangle Area.cpp
- 952. Digital Problem.cpp
- 492. Implement Queue by Linked List.py
- 14. First Position of Target.cpp
- 141. Sqrt(x).cpp
- 38. Search a 2D Matrix II.cpp
- 457. Classical Binary Search.cpp
- 662. Guess Number Game.cpp
- 75. Find Peak Element.cpp
- 898. Leftmost One.cpp
- 148. Sort Colors.cpp
- 463. Sort Integers.cpp
- 830. String Sort.py
- 423. Valid Parentheses.cpp
- 822. Reverse Order Storage.cpp
- 133. Longest Words.cpp
- 1389. Shortest Distance to a Character.py
- 145. Lowercase to Uppercase.cpp
- 157. Unique Characters.cpp
- 158. Two Strings Are Anagrams.cpp
- 211. String Permutation.cpp
- 212. Space Replacement.cpp
- 408. Add Binary.cpp
- 418. Integer to Roman.cpp
- 419. Roman to Integer.cpp
- 422. Length of Last Word.cpp
- 491. Palindrome Number.cpp
- 524. Left Pad.cpp
- 53. Reverse Words in a String.cpp
- 55. Compare Strings.cpp
- 646. First Position Unique Character.cpp
- 655. Big Integer Addition.cpp
- 914. Flip Game.cpp
- 956. Data Segmentation.py
- 1003. Binary Tree Pruning.py
- 11. Search Range in Binary Search Tree.py
- 1126. Merge Two Binary Trees.py
- 1311. Lowest Common Ancestor of a Binary Search Tree.py
- 155. Minimum Depth of Binary Tree.cpp
- 175. Invert Binary Tree.cpp
- 177. Convert Sorted Array to Binary Search Tree With Minimal Height.cpp
- 22. Flatten List.py
- 375. Clone Binary Tree.cpp
- 376. Binary Tree Path Sum.py
- 469. Identical Binary Tree.cpp
- 632. Binary Tree Maximum Node.cpp
- 66. Binary Tree Preorder Traversal.cpp
- 661. Convert BST to Greater Tree.cpp
- 67. Binary Tree Inorder Traversal.cpp
- 68. Binary Tree Postorder Traversal.cpp
- 701. Trim a Binary Search Tree.cpp
- 85. Insert Node in a Binary Search Tree.cpp
- 93. Balanced Binary Tree.cpp
- 97. Maximum Depth of Binary Tree.cpp
- 383. Container With Most Water.cpp
- 56. Two Sum.cpp
- 57. 3Sum.cpp
- 58. 4Sum.cpp
- 59. 3Sum Closest.cpp
- 608. Two Sum - Input array is sorted.cpp
- Chapter_1._Introducing_Algorithm_Interview__Coding_Style_dW5wEfA.pdf
- Chapter_2._Binary_Search_v4.0.pdf
- Chapter_3._Binary_Tree__Divide_Conquer_v4.0.pdf
- Chapter_4._Breadth_First_Search_v4.0.2.pdf
- Chapter_5._Depth_First_Search_v4.0.1.pdf
- Chapter_6._Linked_List__Array_v4.0.1.pdf
- Chapter_7._Two_Pointers_v4.0.pdf
- Chapter_8._Data_Structure_v4.0.1.pdf
- Chapter_9._Dynamic_Programming_v4.0.pdf
- Algorithms_CLRS_3rd.pdf
- Designing Data Intensive Applications.pdf
- leetcode-cpp.pdf
- Leetcode_Category.pdf
- leetcode_summary.xlsx
- .gitignore
- LICENSE
- package-lock.json
- README.md
// repository documentation
Was this content helpful?
(0 ratings)
