Skip to content

chyuck/leet-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solutions for LeetCode problems Solutions for LeetCode problems

# Difficulty Problem Solution
1 Easy Two Sum TwoSum.java (Tests)
2 Medium Add Two Numbers AddTwoNumbers.java (Tests)
3 Medium Longest Substring Without Repeating Characters LongestSubstringWithoutRepeatingCharacters.java (Tests)
4 Hard Median of Two Sorted Arrays MedianOfTwoSortedArrays.java (Tests)
5 Medium Longest Palindromic Substring LongestPalindromicSubstring.java (Tests)
7 Easy Reverse Integer ReverseInteger.java (Tests)
8 Medium String to Integer (atoi) StringToIntegerAtoi.java (Tests)
11 Medium Container With Most Water ContainerWithMostWater.java (Tests)
12 Medium Integer to Roman IntegerToRoman.java (Tests)
13 Easy Roman to Integer RomanToInteger.java (Tests)
14 Easy Longest Common Prefix LongestCommonPrefix.java (Tests)
15 Medium 3Sum ThreeSum.java (Tests)
17 Medium Letter Combinations of a Phone Number LettersOfPhoneNumber.java (Tests)
20 Easy Valid Parentheses ValidParentheses.java (Tests)
21 Easy Merge Two Sorted Lists MergeTwoSortedLists.java (Tests)
22 Medium Generate Parentheses GenerateParentheses.java (Tests)
23 Hard Merge k Sorted Lists MergeKSortedLists.java (Tests)
26 Easy Remove Duplicates from Sorted Array RemoveDuplicatesFromSortedArray.java (Tests)
28 Easy Implement strStr() ImplementStrStr.java (Tests)
29 Medium Divide Two Integers DivideTwoIntegers.java (Tests)
31 Medium Next Permutation NextPermutation.java (Tests)
33 Medium Search in Rotated Sorted Array SearchInRotatedSortedArray.java (Tests)
34 Medium Find First and Last Position of Element in Sorted Array FindFirstAndLastPositionOfElementInSortedArray.java (Tests)
37 Hard Sudoku Solver SudokuSolver.java (Tests)
38 Easy Count and Say CountAndSay.java (Tests)
42 Hard Trapping Rain Water TrappingRainWater.java (Tests)
48 Medium Rotate Image RotateImage.java (Tests)
49 Medium Group Anagrams GroupAnagrams.java (Tests)
50 Medium Pow(x, n) PowxN.java (Tests)
53 Easy Maximum Subarray MaximumSubarray.java (Tests)
56 Medium Merge Intervals MergeIntervals.java (Tests)
57 Hard Insert Interval InsertInterval.java (Tests)
65 Hard Valid Number ValidNumber.java (Tests)
66 Easy Plus One PlusOne.java (Tests)
67 Easy Add Binary AddBinary.java (Tests)
69 Easy Sqrt(x) Sqrtx.java (Tests)
70 Easy Climbing Stairs ClimbingStairs.java (Tests)
71 Medium Simplify Path SimplifyPath.java (Tests)
72 Hard Edit Distance EditDistance.java (Tests)
73 Medium Set Matrix Zeroes SetMatrixZeroes.java (Tests)
76 Hard Minimum Window Substring MinimumWindowSubstring.java (Tests)
78 Medium Subsets Subsets.java (Tests)
79 Medium Word Search WordSearch.java (Tests)
81 Medium Search in Rotated Sorted Array II SearchInRotatedSortedArray2.java (Tests)
84 Hard Largest Rectangle in Histogram LargestRectangleInHistogram.java (Tests)
85 Hard Maximal Rectangle MaximalRectangle.java (Tests)
88 Easy Merge Sorted Array MergeSortedArray.java (Tests)
89 Medium Gray Code GrayCode.java (Tests)
101 Easy Symmetric Tree SymmetricTree.java (Tests)
102 Medium Binary Tree Level Order Traversal BinaryTreeLevelOrderTraversal.java (Tests)
103 Medium Binary Tree Zigzag Level Order Traversal BinaryTreeZigzagTraversal.java (Tests)
104 Easy Maximum Depth of Binary Tree MaximumDepthOfBinaryTree.java (Tests)
108 Easy Convert Sorted Array to Binary Search Tree ConvertSortedArrayToBinarySearchTree.java (Tests)
118 Easy Pascal's Triangle PascalTriangle.java (Tests)
119 Easy Pascal's Triangle II PascalTriangle2.java (Tests)
121 Easy Best Time to Buy and Sell Stock BestTimeBuySellStock.java (Tests)
122 Easy Best Time to Buy and Sell Stock II BestTimeBuySellStock2.java (Tests)
123 Hard Best Time to Buy and Sell Stock III BestTimeBuySellStock3.java (Tests)
124 Hard Binary Tree Maximum Path Sum BinaryTreeMaximumPathSum.java (Tests)
125 Easy Valid Palindrome ValidPalindrome.java (Tests)
126 Hard Word Ladder II WordLadder2.java (Tests)
127 Medium Word Ladder WordLadder.java (Tests)
130 Medium Surrounded Regions SurroundedRegions.java (Tests)
133 Medium Clone Graph CloneGraph.java (Tests)
136 Easy Single Number SingleNumber.java (Tests)
138 Medium Copy List with Random Pointer CopyListWithRandomPointer.java (Tests)
139 Medium Word Break WordBreak.java (Tests)
140 Hard Word Break II WordBreak2.java (Tests)
141 Easy Linked List Cycle LinkedListCycle.java (Tests)
146 Medium LRU Cache LRUCache.java (Tests)
152 Medium Maximum Product Subarray MaximumProductSubarray.java (Tests)
155 Easy Min Stack MinStack.java (Tests)
157 Easy Read N Characters Given Read4 ReadNCharactersGivenRead4.java (Tests)
158 Hard Read N Characters Given Read4 II - Call multiple times ReadNCharactersGivenRead42.java (Tests)
160 Easy Intersection of Two Linked Lists IntersectionOfTwoLinkedLists.java (Tests)
165 Medium Compare Version Numbers CompareVersionNumbers.java (Tests)
166 Medium Fraction to Recurring Decimal FractionToRecurringDecimal.java (Tests)
167 Easy Two Sum II - Input array is sorted TwoSum2InputArrayIsSorted.java (Tests)
169 Easy Majority Element MajorityElement.java (Tests)
171 Easy Excel Sheet Column Number ExcelSheetColumnNumber.java (Tests)
173 Medium Binary Search Tree Iterator BinarySearchTreeIterator.java (Tests)
184 Medium Department Highest Salary DepartmentHighestSalary.sql
188 Hard Best Time to Buy and Sell Stock IV BestTimeBuySellStock4.java (Tests)
189 Easy Rotate Array RotateArray.java (Tests)
190 Easy Reverse Bits ReverseBits.java (Tests)
198 Easy House Robber HouseRobber.java (Tests)
199 Medium Binary Tree Right Side View BinaryTreeRightSideView.java (Tests)
200 Medium Number of Islands NumberOfIslands.java (Tests)
202 Easy Happy Number HappyNumber.java (Tests)
204 Easy Count Primes CountPrimes.java (Tests)
206 Easy Reverse Linked List ReverseLinkedList.java (Tests)
207 Medium Course Schedule CourseSchedule.java (Tests)
211 Medium Add and Search Word - Data structure design AddAndSearchWordDataStructureDesign.java (Tests)
212 Hard Word Search II WordSearch2.java (Tests)
215 Medium Kth Largest Element in an Array KthLargestElementInArray.java (Tests)
217 Easy Contains Duplicate ContainsDuplicate.java (Tests)
221 Medium Maximal Square MaximalSquare.java (Tests)
224 Hard Basic Calculator BasicCalculator.java (Tests)
227 Medium Basic Calculator II BasicCalculator2.java (Tests)
230 Medium Kth Smallest Element in a BST KthSmallestElementInBST.java (Tests)
234 Easy Palindrome Linked List PalindromeLinkedList.java (Tests)
235 Easy Lowest Common Ancestor of a Binary Search Tree LowestCommonAncestorOfBST.java (Tests)
236 Medium Lowest Common Ancestor of a Binary Tree LowestCommonAncestorOfBT.java (Tests)
237 Easy Delete Node in a Linked List DeleteNodeInALinkedList.java (Tests)
238 Medium Product of Array Except Self ProductOfArrayExceptSelf.java (Tests)
239 Hard Sliding Window Maximum SlidingWindowMaximum.java (Tests)
240 Medium Search a 2D Matrix II Search2dMatrix2.java (Tests)
242 Easy Valid Anagram ValidAnagram.java (Tests)
249 Medium Group Shifted Strings GroupShiftedStrings.java (Tests)
252 Easy Meeting Rooms MeetingRooms.java (Tests)
253 Medium Meeting Rooms II MeetingRooms2.java (Tests)
257 Easy Binary Tree Paths BinaryTreePaths.java (Tests)
266 Easy Palindrome Permutation PalindromePermutation.java (Tests)
268 Easy Missing Number MissingNumber.java (Tests)
269 Hard Alien Dictionary AlienDictionary.java (Tests)
270 Easy Closest Binary Search Tree Value ClosestBinarySearchTreeValue.java (Tests)
273 Hard Integer to English Words IntegerToEnglishWords.java (Tests)
278 Easy First Bad Version FirstBadVersion.java (Tests)
282 Hard Expression Add Operators ExpressionAddOperators.java (Tests)
283 Easy Move Zeroes MoveZeroes.java (Tests)
295 Hard Find Median from Data Stream MedianFinder.java (Tests)
297 Hard Serialize and Deserialize Binary Tree SerializeAndDeserializeBT.java (Tests)
299 Easy Bulls and Cows BullsAndCows.java (Tests)
301 Hard Remove Invalid Parentheses RemoveInvalidParentheses.java (Tests)
311 Medium Sparse Matrix Multiplication SparseMatrixMultiplication.java (Tests)
314 Medium Binary Tree Vertical Order Traversal BinaryTreeVerticalOrderTraversal.java (Tests)
315 Hard Count Of Smaller Numbers After Self CountOfSmallerNumbersAfterSelf.java (Tests)
322 Medium Coin Change CoinChange.java (Tests)
323 Medium Number of Connected Components in an Undirected Graph NumberOfConnectedComponentsInGraph.java (Tests)
329 Hard Longest Increasing Path in a Matrix LongestIncreasingPathInAMatrix.java (Tests)
339 Easy Nested List Weight Sum NestedListWeightSum.java (Tests)
340 Hard Longest Substring with At Most K Distinct Characters LongestSubstringWithAtMostKDistinctCharacters.java (Tests)
344 Easy Reverse String ReverseString.java (Tests)
346 Easy Moving Average from Data Stream MovingAverageFromDataStream.java (Tests)
347 Medium Top K Frequent Elements TopKFrequentElements.java (Tests)
348 Medium Design Tic-Tac-Toe TicTacToe.java (Tests)
350 Easy Intersection of Two Arrays II IntersectionOfTwoArrays2.java (Tests)
359 Easy Logger Rate Limiter LoggerRateLimiter.java (Tests)
362 Medium Design Hit Counter HitCounter.java (Tests)
371 Easy Sum of Two Integers SumOfTwoIntegers.java (Tests)
380 Medium Insert Delete GetRandom O(1) InsertDeleteGetRandomO1.java (Tests)
387 Easy First Unique Character in a String FirstUniqueCharacterInString.java (Tests)
394 Medium Decode String DecodeString.java (Tests)
398 Medium Random Pick Index RandomPickIndex.java (Tests)
405 Easy Convert a Number to Hexadecimal ConvertANumberToHexadecimal.java (Tests)
412 Easy Fizz Buzz FizzBuzz.java (Tests)
415 Easy Add Strings AddStrings.java (Tests)
416 Medium Partition Equal Subset Sum PartitionEqualSubsetSum.java (Tests)
438 Medium Find All Anagrams in a String FindAllAnagramsInAString.java (Tests)
443 Easy String Compression StringCompression.java (Tests)
449 Medium Serialize and Deserialize BST SerializeAndDeserializeBST.java (Tests)
485 Easy Max Consecutive Ones MaxConsecutiveOnes.java (Tests)
487 Medium Max Consecutive Ones II MaxConsecutiveOnes2.java (Tests)
489 Hard Robot Room Cleaner RobotRoomCleaner.java (Tests)
518 Medium Coin Change 2 CoinChange2.java (Tests)
523 Medium Continuous Subarray Sum ContinuousSubarraySum.java (Tests)
528 Medium Random Pick with Weight RandomPickWithWeight.java (Tests)
535 Medium Encode and Decode TinyURL EncodeAndDecodeTinyURL.java (Tests)
538 Easy Convert BST to Greater Tree ConvertBSTtoGreaterTree.java (Tests)
543 Easy Diameter of Binary Tree DiameterOfBinaryTree.java (Tests)
560 Medium Subarray Sum Equals K SubarraySumEqualsK.java (Tests)
562 Medium Longest Line of Consecutive One in Matrix LongestLineOfConsecutiveOneInMatrix.java (Tests)
617 Easy Merge Two Binary Trees MergeTwoBinaryTrees.java (Tests)
621 Medium Task Scheduler TaskScheduler.java (Tests)
636 Medium Exclusive Time of Functions ExclusiveTimeOfFunctions.java (Tests)
652 Medium Find Duplicate Subtrees FindDuplicateSubtrees.java (Tests)
659 Medium Split Array into Consecutive Subsequences SplitArrayIntoConsecutiveSubsequences.java (Tests)
670 Medium Maximum Swap MaximumSwap.java (Tests)
680 Easy Valid Palindrome II ValidPalindrome2.java (Tests)
689 Hard Maximum Sum of 3 Non-Overlapping Subarrays MaximumSumOf3NonOverlappingSubarrays.java (Tests)
690 Easy Employee Importance EmployeeImportance.java (Tests)
692 Medium Top K Frequent Words TopKFrequentWords.java (Tests)
721 Medium Accounts Merge AccountsMerge.java (Tests)
729 Medium My Calendar I MyCalendar.java (Tests)
733 Easy Flood Fill FloodFill.java (Tests)
746 Easy Min Cost Climbing Stairs MinCostClimbingStairs.java (Tests)
752 Medium Open the Lock OpenTheLock.java (Tests)
763 Medium Partition Labels PartitionLabels.java (Tests)
767 Medium Reorganize String ReorganizeString.java (Tests)
771 Easy Jewels and Stones JewelsAndStones.java (Tests)
772 Hard Basic Calculator III BasicCalculator3.java (Tests)
785 Medium Is Graph Bipartite? IsGraphBipartite.java (Tests)
791 Medium Custom Sort String CustomSortString.java (Tests)
809 Medium Expressive Words ExpressiveWords.java (Tests)
819 Easy Most Common Word MostCommonWord.java (Tests)
833 Medium Find And Replace in String FindAndReplaceInString.java (Tests)
840 Easy Magic Squares In Grid MagicSquaresInGrid.java (Tests)
843 Hard Guess the Word GuessTheWord.java (Tests)
844 Easy Backspace String Compare BackspaceStringCompare.java (Tests)
846 Medium Hand of Straights HandOfStraights.java (Tests)
865 Medium Smallest Subtree With all the Deepest Nodes SmallestSubtreeWithAllTheDeepestNodes.java (Tests)
896 Easy Monotonic Array MonotonicArray.java (Tests)
900 Medium RLE Iterator RLEIterator.java (Tests)
914 Easy X of a Kind in a Deck of Cards XOfAKindInADeckOfCards.java (Tests)
934 Medium Shortest Bridge ShortestBridge.java (Tests)
937 Easy Reorder Log Files ReorderLogFiles.java (Tests)
938 Easy Range Sum of BST RangeSumOfBst.java (Tests)
946 Medium Validate Stack Sequences ValidateStackSequences.java (Tests)
951 Medium Flip Equivalent Binary Trees FlipEquivalentBinaryTrees.java (Tests)
953 Easy Verifying an Alien Dictionary VerifyingAnAlienDictionary.java (Tests)
973 Medium K Closest Points to Origin KClosestPointsToOrigin.java (Tests)
986 Medium Interval List Intersections IntervalListIntersections.java (Tests)
987 Medium Vertical Order Traversal of a Binary Tree VerticalOrderTraversalOfABinaryTree.java (Tests)
1004 Medium Max Consecutive Ones III MaxConsecutiveOnes3.java (Tests)
1014 Medium Best Sightseeing Pair BestSightseeingPair.java (Tests)
1026 Medium Maximum Difference Between Node and Ancestor MaximumDifferenceBetweenNodeAndAncestor.java (Tests)
1031 Medium Maximum Sum of Two Non-Overlapping Subarrays MaximumSumOfTwoNonOverlappingSubarrays.java (Tests)
1048 Medium Longest String Chain LongestStringChain.java (Tests)
1060 Medium Missing Element in Sorted Array MissingElementInSortedArray.java (Tests)
1094 Medium Car Pooling CarPooling.java (Tests)
1110 Medium Delete Nodes And Return Forest DeleteNodesAndReturnForest.java (Tests)
1138 Medium Alphabet Board Path AlphabetBoardPath.java (Tests)
1140 Medium Stone Game II StoneGame2.java (Tests)
1189 Easy Maximum Number of Balloons MaximumNumberOfBalloons.java (Tests)
1193 Medium Monthly Transactions I MonthlyTransactions.sql
1197 Medium Minimum Knight Moves MinimumKnightMoves.java (Tests)
1231 Hard Divide Chocolate DivideChocolate.java (Tests)
1249 Medium Minimum Remove to Make Valid Parentheses MinimumRemoveToMakeValidParentheses.java (Tests)
1296 Medium Divide Array in Sets of K Consecutive Numbers DivideArrayInSetsOfKConsecutiveNumbers.java (Tests)
1376 Medium Time Needed to Inform All Employees TimeNeededToInformAllEmployees.java (Tests)
1423 Medium Maximum Points You Can Obtain from Cards MaximumPointsYouCanObtainFromCards.java (Tests)
1428 Medium Leftmost Column with at Least a One LeftmostColumnWithAtLeastAOne.java (Tests)
1438 Medium Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit LongestContinuousSubarrayWithDiffUpToLimit.java (Tests)
1463 Hard Cherry Pickup II CherryPickup2.java (Tests)
1504 Medium Count Submatrices With All Ones CountSubmatricesWithAllOnes.java (Tests)

About

Solutions for leetcode.com problems using Java

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages