Skip to content

euchangxian/LeetCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Solutions

pipeline status coverage report

[[TOC]]


Initial Setup

Prerequisites

  • prettier (used to format the README in the pre-commit hook)

Steps

To ensure that the README table is automatically updated with new Solutions, follow these steps to set up a pre-commit hook:

git clone https://gitlab.com/euchangxian/leetcode.git
cd leetcode
bash setup_hook.sh

Description

Contains LeetCode Solutions written in different languages for ME to reference and track my progress.

Started with Go, but Go as an interview language to solve LeetCode questions is a poor choice, since Go's standard library is sorely lacking common data structures and/or algorithms.

Also, solving string/char questions in Go was painful due to runes and such.

Though, Go is still my favorite language by far for Software Engineering due to its ease of use and comprehensive standard library.

Tried Rust for the fun of it. Enjoyed it. Too time-consuming to deal with the borrow-checker when solving Graph questions. Though I would want to engineer some software with it some time in the future.

Now solving in C++. Like it.

Known Issues

  1. Rust solutions are not run-able. Rust requires a different sort of directory that is not really compatible with the way this Repository is structured.

  2. Code Coverage Badge showing unknown. This is a known issue with GitLab Child Pipelines. I could technically not use child pipelines, but for clean-code/configuration purposes, I would rather separate the concerns of each pipeline. Not knowing the test coverage is fine. This repository is not a Library.

Solutions

ID Problem Name Languages
1 TwoSum C++
2 AddTwoNumbers Rust C++
3 LongestSubstringWithoutRepeatingCharacters C++
4 FindMedianOfTwoSortedArrays C++
5 LongestPalindromicSubstring C++
6 ZigZagConversion C++
7 ReverseInteger C++
8 StringToIntegerAtoi C++
10 RegularExpressionMatching C++
11 ContainerWithMostWater C++
14 LongestCommonPrefix C++
15 ThreeSum C++
17 LetterCombinationsOfAPhoneNumber C++
19 RemoveNthNodeFromEndOfList C++
20 ValidParentheses C++
21 MergeTwoSortedLists C++
22 GenerateParentheses C++ Go
23 MergeKSortedLists C++
26 RemoveDuplicatesFromSortedArray C++
27 RemoveElement C++
30 SubstringWithConcatenationOfAllWords C++
31 NextPermutation C++
32 LongestValidParentheses Rust
33 SearchInRotatedSortedArray C++
34 FindFirstAndLastPositionOfElementInSortedArray C++
35 SearchInsertPosition C++
36 ValidSudoku C++
38 CountAndSay C++
39 CombinationSum C++
40 CombinationSumTwo C++
42 TrappingRainWater C++ Go
45 JumpGame Go
46 Permutations C++
48 RotateImage C++
49 GroupAnagrams C++
54 SpiralMatrix C++
55 JumpGame Go C++
56 MergeIntervals C++
57 InsertInterval C++
58 LengthOfLastWord Rust
59 SpiralMatrixTwo C++
61 RotateList C++
62 UniquePaths Go C++
63 UniquePathsII Go
64 MinimumPathSum Go
66 PlusOne C++
67 AddBinary Go
69 Sqrt C++
70 ClimbingStairs Go
72 EditDistance Rust
73 SetMatrixZeroes C++
74 SearchA2DMatrix C++
75 SortColors C++
76 MinimumWindowSubstring C++
78 Subsets C++
84 LargestRectangleInHistogram C++
91 DecodeWays C++
94 BinaryTreeInorderTraversal Go
96 UniqueBinarySearchTrees C++
97 InterleavingString Rust
98 ValidateBinarySearchTree Go C++
100 SameTree C++
102 BinaryTreeLevelOrderTraversal C++
104 MaximumDepthOfBinaryTree C++
105 ConstructBinaryTreeFromPreorderAndInorderTraversal C++
110 BalancedBinaryTree C++
115 DistinctSubsequences C++
118 PascalsTriangle Go
120 Triangle Go
121 BestTimeToBuyAndSellStock C++ Go
122 BestTimeToBuyAndSellStockTwo Go
125 ValidPalindrome C++
127 WordLadder C++
128 LongestConsecutiveSequence C++
130 SurroundedRegions C++
131 PalindromePartitioning C++
136 SingleNumber Go C++
139 WordBreak C++
140 WordBreakTwo C++
141 LinkedListCycle C++
144 BinaryTreePreorderTraversal Go
145 BinaryTreePostorderTraversal Go C++
146 LRUCache C++
150 EvaluateReversePolishNotation C++
152 MaximumProductSubarray C++
153 FindMinimumInRotatedSortedArray C++
155 MinStack C++
162 FindPeakElement C++
165 CompareVersionNumbers Go
167 TwoSumTwo C++
169 MajorityElement C++
170 TwoSumThree C++
173 BinarySearchTreeIterator C++
179 LargestNumber C++
190 ReverseBits C++
191 NumberOf1Bit C++
198 HouseRobber C++
199 BinaryTreeRightSideView Go C++
200 NumberOfIslands C++
206 ReverseLinkedList C++
207 CourseSchedule C++
208 ImplementTriePrefixTree C++
210 CourseScheduleTwo C++
211 DesignAddAndSearchWordsDataStructure C++
213 HouseRobberTwo C++
214 ShortestPalindrome C++
215 KthLargestElementInAnArray C++
219 ContainsDuplicateTwo C++
220 ContainsDuplicateThree C++
221 MaximalSquare C++
225 ImplementStackUsingQueues C++
226 InvertBinaryTree C++
232 ImplementQueueUsingStacks C++
235 LowestCommonAncestorOfABinarySearchTree C++
236 LowestCommonAncestorOfABinaryTree C++
237 DeleteNodeInALinkedList Go
238 ProductOfArrayExceptSelf C++
239 SlidingWindowMaximum C++
241 DifferentWaysToAddParentheses C++
243 ShortestWordDistance C++
244 ShortestWordDistanceTwo C++
245 ShortestWordDistanceThree C++
251 Flatten2DVector C++
252 MeetingRooms C++
253 MeetingRoomsTwo C++
256 PaintHouse C++
260 SingleNumberThree C++
261 GraphValidTree C++
264 UglyNumberTwo C++
265 PaintHouseTwo C++
268 MissingNumber C++
269 AlienDictionary C++
271 EncodeAndDecodeStrings C++
273 IntegerToEnglishWords C++
278 FirstBadVersion C++
281 ZigZagIterator C++
283 MoveZeroes C++
284 PeekingIterator C++
286 WallsAndGates C++
287 FindTheDuplicateNumber C++
288 UniqueWordAbbreviation C++
295 FindMedianFromDataStream C++
297 SerializeAndDeserializeBinaryTree C++
300 LongestIncreasingSubsequence C++
303 RangeSumQueryImmutable C++
304 RangeSumQuery2DImmutable C++
307 RangeSumQueryMutable C++
309 BestTimeToBuyAndSellStockWithCooldown C++
322 CoinChange C++
323 NumberOfConnectedComponentsInAnUndirectedGraph C++
325 MaximumSizeSubarraySumEqualsK C++
329 LongestIncreasingPathInAMatrix C++
332 ReconstructItinerary C++
338 CountingBits C++
344 ReverseString C++
346 MovingAverageFromDataStream C++
347 TopKFrequentElements C++
350 IntersectionOfTwoArrays C++
355 DesignTwitter C++
359 LoggerRateLimiter C++
362 DesignHitCounter C++
380 InsertDeleteGetRandomO1 C++
381 InsertDeleteGetRandomO1WithDuplicates C++
386 LexicographicalNumebrs C++
394 DecodeString C++
395 LongestSubstringWithAtLeastKRepeatingCharacters C++
399 EvaluateDivision C++
402 RemoveKDigits Go
404 SumOfLeftLeaves Go
407 TrappingRainWaterTwo C++
409 LongestPalindrome C++
410 SplitArrayLargestSum C++
416 PartitionEqualSubsetSum C++
417 PacificAtlanticWaterFlow C++
424 LongestRepeatingCharacterReplacement C++
431 FizzBuzz C++
432 AllOOneDataStructure C++
435 NonOverlappingIntervals C++
440 KthSmallestInLexicographicalOrder C++
443 StringCompression C++
452 MinimumNumberOfArrowsToBurstBalloons Go
460 LFUCache C++
464 CanIWin C++
476 NumberComplement C++
494 TargetSum C++
506 RelativeRanks Go
518 CoinChangeTwo C++
523 ContinuousSubarraySum C++
525 ContiguousArray C++
528 RandomPickWithWeight C++
539 MinimumTimeDifference C++
543 DiameterOfBinaryTree C++
552 StudentAttendanceRecordTwo C++
564 FindTheClosestPalindrome C++
567 PermutationInString C++
572 SubtreeOfAnotherTree C++
590 NaryTreePostorderTraversal C++
592 FractionAdditionAndSubtraction C++
604 DesignCompressedStringIterator C++
605 CanPlaceFlowers Go
621 TaskScheduler C++
622 DesignCircularQueue C++
624 MaximumDistanceInArrays C++
632 SmallestRangeCoveringElementsFromKLists C++
641 DesignCircularQueue C++
645 SetMismatch C++
647 PalindromicSubstring C++
648 ReplaceWords C++
650 2KeysKeyboard C++
664 StrangePrinter C++
670 MaximumSwap C++
684 RedundantConnection C++
695 MaxAreaOfIsland C++
703 KthLargestElementInAStream C++
704 BinarySearch C++
705 DesignHashSet C++
706 DesignHashMap C++
713 SubarrayProductLessThanK C++
719 FindKthSmallestPairDistance C++
725 SplitLinkedListInParts C++
726 NumberOfAtoms C++
729 MyCalendarOne C++
731 MyCalendarTwo C++
732 MyCalendarThree C++
735 AsteroidCollision C++
739 DailyTemperatures C++ Go
740 DeleteAndEarn C++
743 NetworkDelayTime C++
746 MinCostClimbingStairs C++
752 OpenTheLock C++
778 SwimInRisingWater C++
785 IsGraphBipartite C++
786 KthSmallestPrimeFraction Rust
787 CheapestFlightWithinKStops C++
796 RotateString C++
840 MagicSquaresInAGrid C++
846 HandOfStraights C++
853 CarFleet C++
857 MinimumCostToHireKWorkers Rust
860 LemonadeChange C++
861 ScoreAfterFlippingMatrix Rust
874 WalkingRobotSimulation C++
875 KokoEatingBananas C++
881 BoatsToSavePeople Go
884 UncommonWordsFromTwoSentences C++
885 SpiralMatrixThree C++
887 SuperEggDrop C++
895 MaximumFrequencyStack C++
912 SortAnArray C++
921 MinimumAddToMakeParenthesesValid C++
926 FlipStringToMonotoneIncreasing C++
931 MinimumFallingPathSum C++
933 NumberOfRecentCalls C++
938 RangeSumOfBST Go
945 MinimumIncrementToMakeArrayUnique C++
947 MostStonesRemovedWithSameRowOrColumn C++
951 FlipEquivalentBinaryTrees C++
959 RegionsCutBySlashes C++
962 MaximumWidthRamp C++
973 KClosestPointToOrigin C++
974 SubarraySumsDivisibleByK C++
979 DistributeCoinsInBinaryTree C++
981 TimeBasedKeyValueStore C++
993 CousinsInBinaryTree C++
994 RottingOranges C++
1002 FindCommonCharacters C++
1011 CapacityToShipPackagesWithinDDays C++
1014 BestSightseeingPair C++
1046 LastStoneWeight C++
1049 LastStoneWeightTwo C++
1051 HeightChecker C++
1071 GCDOfStrings Go C++
1101 TheEarliestMomentWhenEveryoneBecomesFriends C++
1105 FillingBookcaseShelves C++
1106 ParsingABooleanExpression C++
1110 DeleteNodesAndReturnForest C++
1114 PrintInOrder C++
1116 PrintZeroEvenOdd C++
1122 RelativeSortArray C++
1133 LargestUniqueNumber C++
1140 StoneGameTwo C++
1143 LongestCommonSubsequence Go C++
1161 MaximumLevelSumOfABinaryTree C++
1190 ReverseSubstringsBetweenEachPairOfParentheses C++
1208 GetEqualSubstringsWithinBudget C++
1213 IntersectionOfThreeSortedArrays C++
1219 PathWithMaximumGold Rust
1229 MeetingScheduler C++
1233 RemoveSubFoldersFromTheFilesystem C++
1255 MaximumScoreWordsFormedByLetters C++
1257 SmallestCommonRegion C++
1268 SearchSuggestionSystem C++
1277 CountSquareSubmatricesWithOnes C++
1283 FindTheSmallestDivisorGivenAThreshold C++
1293 ShortestPathInAGridWithObstaclesElimination C++
1310 XORQueriesOfASubarray C++
1317 ConvertIntegerToTheSumOfTwoNoZeroIntegers C++
1323 Maximum69Number C++
1325 DeleteLeavesWithAGivenValue C++
1331 RankTransformOfAnArray C++
1334 FindTheCityWithTheSmallestNumberOfNeighboursAtAThresholdDistance C++
1342 NumberOfStepsToReduceANumberToZero C++
1348 TweetCountsPerFrequency C++
1356 SortIntegersByTheNumberOf1Bits C++
1367 LinkedListInBinaryTree C++
1371 FindTheLongestSubstringContainingVowelsInEvenCounts C++
1380 LuckyNumbersInAMatrix C++
1381 DesignAStackWithIncrementOperation C++
1395 CountNumberOfTeams C++
1404 NumberOfStepsToReduceANumberInBinaryRepresentationToOne C++
1405 LongestHappyString C++
1423 MaximumPointsYouCanObtainFromCards C++
1429 FirstUniqueNumber C++
1431 KidsWithGreatestNumberOfCandies Go
1441 BuildAnArrayWithStackOperations C++
1442 CountTripletsThatCanFormTwoArraysOfEqualXOR C++
1460 MakeTwoArraysEqualByReversingSubarrays C++
1464 MaximumProductOfTwoElementsInAnArray C++
1472 DesignBrowserHistory C++
1482 MinimumNumberOfDaysToMakeMBouquets C++
1497 CheckIfArrayPairsAreDivisibleByK C++
1502 CanMakeArithmeticProgressionFromSequence C++
1508 RangeSumOfSortedSubArraySums C++
1509 MinimumDifferenceBetweenLargestAndSmallestValueInThreeMoves C++
1514 PathWithMaximumProbability C++
1518 WaterBottles C++
1526 MinimumNumberOfIncrementsOnSubarraysToFormATargetArray C++
1530 NumberOfGoodLeafNodesPairs C++
1545 FindKthBitInNthBinaryString C++
1550 ThreeConsecutiveOdds C++
1566 DetectPatternsOfLengthMRepeatedKOrMoreTimes C++
1568 MinimumNumberOfDaysToDisconnectIsland C++
1574 ShortestSubarrayToBeRemovedToMakeArraySorted C++
1584 MinCostToConnectAllPoints C++
1590 MakeSumDivisibleByP C++
1593 SplitAStringIntoTheMaxNumberOfUniqueSubstrings C++
1598 CrawlerLogFolder C++
1603 DesignParkingSystem C++
1605 FindValidMatrixGivenRowAndColumnSums C++
1608 SpecialArrayWithXElementsGreaterThanOrEqualX C++
1631 PathWithMinimumEffort C++
1634 AddTwoPolynomialsRepresentedAsLinkedLists C++
1636 SortArrayByIncreasingFrequency C++
1652 DefuseTheBomb C++
1653 MinimumDeletionsToMakeStringsBalanced C++
1656 DesignAnOrderedStream C++
1671 MinimumNumberOfRemovalsToMakeMountainArray C++
1684 CountTheNumberOfConsistentStrings C++
1700 NumberOfStudentsUnableToEatLunch Go
1701 AverageWaitingTime C++
1717 MaximumScoreFromRemovingSubstrings C++
1730 ShortestPathToGetFood C++
1760 MinimumLimitOfBallsInABag C++
1768 MergeStringsAlternately Go
1770 MaximumScoreFromPerformingMultiplicationOperations C++
1791 FindCenterOfStarGraph C++
1813 SentenceSimilarityThree C++
1823 FindTheWinnerOfTheCircularGame C++
1829 MaximumXORForEachQuery C++
1845 SeatReservationManager C++
1863 SumOfAllSubsetXORTotals C++
1884 EggDropWith2EggsAndNFloors Go C++
1894 FindTheStudentThatWillReplaceTheChalk C++
1897 RedistributeCharactersToMakeAllStringsEqual C++
1905 CountSubIslands C++
1937 MaximumNumberOfPointsWithCost C++
1942 TheNumberOfTheSmallestUnoccupiedChair C++
1945 SumOfDigitsOfStringAfterConvert C++
1953 MaximumNumberOfWeeksForWhichYouCanWork C++
1957 DeleteCharactersToMakeFancyString C++
1962 RemoveStonesToMinimizeTheTotal C++
1963 MinimumNumberOfSwapsToMakeTheStringsBalanced C++
1979 FindGreatestCommonDivisorOfArray C++
2000 ReversePrefixOfWord Go
2022 Convert1DArrayTo2DArray C++
2028 FindMissingObservations C++
2037 MinimumNumberOfMovesToSeatEveryone C++
2044 CountNumberOfMaximumBitwiseORSubsets C++
2045 SecondMinimumTimeToReachDestination C++
2053 KthDistinctStringInAnArray C++
2058 FindTheMinimumAndMaximumNumberOfNodesBetweenCriticalPoints C++
2064 MinimizedMaximumOfProductsDistributedToAnyStore C++
2070 MostBeautifulItemForEachQuery C++
2073 TimeNeededToBuyTickets Go
2096 StepByStepDirectionsFromABinaryTreeNodeToAnother C++
2107 NumberOfUniqueFlavorsAfterSharingKCandies C++
2134 MinimumSwapsToGroupAllOnesTogetherTwo C++
2166 DesignBitset C++
2181 MergeNodesInBetweenZeros C++
2191 SortTheJumbledNumbers C++
2196 CreateBinaryTreeFromDescriptions C++
2208 MinimumOperationsToHalveArraySum C++
2220 MinimumBitFlipsToConvertNumber C++
2246 LongestPathWithDifferentAdjacentCharacters C++
2254 DesignVideoSharingPlatform C++
2275 LargestCombinationWithBitwiseANDGreaterThanZero C++
2285 MaximumTotalImportanceOfRoads C++
2290 MinimumObstacleRemovalToReachCorner C++
2294 PartitionArraySuchThatMaximumDifferenceIsK C++
2307 CheckForContradictionsInEquations C++
2326 SpiralMatrixFour C++
2331 EvaluateBooleanBinaryTree Rust C++
2334 SubarrayWithElementsGreaterThanVaryingThreshold C++
2336 SmallestNumberInInfiniteSet C++
2349 DesignANumberContainerSystem C++
2371 MinimizeMaximumValueInAGrid C++
2373 LargestLocalValuesInAMatrix Rust
2392 BuildAMatrixWithConditions C++
2393 CountStrictlyIncreasingSubarrays C++
2406 DivideIntervalsIntoMinimumNumberOfGroups C++
2416 SumOfPrefixScoresOfStrings C++
2418 SortThePeople C++
2419 LongestSubarrayWithMaximumBitwiseAND C++
2441 LargestPositiveIntegerThatExistsWithItsNegative Go
2444 CountSubarraysWithFixedBounds C++
2458 HeightOfBinaryTreeAfterSubtreeRemoval C++
2463 MinimumTotalDistanceTraveled C++
2486 AppendCharactersToMakeSubsequence C++
2487 RemoveNodesFromLinkedList Go
2490 CircularSentence C++
2491 DividePlayersIntoTeamsOfEqualSkills C++
2501 LongestSquareStreakInAnArray C++
2508 AddEdgesToMakeDegreesOfAllNodesEven C++
2530 MaximalScoreAfterApplyingKOperations C++
2563 CountTheNumberOfFairPairs C++
2582 PassThePillow C++
2583 KthLargestSumInABinaryTree C++
2588 CountTheNumberOfBeautifulSubarrays C++
2597 TheNumberOfBeautifulSubsets C++
2601 PrimeSubtractionOperation C++
2641 CousinsInBinaryTreeTwo C++
2664 TheKnightsTour C++
2678 NumberOfSeniorCitizens C++
2684 MaximumNumberOfMovesInAGrid C++
2685 CountTheNumberOfCompletedComponents C++
2696 MinimumStringLengthAfterRemovingSubstrings C++
2699 ModifyGraphEdgeWeights C++
2702 MinimumOperationsToMakeNumbersNonPositive C++
2707 ExtraCharactersInAString C++
2712 MinimumCostToMakeAllCharactersEqual C++
2751 RobotCollisions C++
2779 MaximumBeautyOfAnArrayAfterApplyingOperations C++
2807 InsertGreatestCommonDivisorInLinkedList C++
2812 FindTheSafestPathInAGrid Rust
2816 DoubleANumberRepresentedAsALinkedList Go
2830 MaximizeTheProfitAsASalesman Go
2838 MaximumCoinsHeroesCanCollect C++
2914 MinimumNumberOfChangesToMakeBinaryStringBeautiful C++
2931 MaximumSpendingAfterBuyingItems C++
2938 SeparateBlackAndWhiteBalls C++
2955 NumberOfSameEndSubstrings C++
2976 MinimumCostToConvertStringOne C++
3008 FindBeautifulIndicesInTheGivenArrayTwo C++
3011 FindIfArrayCanBeSorted C++
3016 MinimumNumberOfPushesToTypeWordTwo C++
3043 FindTheLengthOfTheLongestCommonPrefix C++
3066 MinimumOperationsToExceedThresholdValueTwo C++
3068 FindTheMaximumSumOfNodeValues C++
3075 MaximizeHappinessOfSelectedChildren Rust Go
3097 ShortestSubarrayWithORAtLeastKTwo C++
3110 ScoreOfAString C++
3133 MinimumArrayEnd C++
3157 FindTheLevelOfTreeWithMinimumSum C++
3163 StringCompressionThree C++
3217 DeleteNodesFromLinkedListPresentInArray C++
3242 DesignNeighbourSumService C++
3254 FindThePowerOfKSizeSubarraysOne C++
3286 FindASafeWalkThroughAGrid C++

Releases

No releases published

Packages

No packages published