This repository contains my solutions to various LeetCode problems.
All solutions are written in a clean, easy-to-understand style โ some in Python, some in Java, depending on the problem.
| # | Question ID | Question Name | Problem | Solution |
|---|---|---|---|---|
| 1 | 1 | 1 Two Sum | Problem | two-sum.java |
| 2 | 100 | 100 Same Tree | Problem | same-tree.py |
| 3 | 104 | 104 Maximum Depth Of Binary Tree | Problem | maximum-depth-of-binary-tree.py |
| 4 | 1064 | 1064 Smallest Integer Divisible By K | Problem | smallest-integer-divisible-by-k.py |
| 5 | 1071 | 1071 Binary Prefix Divisible By 5 | Problem | - |
| 6 | 108 | 108 Convert Sorted Array To Binary Search Tree | Problem | convert-sorted-array-to-binary-search-tree.cpp |
| 7 | 11 | 11 Container With Most Water | Problem | container-with-most-water.py |
| 8 | 1127 | 1127 Last Stone Weight | Problem | last-stone-weight.cpp |
| 9 | 118 | 118 Pascal'Striangle | - | View Code |
| 10 | 1205 | 1205 Defanging An Ip Address | Problem | defanging-an-ip-address.py |
| 11 | 121 | 121 Best Time To Buy And Sell Stock | Problem | best-time-to-buy-and-sell-stock.java |
| 12 | 125 | 125 Validpalindrome | - | View Code |
| 13 | 1266 | 1266 Minimumtimevisitingallpoints | - | View Code |
| 14 | 1353 | 1353 Find Resultant Array After Removing Anagrams | Problem | find-resultant-array-after-removing-anagrams.java find-resultant-array-after-removing-anagrams.py |
| 15 | 136 | 136 Single Number | Problem | single-number.java |
| 16 | 1365 | 1365 Howmanynumbersaresmallerthanthecurrentnumber | - | View Code |
| 17 | 1388 | 1388 Greatest Sum Divisible By Three | Problem | greatest-sum-divisible-by-three.py |
| 18 | 1395 | 1395 Minimum Time Visiting All Points | Problem | minimum-time-visiting-all-points.cpp |
| 19 | 13 | 13 Romantointeger | - | View Code |
| 20 | 1402 | 1402 Count Square Submatrices With All Ones | Problem | count-square-submatrices-with-all-ones.py |
| 21 | 141 | 141 Linked List Cycle | Problem | - |
| 22 | 142 | 142 Linked List Cycle Ii | Problem | - |
| 23 | 143 | 143 Reorder List | Problem | - |
| 24 | 144 | 144 Binary Tree Preorder Traversal | Problem | - |
| 25 | 1440 | 1440 Convert Integer To The Sum Of Two No Zero Integers | Problem | convert-integer-to-the-sum-of-two-no-zero-integers.py |
| 26 | 1448 | 1448 Maximum 69 Number | Problem | maximum-69-number.py |
| 27 | 148 | 148 Sort List | Problem | - |
| 28 | 1482 | 1482 How Many Numbers Are Smaller Than The Current Number | Problem | how-many-numbers-are-smaller-than-the-current-number.cpp |
| 29 | 149 | 149 Max Points On A Line | Problem | max-points-on-a-line.py |
| 30 | 14 | 14 Longestcommonprefix | - | View Code |
| 31 | 15 | 15 3Sum | Problem | 3sum.py |
| 32 | 150 | 150 Evaluatereversepolishnotation | - | View Code |
| 33 | 153 | 153 Find Minimum In Rotated Sorted Array | Problem | find-minimum-in-rotated-sorted-array.py |
| 34 | 1552 | 1552 Build An Array With Stack Operations | Problem | build-an-array-with-stack-operations.cpp |
| 35 | 155 | 155 Minstack | - | View Code |
| 36 | 1570 | 1570 Final Prices With A Special Discount In A Shop | Problem | - |
| 37 | 1580 | 1580 Shuffle The Array | Problem | shuffle-the-array.cpp |
| 38 | 160 | 160 Intersection Of Two Linked Lists | Problem | - |
| 39 | 1603 | 1603 Running Sum Of 1D Array | Problem | running-sum-of-1d-array.py |
| 40 | 1635 | 1635 Number Of Good Pairs | Problem | number-of-good-pairs.py |
| 41 | 167 | 167 Twosum Ii Inputarrayissorted | - | View Code |
| 42 | 169 | 169 Majority Element | Problem | majority-element.java |
| 43 | 172 | 172 Factorialtrailingzeroes | - | View Code |
| 44 | 1742 | 1742 Widest Vertical Area Between Two Points Containing No Points | Problem | widest-vertical-area-between-two-points-containing-no-points.py |
| 45 | 1791 | 1791 Richest Customer Wealth | Problem | richest-customer-wealth.py |
| 46 | 1797 | 1797 Goal Parser Interpretation | Problem | goal-parser-interpretation.py |
| 47 | 17 | 17 Lettercombinationsofaphonenumber | - | View Code |
| 48 | 1802 | 1802 Number Of Students Unable To Eat Lunch | Problem | number-of-students-unable-to-eat-lunch.cpp |
| 49 | 1806 | 1806 Count Of Matches In Tournament | Problem | count-of-matches-in-tournament.py |
| 50 | 1817 | 1817 Calculate Money In Leetcode Bank | Problem | calculate-money-in-leetcode-bank.py |
| 51 | 189 | 189 Rotate Array | Problem | rotate-array.py |
| 52 | 1895 | 1895 Minimum Number Of Operations To Move All Balls To Each Box | Problem | minimum-number-of-operations-to-move-all-balls-to-each-box.py |
| 53 | 19 | 19 Remove Nth Node From End Of List | Problem | - |
| 54 | 1 | 1 Twosum | - | View Code |
| 55 | 2 | 2 Add Two Numbers | Problem | - |
| 56 | 202 | 202 Happy Number | Problem | happy-number.py |
| 57 | 2037 | 2037 Count Square Sum Triples | Problem | count-square-sum-triples.py |
| 58 | 2048 | 2048 Build Array From Permutation | Problem | build-array-from-permutation.py |
| 59 | 205 | 205 Isomorphic Strings | Problem | isomorphic-strings.py |
| 60 | 2050 | 2050 Count Good Numbers | Problem | count-good-numbers.py |
| 61 | 2058 | 2058 Concatenation Of Array | Problem | - |
| 62 | 206 | 206 Reverse Linked List | Problem | - |
| 63 | 20 | 20 Validparentheses | - | View Code |
| 64 | 2137 | 2137 Final Value Of Variable After Performing Operations | Problem | final-value-of-variable-after-performing-operations.py |
| 65 | 217 | 217 Containsduplicates | - | View Code |
| 66 | 2195 | 2195 Time Needed To Buy Tickets | Problem | time-needed-to-buy-tickets.cpp |
| 67 | 21 | 21 Mergetwosortedlists | - | View Code |
| 68 | 2216 | 2216 Delete The Middle Node Of A Linked List | Problem | - |
| 69 | 2219 | 2219 Maximum Number Of Words Found In Sentences | Problem | maximum-number-of-words-found-in-sentences.py |
| 70 | 223 | 223 Rectangle Area | Problem | rectangle-area.py |
| 71 | 2244 | 2244 Number Of Laser Beams In A Bank | Problem | number-of-laser-beams-in-a-bank.py |
| 72 | 2264 | 2264 Largest3Samedigitnumberinstring | - | View Code |
| 73 | 2265 | 2265 Partition Array According To Given Pivot | Problem | partition-array-according-to-given-pivot.py |
| 74 | 2271 | 2271 Rearrange Array Elements By Sign | Problem | rearrange-array-elements-by-sign.java |
| 75 | 2274 | 2274 Keep Multiplying Found Values By Two | Problem | keep-multiplying-found-values-by-two.py |
| 76 | 229 | 229 Majority Element Ii | Problem | majority-element-ii.py |
| 77 | 232 | 232 Implement Queue Using Stacks | Problem | implement-queue-using-stacks.cpp |
| 78 | 234 | 234 Palindrome Linked List | Problem | - |
| 79 | 237 | 237 Delete Node In A Linked List | Problem | - |
| 80 | 238 | 238 Productofarrayexceptself | - | View Code |
| 81 | 2396 | 2396 Strictlypalindromicnumber | - | View Code |
| 82 | 2423 | 2423 Removelettertoequalizefrequency | - | View Code |
| 83 | 242 | 242 Validanagram | - | View Code |
| 84 | 2491 | 2491 Smallest Even Multiple | Problem | smallest-even-multiple.py |
| 85 | 2556 | 2556 Convert The Temperature | Problem | convert-the-temperature.py |
| 86 | 2591 | 2591 Distributemoneytomaximumchildren | - | View Code |
| 87 | 26 | 26 Remove Duplicates From Sorted Array | Problem | remove-duplicates-from-sorted-array.py |
| 88 | 2631 | 2631 Sort The Students By Their Kth Score | Problem | sort-the-students-by-their-kth-score.py |
| 89 | 268 | 268 Missingnumbers | - | View Code |
| 90 | 27 | 27 Remove Element | Problem | remove-element.java |
| 91 | 2714 | 2714 Left And Right Sum Differences | Problem | left-and-right-sum-differences.py |
| 92 | 2724 | 2724 Convert An Array Into A 2D Array With Conditions | Problem | convert-an-array-into-a-2d-array-with-conditions.py |
| 93 | 28 | 28 Find The Index Of The First Occurrence In A String | Problem | find-the-index-of-the-first-occurrence-in-a-string.py |
| 94 | 2812 | 2812 Find The Maximum Achievable Number | Problem | find-the-maximum-achievable-number.py |
| 95 | 283 | 283 Move Zeroes | Problem | move-zeroes.java |
| 96 | 2894 | 2894 Divisibleandnondivisiblesumsdifference | - | View Code |
| 97 | 29 | 29 Divide Two Integers | Problem | divide-two-integers.py |
| 98 | 2903 | 2903 Insert Greatest Common Divisors In Linked List | Problem | - |
| 99 | 2917 | 2917 Count Pairs Whose Sum Is Less Than Target | Problem | count-pairs-whose-sum-is-less-than-target.py |
| 100 | 31 | 31 Next Permutation | Problem | next-permutation.py |
| 101 | 3110 | 3110 Scoreofastring | - | View Code |
| 102 | 312 | 312 Burst Balloons | Problem | burst-balloons.py |
| 103 | 3194 | 3194 Find Words Containing Character | Problem | find-words-containing-character.py |
| 104 | 324 | 324 Wigglesortii | - | View Code |
| 105 | 3251 | 3251 Maximum Area Of Longest Diagonal Rectangle | Problem | maximum-area-of-longest-diagonal-rectangle.java |
| 106 | 328 | 328 Odd Even Linked List | Problem | - |
| 107 | 33 | 33 Search In Rotated Sorted Array | Problem | search-in-rotated-sorted-array.py |
| 108 | 3371 | 3371 Harshad Number | Problem | harshad-number.py |
| 109 | 34 | 34 Find First And Last Position Of Element In Sorted Array | Problem | find-first-and-last-position-of-element-in-sorted-array.py |
| 110 | 342 | 342 Power Of Four | Problem | power-of-four.py |
| 111 | 342 | 342 Poweroffour | - | View Code |
| 112 | 3446 | 3446 Find The Number Of Good Pairs I | Problem | find-the-number-of-good-pairs-i.py |
| 113 | 3476 | 3476 Find Minimum Operations To Make All Elements Divisible By Three | Problem | find-minimum-operations-to-make-all-elements-divisible-by-three.py |
| 114 | 347 | 347 Topkfrequentelements | - | View Code |
| 115 | 3567 | 3567 Convert Date To Binary | Problem | convert-date-to-binary.py |
| 116 | 3581 | 3581 The Two Sneaky Numbers Of Digitville | Problem | the-two-sneaky-numbers-of-digitville.py |
| 117 | 3582 | 3582 Find Indices Of Stable Mountains | Problem | find-indices-of-stable-mountains.py |
| 118 | 373 | 373 Find K Pairs With Smallest Sums | Problem | find-k-pairs-with-smallest-sums.cpp |
| 119 | 3748 | 3748 Sort Matrix By Diagonals | Problem | sort-matrix-by-diagonals.java |
| 120 | 3778 | 3778 Transform Array By Parity | Problem | transform-array-by-parity.py |
| 121 | 3811 | 3811 Reverse Degree Of A String | Problem | reverse-degree-of-a-string.py |
| 122 | 3830 | 3830 Find Closest Person | Problem | find-closest-person.py |
| 123 | 4008 | 4008 Restore Finishing Order | Problem | restore-finishing-order.py |
| 124 | 4058 | 4058 Compute Alternating Sum | Problem | compute-alternating-sum.py |
| 125 | 4080 | 4080 Smallest Missing Multiple Of K | Problem | smallest-missing-multiple-of-k.py |
| 126 | 42 | 42 Trapping Rain Water | Problem | trapping-rain-water.py |
| 127 | 448 | 448 Find All Numbers Disappeared In An Array | Problem | find-all-numbers-disappeared-in-an-array.cpp |
| 128 | 451 | 451 Sort Characters By Frequency | Problem | sort-characters-by-frequency.py |
| 129 | 48 | 48 Rotate Image | Problem | rotate-image.java |
| 130 | 485 | 485 Max Consecutive Ones | Problem | max-consecutive-ones.py |
| 131 | 49 | 49 Groupanagrams | - | View Code |
| 132 | 5 | 5 Longest Palindromic Substring | Problem | longest-palindromic-substring.py |
| 133 | 50 | 50 Pow | X,N | - |
| 134 | 53 | 53 Maximum Subarray | Problem | maximum-subarray.java |
| 135 | 54 | 54 Spiralmatrix | - | View Code |
| 136 | 58 | 58 Length Of Last Word | Problem | length-of-last-word.py |
| 137 | 5 | 5 Longestpalindromicsubstring | - | View Code |
| 138 | 60 | 60 Permutation Sequence | Problem | permutation-sequence.py |
| 139 | 636 | 636 Exclusive Time Of Functions | Problem | exclusive-time-of-functions.cpp |
| 140 | 645 | 645 Set Mismatch | Problem | set-mismatch.cpp |
| 141 | 65 | 65 Validnumber | - | View Code |
| 142 | 66 | 66 Plus One | Problem | plus-one.py |
| 143 | 68 | 68 Text Justification | Problem | text-justification.java |
| 144 | 69 | 69 Sqrtx | Problem | sqrtx.py |
| 145 | 7 | 7 Reverse Integer | Problem | reverse-integer.py |
| 146 | 73 | 73 Set Matrix Zeroes | Problem | set-matrix-zeroes.java |
| 147 | 739 | 739 Daily Temperatures | Problem | daily-temperatures.cpp |
| 148 | 74 | 74 Search A 2D Matrix | Problem | search-a-2d-matrix.py |
| 149 | 75 | 75 Sort Colors | Problem | sort-colors.java |
| 150 | 78 | 78 Subsets | Problem | subsets.py |
| 151 | 782 | 782 Jewels And Stones | Problem | - |
| 152 | 8 | 8 String To Integer Atoi | Problem | string-to-integer-atoi.py |
| 153 | 808 | 808 Soupservings | - | View Code |
| 154 | 825 | 825 Max Increase To Keep City Skyline | Problem | max-increase-to-keep-city-skyline.py |
| 155 | 84 | 84 Largest Rectangle In Histogram | Problem | largest-rectangle-in-histogram.cpp |
| 156 | 867 | 867 New 21 Game | Problem | new-21-game.py |
| 157 | 869 | 869 Reorderedpowerof2 | - | View Code |
| 158 | 88 | 88 Merge Sorted Array | Problem | merge-sorted-array.py |
| 159 | 9 | 9 Palindrome Number | Problem | palindrome-number.cpp |
| 160 | 907 | 907 Koko Eating Bananas | Problem | koko-eating-bananas.py |
| 161 | 908 | 908 Middle Of The Linked List | Problem | - |
| 162 | 909 | 909 Stone Game | Problem | stone-game.java |
| 163 | 90 | 90 Subsetsii | - | View Code |
| 164 | 93 | 93 Restore Ip Addresses | Problem | restore-ip-addresses.cpp |
| 165 | 932 | 932 Monotonic Array | Problem | monotonic-array.java |
| 166 | 9 | 9 Palindromenumber | - | View Code |
| 167 | - | Solutions | - | - |
(Click on View Code to open the file in GitHub.)
- Clone the repository
git clone https://github.com/HardikLovesTech/LeetCodeSolutions.git