Skip to content

therenotomorrow/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode

LeetCode problems and how I solved them.

Structure

  • Explore - useful technics shortcuts for learn
  • Solutions - all solved and refactored problems
  • Again - need resolve because of loosing day streak or not enough knowledge
  • Archive - all solved problems that in progress refactoring

Development

After adding some code samples run code.sh

./scripts/code.sh

You can automate this action by calling pre-commit.sh

Testing

./scripts/test.sh

Completed explores

Completed problems

# Problem Solution
1 Two Sum twosum_1.go
2 Add Two Numbers addtwonumbers.go
3 Longest Substring Without Repeating Characters lengthoflongestsubstring.go
4 Median of Two Sorted Arrays findmediansortedarrays.go
7 Reverse Integer reverse.go
9 Palindrome Number ispalindrome_1.go
19 Remove Nth Node From End of List removenthfromend.go
35 Search Insert Position searchinsert.go
49 Group Anagrams groupanagrams.go
53 Maximum Subarray maxsubarray.go
57 Insert Interval insert.go
58 Length of Last Word lengthoflastword.go
62 Unique Paths uniquepaths.go
69 Sqrt(x) mysqrt.go
70 Climbing Stairs climbstairs.go
76 Minimum Window Substring minwindow.go
79 Word Search exist.go
94 Binary Tree Inorder Traversal inordertraversal.go
100 Same Tree issametree.go
110 Balanced Binary Tree isbalanced.go
118 Pascal's Triangle generate.go
119 Pascal's Triangle II getrow.go
141 Linked List Cycle hascycle.go
143 Reorder List reorderlist.go
144 Binary Tree Preorder Traversal preordertraversal.go
145 Binary Tree Postorder Traversal postordertraversal.go
150 Evaluate Reverse Polish Notation evalrpn.go
157 Read N Characters Given Read4 solution.go
159 Longest Substring with At Most Two Distinct Characters lengthoflongestsubstringtwodistinct.go
160 Intersection of Two Linked Lists getintersectionnode.go
163 Missing Ranges findmissingranges.go
165 Compare Version Numbers compareversion.go
168 Excel Sheet Column Title converttotitle.go
169 Majority Element majorityelement.go
171 Excel Sheet Column Number titletonumber.go
175 Combine Two Tables 175.sql
181 Employees Earning More Than Their Managers 181.sql
182 Duplicate Emails 182.sql
183 Customers Who Never Order 183.sql
191 Number of 1 Bits hammingweight.go
193 Valid Phone Numbers 193.sh
195 Tenth Line 195.sh
196 Delete Duplicate Emails 196.sql
197 Rising Temperature 197.sql
198 House Robber rob.go
201 Bitwise AND of Numbers Range rangebitwiseand.go
202 Happy Number ishappy.go
205 Isomorphic Strings isisomorphic.go
206 Reverse Linked List reverselist.go
209 Minimum Size Subarray Sum minsubarraylen.go
219 Contains Duplicate II containsnearbyduplicate.go
222 Count Complete Tree Nodes countnodes.go
226 Invert Binary Tree inverttree.go
231 Power of Two ispoweroftwo.go
232 Implement Queue using Stacks myqueue.go
234 Palindrome Linked List ispalindrome_2.go
237 Delete Node in a Linked List deletenode.go
238 Product of Array Except Self productexceptself.go
242 Valid Anagram isanagram.go
243 Shortest Word Distance shortestdistance.go
246 Strobogrammatic Number isstrobogrammatic.go
252 Meeting Rooms canattendmeetings.go
253 Meeting Rooms II minmeetingrooms.go
256 Paint House mincost_2.go
257 Binary Tree Paths binarytreepaths.go
258 Add Digits adddigits.go
266 Palindrome Permutation canpermutepalindrome.go
268 Missing Number missingnumber.go
276 Paint Fence numways_2.go
279 Perfect Squares numsquares.go
283 Move Zeroes movezeroes.go
293 Flip Game generatepossiblenextmoves.go
296 Best Meeting Point mintotaldistance.go
300 Longest Increasing Subsequence lengthoflis.go
303 Range Sum Query - Immutable numarray.go
340 Longest Substring with At Most K Distinct Characters lengthoflongestsubstringkdistinct.go
342 Power of Four ispoweroffour.go
344 Reverse String reversestring.go
346 Moving Average from Data Stream movingaverage.go
349 Intersection of Two Arrays intersection.go
359 Logger Rate Limiter logger.go
367 Valid Perfect Square isperfectsquare.go
368 Largest Divisible Subset largestdivisiblesubset.go
380 Insert Delete GetRandom O(1) randomizedset.go
387 First Unique Character in a String firstuniqchar.go
404 Sum of Left Leaves sumofleftleaves.go
405 Convert a Number to Hexadecimal tohex.go
408 Valid Word Abbreviation validwordabbreviation.go
451 Sort Characters By Frequency frequencysort.go
452 Minimum Number of Arrows to Burst Balloons findminarrowshots.go
455 Assign Cookies findcontentchildren.go
458 Poor Pigs poorpigs.go
485 Max Consecutive Ones findmaxconsecutiveones_1.go
487 Max Consecutive Ones II findmaxconsecutiveones_2.go
501 Find Mode in Binary Search Tree findmode.go
506 Relative Ranks findrelativeranks.go
509 Fibonacci Number fib.go
513 Find Bottom Left Tree Value findbottomleftvalue.go
525 Contiguous Array findmaxlength.go
539 Minimum Time Difference findmindifference.go
543 Diameter of Binary Tree diameterofbinarytree.go
557 Reverse Words in a String III reversewords.go
572 Subtree of Another Tree issubtree.go
573 Squirrel Simulation mindistance.go
576 Out of Boundary Paths findpaths.go
606 Construct String from Binary Tree tree2str.go
621 Task Scheduler leastinterval.go
624 Maximum Distance in Arrays maxdistance.go
643 Maximum Average Subarray I findmaxaverage.go
645 Set Mismatch finderrornums.go
647 Palindromic Substrings countsubstrings.go
661 Image Smoother imagesmoother.go
680 Valid Palindrome II validpalindrome.go
704 Binary Search search.go
713 Subarray Product Less Than K numsubarrayproductlessthank.go
724 Find Pivot Index pivotindex.go
739 Daily Temperatures dailytemperatures.go
746 Min Cost Climbing Stairs mincostclimbingstairs.go
779 K-th Symbol in Grammar kthgrammar.go
791 Custom Sort String customsortstring.go
844 Backspace String Compare backspacecompare.go
867 Transpose Matrix transpose.go
872 Leaf-Similar Trees leafsimilar.go
876 Middle of the Linked List middlenode.go
881 Boats to Save People numrescueboats.go
905 Sort Array By Parity sortarraybyparity.go
907 Sum of Subarray Minimums sumsubarraymins.go
917 Reverse Only Letters reverseonlyletters.go
930 Binary Subarrays With Sum numsubarrayswithsum.go
931 Minimum Falling Path Sum minfallingpathsum.go
935 Knight Dialer knightdialer.go
938 Range Sum of BST rangesumbst.go
948 Bag of Tokens bagoftokensscore.go
977 Squares of a Sorted Array sortedsquares.go
997 Find the Town Judge findjudge.go
1002 Find Common Characters commonchars.go
1004 Max Consecutive Ones III longestones.go
1018 Binary Prefix Divisible By 5 prefixesdivby5.go
1026 Maximum Difference Between Node and Ancestor maxancestordiff.go
1051 Height Checker heightchecker.go
1057 Campus Bikes assignbikes_1.go
1066 Campus Bikes II assignbikes_2.go
1085 Sum of Digits in the Minimum Number sumofdigits.go
1099 Two Sum Less Than K twosumlessthank.go
1119 Remove Vowels from a String removevowels.go
1120 Maximum Average Subtree maximumaveragesubtree.go
1137 N-th Tribonacci Number tribonacci.go
1143 Longest Common Subsequence longestcommonsubsequence.go
1155 Number of Dice Rolls With Target Sum numrollstotarget.go
1160 Find Words That Can Be Formed by Characters countcharacters.go
1165 Single-Row Keyboard calculatetime.go
1167 Minimum Cost to Connect Sticks connectsticks.go
1171 Remove Zero Sum Consecutive Nodes from Linked List removezerosumsublists.go
1207 Unique Number of Occurrences uniqueoccurrences.go
1208 Get Equal Substrings Within Budget equalsubstring.go
1216 Valid Palindrome III isvalidpalindrome.go
1219 Path with Maximum Gold getmaximumgold.go
1239 Maximum Length of a Concatenated String with Unique Characters maxlength.go
1243 Array Transformation transformarray.go
1266 Minimum Time Visiting All Points mintimetovisitallpoints.go
1269 Number of Ways to Stay in the Same Place After Some Steps numways_1.go
1272 Remove Interval removeinterval.go
1287 Element Appearing More Than 25% In Sorted Array findspecialinteger.go
1291 Sequential Digits sequentialdigits.go
1295 Find Numbers with Even Number of Digits findnumbers.go
1325 Delete Leaves With a Given Value removeleafnodes.go
1337 The K Weakest Rows in a Matrix kweakestrows.go
1347 Minimum Number of Steps to Make Two Strings Anagram minsteps.go
1356 Sort Integers by The Number of 1 Bits sortbybits.go
1360 Number of Days Between Two Dates daysbetweendates.go
1361 Validate Binary Tree Nodes validatebinarytreenodes.go
1413 Minimum Value to Get Positive Step by Step Sum minstartvalue.go
1422 Maximum Score After Splitting a String maxscore.go
1424 Diagonal Traverse II finddiagonalorder.go
1428 Leftmost Column with at Least a One leftmostcolumnwithone.go
1436 Destination City destcity.go
1441 Build an Array With Stack Operations buildarray.go
1456 Maximum Number of Vowels in a Substring of Given Length maxvowels.go
1457 Pseudo-Palindromic Paths in a Binary Tree pseudopalindromicpaths.go
1463 Cherry Pickup II cherrypickup.go
1464 Maximum Product of Two Elements in an Array maxproduct.go
1470 Shuffle the Array shuffle.go
1480 Running Sum of 1d Array runningsum.go
1481 Least Number of Unique Integers after K Removals findleastnumofuniqueints.go
1496 Path Crossing ispathcrossing.go
1503 Last Moment Before All Ants Fall Out of a Plank getlastmoment.go
1535 Find the Winner of an Array Game getwinner.go
1561 Maximum Number of Coins You Can Get maxcoins.go
1578 Minimum Time to Make Rope Colorful mincost_1.go
1581 Customer Who Visited but Did Not Make Any Transactions 1581.sql
1582 Special Positions in a Binary Matrix numspecial.go
1603 Design Parking System parkingsystem.go
1609 Even Odd Tree isevenoddtree.go
1614 Maximum Nesting Depth of the Parentheses maxdepth.go
1624 Largest Substring Between Two Equal Characters maxlengthbetweenequalcharacters.go
1630 Arithmetic Subarrays checkarithmeticsubarrays.go
1633 Percentage of Users Attended a Contest 1633.sql
1637 Widest Vertical Area Between Two Points Containing No Points maxwidthofverticalarea.go
1642 Furthest Building You Can Reach furthestbuilding.go
1652 Defuse the Bomb decrypt.go
1657 Determine if Two Strings Are Close closestrings.go
1662 Check If Two String Arrays are Equivalent arraystringsareequal.go
1685 Sum of Absolute Differences in a Sorted Array getsumabsolutedifferences.go
1688 Count of Matches in Tournament numberofmatches.go
1669 Merge In Between Linked Lists mergeinbetween.go
1700 Number of Students Unable to Eat Lunch countstudents.go
1704 Determine if String Halves Are Alike halvesarealike.go
1716 Calculate Money in Leetcode Bank totalmoney.go
1720 Decode XORed Array decode.go
1732 Find the Highest Altitude largestaltitude.go
1743 Restore the Array From Adjacent Pairs restorearray.go
1750 Minimum Length of String After Deleting Similar Ends minimumlength.go
1757 Recyclable and Low Fat Products 1757.sql
1758 Minimum Changes To Make Alternating Binary String minoperations_1.go
1759 Count Number of Homogenous Substrings counthomogenous.go
1814 Count Nice Pairs in an Array countnicepairs.go
1822 Sign of the Product of an Array arraysign.go
1838 Frequency of the Most Frequent Element maxfrequency.go
1845 Seat Reservation Manager seatmanager.go
1846 Maximum Element After Decreasing and Rearranging maximumelementafterdecrementingandrearranging.go
1877 Minimize Maximum Pair Sum in Array minpairsum.go
1885 Count Pairs in Two Arrays countpairs.go
1887 Reduction Operations to Make the Array Elements Equal reductionoperations.go
1897 Redistribute Characters to Make All Strings Equal makeequal.go
1903 Largest Odd Number in String largestoddnumber.go
1913 Maximum Product Difference Between Two Pairs maxproductdifference.go
1921 Eliminate Maximum Number of Monsters eliminatemaximum.go
1930 Unique Length-3 Palindromic Subsequences countpalindromicsubsequence.go
1961 Check If String Is a Prefix of Array isprefixstring.go
1973 Count Nodes Equal to Sum of Descendants equaltodescendants.go
1980 Find Unique Binary String finddifferentbinarystring.go
1991 Find the Middle Index in Array findmiddleindex.go
2000 Reverse Prefix of Word reverseprefix.go
2032 Two Out of Three twooutofthree.go
2090 K Radius Subarray Averages getaverages.go
2108 Find First Palindromic String in the Array firstpalindrome.go
2125 Number of Laser Beams in a Bank numberofbeams.go
2149 Rearrange Array Elements by Sign rearrangearray.go
2225 Find Players With Zero or One Losses findwinners.go
2244 Minimum Rounds to Complete All Tasks minimumrounds.go
2259 Remove Digit From Number to Maximize Result removedigit.go
2264 Largest 3-Same-Digit Number in String largestgoodinteger.go
2265 Count Nodes Equal to Average of Subtree averageofsubtree.go
2331 Evaluate Boolean Binary Tree evaluatetree.go
2353 Design a Food Rating System foodratings.go
2357 Make Array Zero by Subtracting Equal Amounts minimumoperations.go
2385 Amount of Time for Binary Tree to Be Infected amountoftime.go
2391 Minimum Amount of Time to Collect Garbage garbagecollection.go
2433 Find The Original Array of Prefix Xor findarray.go
2441 Largest Positive Integer That Exists With Its Negative findmaxk.go
2482 Difference Between Ones and Zeros in Row and Column onesminuszeros.go
2485 Find the Pivot Integer pivotinteger.go
2487 Remove Nodes From Linked List removenodes.go
2490 Circular Sentence iscircularsentence.go
2540 Minimum Common Value getcommon.go
2549 Count Distinct Numbers on Board distinctintegers.go
2595 Number of Even and Odd Bits evenoddbit.go
2610 Convert an Array Into a 2D Array With Conditions findmatrix.go
2620 Counter createCounter.js
2667 Create Hello World Function createHelloWorld.js
2704 To Be Or Not To Be expect.js
2706 Buy Two Chocolates buychoco.go
2785 Sort Vowels in a String sortvowels.go
2816 Double a Number Represented as a Linked List doubleit.go
2849 Determine if a Cell Is Reachable at a Given Time isreachableattime.go
2864 Maximum Odd Binary Number maximumoddbinarynumber.go
2870 Minimum Number of Operations to Make Array Empty minoperations_2.go
2877 Create a DataFrame from List create_dataframe.py
2958 Length of Longest Subarray With at Most K Frequency maxsubarraylength.go
2966 Divide Array Into Arrays With Max Difference dividearray.go
2971 Find Polygon With the Largest Perimeter largestperimeter.go
3005 Count Elements With Maximum Frequency maxfrequencyelements.go
3062 Winner of the Linked List Game gameresult.go
3063 Linked List Frequency frequenciesofelements.go
3075 Maximize Happiness of Selected Children maximumhappinesssum.go

In revision

  1. Longest Palindromic Substring
  2. String to Integer (atoi)
  3. Container With Most Water
  4. Roman to Integer
  5. Longest Common Prefix
  6. Valid Parentheses
  7. Merge Two Sorted Lists
  8. Swap Nodes in Pairs
  9. Remove Duplicates from Sorted Array
  10. Remove Element
  11. Find the Index of the First Occurrence in a String
  12. Find First and Last Position of Element in Sorted Array
  13. Valid Sudoku
  14. Rotate Image
  15. Spiral Matrix
  16. Plus One
  17. Add Binary
  18. Simplify Path
  19. Remove Duplicates from Sorted List II
  20. Remove Duplicates from Sorted List
  21. Merge Sorted Array
  22. Reverse Linked List II
  23. Validate Binary Search Tree
  24. Symmetric Tree
  25. Binary Tree Level Order Traversal
  26. Binary Tree Zigzag Level Order Traversal
  27. Maximum Depth of Binary Tree
  28. Convert Sorted Array to Binary Search Tree
  29. Minimum Depth of Binary Tree
  30. Path Sum
  31. Best Time to Buy and Sell Stock
  32. Best Time to Buy and Sell Stock II
  33. Valid Palindrome
  34. Single Number
  35. LRU Cache
  36. Reverse Words in a String
  37. Min Stack
  38. Find Peak Element
  39. Two Sum II - Input Array Is Sorted
  40. Rotate Array
  41. Reverse Bits
  42. Binary Tree Right Side View
  43. Remove Linked List Elements
  44. Count Primes
  45. Contains Duplicate
  46. Implement Stack using Queues
  47. Summary Ranges
  48. Majority Element II
  49. Lowest Common Ancestor of a Binary Tree
  50. Sliding Window Maximum
  51. Closest Binary Search Tree Value
  52. First Bad Version
  53. Find the Duplicate Number
  54. Word Pattern
  55. Power of Three
  56. Odd Even Linked List
  57. Increasing Triplet Subsequence
  58. Counting Bits
  59. Flatten Nested List Iterator
  60. Integer Break
  61. Reverse Vowels of a String
  62. Intersection of Two Arrays II
  63. Guess Number Higher or Lower
  64. Ransom Note
  65. Shuffle an Array
  66. Find the Difference
  67. Is Subsequence
  68. Decode String
  69. Fizz Buzz
  70. Path Sum III
  71. Find All Anagrams in a String
  72. String Compression
  73. Delete Node in a BST
  74. Hamming Distance
  75. Next Greater Element I
  76. Diagonal Traverse
  77. Find Largest Value in Each Tree Row
  78. Minimum Absolute Difference in BST
  79. Subarray Sum Equals K
  80. Array Partition
  81. Permutation in String
  82. Can Place Flowers
  83. Dota2 Senate
  84. Search in a Binary Search Tree
  85. Insert into a Binary Search Tree
  86. Design HashMap
  87. Design Linked List
  88. Asteroid Collision
  89. Find Smallest Letter Greater Than Target
  90. Largest Number At Least Twice of Others
  91. Jewels and Stones
  92. Minimum Distance Between BST Nodes
  93. Bus Routes
  94. Binary Trees With Factors
  95. Peak Index in a Mountain Array
  96. Online Stock Span
  97. Number of Recent Calls
  98. Validate Stack Sequences
  99. Longest Arithmetic Subsequence
  100. Remove All Adjacent Duplicates In String
  101. Greatest Common Divisor of Strings
  102. Find in Mountain Array
  103. Print in Order
  104. Largest Unique Number
  105. Snapshot Array
  106. Maximum Level Sum of a Binary Tree
  107. Maximum Number of Balloons
  108. Count Vowels Permutation
  109. Check If It Is a Straight Line
  110. Count Number of Nice Subarrays
  111. Convert Binary Number in a Linked List to Integer
  112. Deepest Leaves Sum
  113. Number of Steps to Reduce a Number to Zero
  114. Count Negative Numbers in a Sorted Matrix
  115. Longest ZigZag Path in a Binary Tree
  116. Find Lucky Integer in an Array
  117. Build Array Where You Can Find The Maximum Exactly K Comparisons
  118. Constrained Subsequence Sum
  119. Counting Elements
  120. Kids With the Greatest Number of Candies
  121. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit
  122. Count Good Nodes in Binary Tree
  123. Max Dot Product of Two Subsequences
  124. Longest Subarray of 1's After Deleting One Element
  125. Can Make Arithmetic Progression From Sequence
  126. Number of Good Pairs
  127. Make The String Great
  128. Richest Customer Wealth
  129. Max Number of K-Sum Pairs
  130. Maximum Erasure Value
  131. Swapping Nodes in a Linked List
  132. Sum of Unique Elements
  133. Merge Strings Alternately
  134. Maximum Score of a Good Subarray
  135. Check if the Sentence Is Pangram
  136. Check if All Characters Have Equal Number of Occurrences
  137. Minimum Number of Operations to Make Array Continuous
  138. Remove Colored Pieces if Both Neighbors are the Same Color
  139. Parallel Courses III
  140. Reverse Nodes in Even Length Groups
  141. Delete the Middle Node of a Linked List
  142. Maximum Twin Sum of a Linked List
  143. Find the Difference of Two Arrays
  144. Add Two Integers
  145. Intersection of Multiple Arrays
  146. Number of Flowers in Full Bloom
  147. Minimum Consecutive Cards to Pick Up
  148. Number of Ways to Split Array
  149. Successful Pairs of Spells and Potions
  150. Max Sum of a Pair With Equal Sum of Digits
  151. First Letter to Appear Twice
  152. Equal Row and Column Pairs
  153. Removing Stars From a String
  154. Using a Robot to Print the Lexicographically Smallest String
  155. Total Cost to Hire K Workers
  156. Design Graph With Shortest Path Calculator
  157. Painting the Walls
  158. Largest Submatrix With Rearrangements
  159. Number of Ways to Divide a Long Corridor
  160. Minimum One Bit Operations to Make Integers Zero
  161. Decode Ways
  162. String Compression II
  163. Minimum Difficulty of a Job Schedule
  164. Maximum Profit in Job Scheduling
  165. Arithmetic Slices II - Subsequence
  166. K Inverse Pairs Array
  167. Number of Submatrices That Sum to Target
  168. Partition Array for Maximum Sum
  169. Meeting Rooms III
  170. Tree Diameter
  171. Cheapest Flights Within K Stops
  172. Greatest Common Divisor Traversal
  173. Find All People With Secret
  174. Find All Duplicates in an Array
  175. First Missing Positive