Skip to content

Solutions to LeetCode problems; updated daily. Subscribe to my YouTube channel for more.

License

Notifications You must be signed in to change notification settings

mkraghav/Leetcode

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

If you like this project, please leave me a star. โ˜…

"For coding interview preparation, LeetCode is one of the best online resource providing a rich library of more than 300 real coding interview questions for you to practice from using one of the 7 supported languages - C, C++, Java, Python, C#, JavaScript, Ruby."

Algorithms

#TitleSolutionsVideoDifficultyTag
1598Crawler Log FolderSolutionEasyStack
1592Rearrange Spaces Between WordsSolutionEasyString
1588Sum of All Odd Length SubarraysSolutionEasyArray
1583Count Unhappy FriendsSolutionMediumArray
1582Special Positions in a Binary MatrixSolutionEasyArray
1576Replace All ?'s to Avoid Consecutive Repeating CharactersSolution๐Ÿ“บEasyString
1574Shortest Subarray to be Removed to Make Array SortedSolutionMediumArray, Binary Search
1572Matrix Diagonal SumSolutionEasyArray
1567Maximum Length of Subarray With Positive ProductSolution๐Ÿ“บMediumGreedy
1566Detect Pattern of Length M Repeated K or More TimesSolution๐Ÿ“บEasyArray
1561Maximum Number of Coins You Can GetSolution๐Ÿ“บMediumSort
1560Most Visited Sector in a Circular TrackSolutionEasyArray
1558Minimum Numbers of Function Calls to Make Target ArraySolutionMediumGreedy
1557Minimum Number of Vertices to Reach All NodesSolutionMediumGraph
1556Thousand SeparatorSolution๐Ÿ“บEasyString
1551Minimum Operations to Make Array EqualSolution๐Ÿ“บMediumMath
1550Three Consecutive OddsSolutionEasyArray
1545Find Kth Bit in Nth Binary StringSolutionMediumString
1544Make The String GreatSolution๐Ÿ“บEasyString, Stack
1541Minimum Insertions to Balance a Parentheses StringSolutionMediumString, Stack
1539Kth Missing Positive NumberSolution๐Ÿ“บEasyArray, HashTable
1535Find the Winner of an Array GameSolution๐Ÿ“บMediumArray
1534Count Good TripletsSolutionEasyArray
1528Shuffle StringSolutionEasySort
1526Minimum Number of Increments on Subarrays to Form a Target ArraySolutionHardSegment Tree
1525Number of Good Ways to Split a StringSolution๐Ÿ“บMediumString, Bit Manipulation
1524Number of Sub-arrays With Odd SumSolutionMediumArray, Math
1523Count Odd Numbers in an Interval RangeSolution๐Ÿ“บEasyMath
1518Water BottlesSolutionEasyGreedy
1514Path with Maximum ProbabilitySolutionMediumGraph
1512Number of Good PairsSolutionEasyArray, HashTable, Math
1508Range Sum of Sorted Subarray SumsSolutionMediumArray, Sort
1507Reformat DateSolutionEasyString
1502Can Make Arithmetic Progression From SequenceSolutionEasyArray, Sort
1496Path CrossingSolutionEasyString
1493Longest Subarray of 1's After Deleting One ElementSolutionMediumArray
1492The kth Factor of nSolutionMediumMath
1491Average Salary Excluding the Minimum and Maximum SalarySolutionEasyArray, Sort
1487Making File Names UniqueSolutionMediumHashTable, String
1486XOR Operation in an ArraySolutionMediumArray, Bit Manipulation
1481Least Number of Unique Integers after K RemovalsSolutionMediumArray, Sort
1480Running Sum of 1d ArraySolution, C++EasyArray
1476Subrectangle QueriesSolutionMediumArray
1475Final Prices With a Special Discount in a ShopSolutionEasyArray
1471The k Strongest Values in an ArraySolutionMediumArray, Sort
1470Shuffle the ArraySolution, C++EasyArray
1469Find All The Lonely NodesSolutionEasyTree, DFS
1466Reorder Routes to Make All Paths Lead to the City ZeroSolutionMediumTree, DFS
1464Maximum Product of Two Elements in an ArraySolutionEasyArray
1460Make Two Arrays Equal by Reversing Sub-arraysSolutionEasyArray
1457Pseudo-Palindromic Paths in a Binary TreeSolutionMediumBit Manipulation, Tree, DFS
1456Maximum Number of Vowels in a Substring of Given LengthSolutionMediumString, Sliding Window
1455Check If a Word Occurs As a Prefix of Any Word in a SentenceSolutionEasyString
1452People Whose List of Favorite Companies Is Not a Subset of Another ListSolutionMediumString, Sort
1451Rearrange Words in a SentenceSolutionMediumString, Sort
1450Number of Students Doing Homework at a Given TimeSolutionEasyArray
1448Count Good Nodes in Binary TreeSolutionMediumTree, DFS
1447Simplified FractionsSolutionMediumMath
1446Consecutive CharactersSolutionEasyString
1441Build an Array With Stack OperationsSolutionEasyStack
1437Check If All 1's Are at Least Length K Places AwaySolutionMediumArray
1436Destination CitySolutionEasyString
1432Max Difference You Can Get From Changing an IntegerSolutionMediumString
1431Kids With the Greatest Number of CandiesSolution, C++EasyArray
1428Leftmost Column with at Least a OneSolutionMediumArray
1427Perform String ShiftsSolutionEasyArray, Math
1426Counting ElementsSolutionEasyArray
1423Maximum Points You Can Obtain from CardsSolutionMediumArray, DP, Sliding Window
1422Maximum Score After Splitting a StringSolutionEasyString
1418Display Table of Food Orders in a RestaurantSolutionMediumHashTable
1417Reformat The StringSolutionEasyString
1415The k-th Lexicographical String of All Happy Strings of Length nSolutionMediumBacktracking
1413Minimum Value to Get Positive Step by Step SumSolutionEasyArray
1410HTML Entity ParserSolutionMediumString, Stack
1409Queries on a Permutation With KeySolutionMediumArray
1408String Matching in an ArraySolutionEasyString
1403Minimum Subsequence in Non-Increasing OrderSolutionEasyGreedy, Sort
1401Circle and Rectangle OverlappingSolutionMediumGeometry
1400Construct K Palindrome StringsSolutionMediumGreedy
1399Count Largest GroupSolutionEasyArray
1396Design Underground SystemSolutionMediumDesign
1395Count Number of TeamsSolutionMediumArray
1394Find Lucky Integer in an ArraySolutionEasyArray
1392Longest Happy PrefixSolutionHardString, Rolling Hash
1390Four DivisorsSolutionMediumMath
1389Create Target Array in the Given OrderSolutionEasyArray
1388Pizza With 3n SlicesSolutionHardDP
1387Sort Integers by The Power ValueSolutionMediumSort, Graph
1386Cinema Seat AllocationSolutionMediumArray, Greedy
1385Find the Distance Value Between Two ArraysSolutionEasyArray
1382Balance a Binary Search TreeSolutionMediumBinary Search Tree
1381Design a Stack With Increment OperationSolutionMediumStack, Design
1380Lucky Numbers in a MatrixSolutionEasyArray
1379Find a Corresponding Node of a Binary Tree in a Clone of That TreeSolutionMediumTree
1377Frog Position After T SecondsSolutionHardDFS, BFS
1376Time Needed to Inform All EmployeesSolutionMediumDFS
1375Bulb Switcher IIISolutionMediumArray
1374Generate a String With Characters That Have Odd CountsSolutionEasyString
1373Maximum Sum BST in Binary TreeSolutionHardDP, BST
1372Longest ZigZag Path in a Binary TreeSolutionHardDP, Tree
1371Find the Longest Substring Containing Vowels in Even CountsSolutionMediumString
1370Increasing Decreasing StringSolutionEasyString, Sort
1367Linked List in Binary TreeSolutionMediumDP, Linked List, Tree
1366Rank Teams by VotesSolutionMediumArray, Sort
1365How Many Numbers Are Smaller Than the Current NumberSolutionEasyArray, HashTable
1362Closest DivisorsSolutionMediumMath
1361Validate Binary Tree NodesSolutionMediumGraph
1360Number of Days Between Two DatesSolutionEasy
1358Number of Substrings Containing All Three CharactersSolutionMediumString
1357Apply Discount Every n OrdersSolutionMediumDesign
1356Sort Integers by The Number of 1 BitsSolutionEasySort, Bit Manipulation
1354Construct Target Array With Multiple SumsSolutionHardGreedy
1353Maximum Number of Events That Can Be AttendedSolutionMediumGreedy, Sort, Segment Tree
1352Product of the Last K NumbersSolutionMediumArray, Design
1351Count Negative Numbers in a Sorted MatrixSolutionEasyArray, Binary Search
1349Maximum Students Taking ExamSolutionHardDynamic Programming
1348Tweet Counts Per FrequencySolutionMediumDesign
1347Minimum Number of Steps to Make Two Strings AnagramSolutionEasyString
1346Check If N and Its Double ExistSolutionEasyArray
1345Jump Game IVSolutionHardBFS
1344Angle Between Hands of a ClockSolutionMediumMath
1343Number of Sub-arrays of Size K and Average Greater than or Equal to ThresholdSolutionMediumArray
1342Number of Steps to Reduce a Number to ZeroSolutionEasyBit Manipulation
1341The K Weakest Rows in a MatrixSolutionEasy
1339Maximum Product of Splitted Binary TreeSolutionMediumDP, Tree
1338Reduce Array Size to The HalfSolutionMedium
1337Remove Palindromic SubsequencesSolutionEasyString
1333Filter Restaurants by Vegan-Friendly, Price and DistanceSolutionMedium
1331Rank Transform of an ArraySolutionEasy
1329Sort the Matrix DiagonallySolutionMedium
1325Delete Leaves With a Given ValueSolutionMediumTree
1324Print Words VerticallySolutionMediumString
1323Maximum 69 NumberSolutionEasyMath
1317Convert Integer to the Sum of Two No-Zero IntegersSolutionEasy
1315Sum of Nodes with Even-Valued GrandparentSolutionMediumTree, DFS
1314Matrix Block SumSolutionMediumDynamic Programming
1313Decompress Run-Length Encoded ListSolutionEasyArray
1305All Elements in Two Binary Search TreesSolutionMedium
1304Find N Unique Integers Sum up to ZeroSolutionEasy
1302Deepest Leaves SumSolutionMedium
1300Sum of Mutated Array Closest to TargetSolutionMedium
1299Replace Elements with Greatest Element on Right SideSolutionEasy
1297Maximum Number of Occurrences of a SubstringSolutionMedium
1296Divide Array in Sets of K Consecutive NumbersSolutionMedium
1295Find Numbers with Even Number of DigitsJavaJavascript๐Ÿ“บEasy
1291Sequential DigitsSolutionMedium
1290Convert Binary Number in a Linked List to IntegerSolutionEasy
1289Minimum Falling Path Sum IISolutionHardDynamic Programming
1287Element Appearing More Than 25% In Sorted ArraySolution๐Ÿ“บEasy
1286Iterator for CombinationSolutionMediumBacktracking, Design
1282Group the People Given the Group Size They Belong ToSolution๐Ÿ“บMedium
1281Subtract the Product and Sum of Digits of an IntegerSolutionEasy
1277Count Square Submatrices with All OnesSolutionMedium
1275Find Winner on a Tic Tac Toe GameSolutionEasyArray
1273Delete Tree NodesSolutionMediumDynamic Programming, DFS
1271HexspeakSolutionEasy
1267Count Servers that CommunicateSolutionMedium
1266Minimum Time Visiting All PointsSolutionEasy
1265Print Immutable Linked List in ReverseSolutionMedium
1261Find Elements in a Contaminated Binary TreeSolutionMediumTree, HashTable
1260Shift 2D GridSolution๐Ÿ“บEasy
1258Synonymous SentencesSolutionMediumBacktracking
1252Cells with Odd Values in a MatrixSolutionEasy
1237Find Positive Integer Solution for a Given EquationSolutionEasy
1243Array TransformationSolution๐Ÿ“บEasy
1232Check If It Is a Straight LineSolution๐Ÿ“บEasy
1228Missing Number In Arithmetic ProgressionSolutionEasy
1221Split a String in Balanced StringsSolutionEasyGreedy
1219Path with Maximum GoldSolutionMediumBacktracking
1217Play with ChipsSolutionEasyArray, Math, Greedy
1214Two Sum BSTsSolutionMediumBinary Search Tree
1213Intersection of Three Sorted ArraysSolution๐Ÿ“บEasy
1209Remove All Adjacent Duplicates in String IISolutionMediumStack
1207Unique Number of OccurrencesSolution๐Ÿ“บEasy
1200Minimum Absolute DifferenceSolution๐Ÿ“บEasy
1198Find Smallest Common Element in All RowsSolution๐Ÿ“บEasy
1196How Many Apples Can You Put into the BasketSolution๐Ÿ“บEasy
1190Reverse Substrings Between Each Pair of ParenthesesSolutionMediumStack
1189Maximum Number of BalloonsSolution๐Ÿ“บEasy
1185Day of the WeekSolutionEasy
1184Distance Between Bus StopsSolution๐Ÿ“บEasy
1182Shortest Distance to Target ColorSolutionMediumBinary Search
1180Count Substrings with Only One Distinct LetterSolutionEasyMath, String
1176Diet Plan PerformanceSolutionEasyArray, Sliding Window
1175Prime ArrangementsSolutionEasy
1165Single-Row KeyboardSolutionEasy
1161Maximum Level Sum of a Binary TreeSolutionMediumGraph
1160Find Words That Can Be Formed by CharactersSolutionEasy
1154Day of the YearSolutionEasy
1150Check If a Number Is Majority Element in a Sorted ArraySolution๐Ÿ“บEasy
1137N-th Tribonacci NumberSolutionEasy
1134Armstrong NumberSolution๐Ÿ“บEasy
1133Largest Unique NumberSolution๐Ÿ“บEasy
1128Number of Equivalent Domino PairsSolution๐Ÿ“บEasy
1122Relative Sort ArraySolutionEasy
1170Compare Strings by Frequency of the Smallest CharacterSolutionEasy
1119Remove Vowels from a StringSolution๐Ÿ“บEasy
1118Number of Days in a MonthSolutionEasy
1114Print in OrderSolutionEasy
1108Defanging an IP AddressSolution๐Ÿ“บEasy
1104Path In Zigzag Labelled Binary TreeSolutionMediumMath, Tree
1103Distribute Candies to PeopleSolutionEasyMath
1100Find K-Length Substrings With No Repeated CharactersSolutionMediumString, Sliding Window
1099Two Sum Less Than KSolution๐Ÿ“บEasy
1089Duplicate ZerosSolutionEasy
1087Brace ExpansionSolutionMediumBacktracking
1086High FiveSolution๐Ÿ“บEasy
1085Sum of Digits in the Minimum NumberSolution๐Ÿ“บEasy
1079Letter Tile PossibilitiesSolutionMedium
1078Occurrences After BigramSolutionEasy
1071Greatest Common Divisor of StringsSolutionEasy
1066Campus Bikes IISolutionMediumBacktracking, DP
1065Index Pairs of a StringSolutionMedium
1062Longest Repeating SubstringSolutionMedium
1057Campus BikesSolutionMedium
1056Confusing NumberSolutionEasy
1055Fixed PointSolutionEasy
1051Height CheckerSolutionEasy
1047Remove All Adjacent Duplicates In StringSolutionEasy
1046Last Stone WeightSolution๐Ÿ“บEasy
1043Partition Array for Maximum SumSolutionMediumDP
1038Binary Search Tree to Greater Sum TreeSolutionMediumDFS, tree
1037Valid BoomerangSolutionEasyMath
1033Moving Stones Until ConsecutiveSolutionEasyMath
1030Matrix Cells in Distance OrderSolutionEasy
1029Two City SchedulingSolutionEasy
1025Divisor GameSolutionEasy
1022Sum of Root To Leaf Binary NumbersSolutionEasy
1021Remove Outermost ParenthesesSolutionEasy
1020Number of EnclavesSolutionMediumGraph, DFS, BFS, recursion
1019Next Greater Node In Linked ListSolutionMediumLinked List, Stack
1018Binary Prefix Divisible By 5SolutionEasy
1014Best Sightseeing PairSolutionMedium
1013Partition Array Into Three Parts With Equal SumSolutionEasy
1011Capacity To Ship Packages Within D DaysSolutionMediumBinary Search
1010Pairs of Songs With Total Durations Divisible by 60SolutionEasy
1009Complement of Base 10 IntegerSolutionEasy
1008Construct Binary Search Tree from Preorder TraversalSolutionMediumRecursion
1005Maximize Sum Of Array After K NegationsSolution๐Ÿ“บEasy
1004Max Consecutive Ones IIISolutionMediumTwo Pointers, Sliding Window
1003Check If Word Is Valid After SubstitutionsSolutionMedium
1002Find Common CharactersSolutionEasy
999Available Captures for RookSolutionEasy
997Find the Town JudgeSolutionEasy
994Rotting OrangesSolutionEasyBFS
993Cousins in Binary TreeSolutionEasyTree, BFS
989Add to Array-Form of IntegerSolutionEasyArray
988Smallest String Starting From LeafSolutionMediumTree, DFS
987Vertical Order Traversal of a Binary TreeSolutionMediumRecursion
986Interval List IntersectionsSolutionMediumTwo Pointers
985Sum of Even Numbers After QueriesSolutionEasyArray
980Unique Paths IIISolutionHardBacktracking, DFS
979Distribute Coins in Binary TreeSolutionMediumRecursion
977Squares of a Sorted ArraySolutionEasyArray
976Largest Perimeter TriangleSolutionEasyMath Array
974Subarray Sums Divisible by KSolutionMediumArray
973K Closest Points to OriginSolutionEasyMath Sort
970Powerful IntegersSolutionEasyMath
966Vowel SpellcheckerSolutionMediumHash Table, String
965Univalued Binary TreeSolutionEasyDFS, recursion
961N-Repeated Element in Size 2N ArraySolutionEasy
958Check Completeness of a Binary TreeSolutionMediumTree
957Prison Cells After N DaysSolutionMedium
954Array of Doubled PairsSolution๐Ÿ“บMedium
953Verifying an Alien DictionarySolutionEasy
951Flip Equivalent Binary TreesSolutionMediumTree, DFS, recursion
950Reveal Cards In Increasing OrderSolutionMedium
946Validate Stack SequencesSolutionMediumStack
944Delete Columns to Make SortedSolutionEasy
942DI String MatchSolutionEasy
941Valid Mountain ArraySolutionEasy
938Range Sum of BSTSolutionMediumBST, recursion, DFS
937Reorder Log FilesSolutionEasy
935Knight DialerSolutionMedium
933Number of Recent CallsSolutionEasy
931Minimum Falling Path SumSolutionMediumDynamic Programming
929Unique Email AddressesSolutionEasy
925Long Pressed NameSolutionEasy
922Sort Array By Parity IISolutionEasy
921Minimum Add to Make Parentheses ValidSolutionMediumStack, Greedy
917Reverse Only LettersSolutionEasy
914X of a Kind in a Deck of CardsSolutionEasy
912Sort an ArraySolutionEasy
908Smallest Range ISolutionEasy
901Online Stock SpanSolutionMediumStack
900RLE IteratorSolutionMedium
897Increasing Order Search TreeSolutionEasyDFS, recursion
896Monotonic ArraySolutionEasy
890Find and Replace PatternSolutionMedium
893Groups of Special-Equivalent StringsSolution๐Ÿ“บEasy
888Fair Candy SwapSolutionEasy
885Spiral Matrix IIISolution๐Ÿ“บMedium
884Uncommon Words from Two SentencesSolutionEasy
883Projection Area of 3D ShapesSolutionEasyMath
880Decoded String at IndexSolutionMediumStack
876Middle of the Linked ListSolutionEasy
872Leaf-Similar TreesSolutionEasyDFS, recursion
868Binary GapSolutionEasy
867Transpose MatrixSolutionEasy
860Lemonade ChangeSolutionEasy
859Buddy StringsSolutionEasy
856Score of ParenthesesSolutionMediumStack, String
852Peak Index in a Mountain ArraySolutionEasy
849Maximize Distance to Closest PersonSolutionEasy
844Backspace String CompareSolutionEasy
841Keys and RoomsSolutionEasyDFS, Graph
840Magic Squares In GridSolutionEasy
836Rectangle OverlapSolution๐Ÿ“บEasy
832Flipping an ImageSolutionEasy
830Positions of Large GroupsSolutionEasy
824Goat LatinSolutionEasy
821Shortest Distance to a CharacterSolutionEasy
819Most Common WordSolutionEasyHashMap
814Binary Tree PruningSolutionMediumrecursion, DFS
811Subdomain Visit CountSolutionEasyHashMap
807Max Increase to Keep City SkylineSolutionMedium
806Number of Lines To Write StringSolutionEasy
804Unique Morse Code WordsSolutionEasy
800Similar RGB ColorSolutionEasy
799Champagne TowerSolutionMedium
796Rotate StringSolutionEasy
791Custom Sort StringSolutionMedium
789Escape The GhostsSolutionMediumMath
788Rotated DigitsSolutionEasy
784Letter Case PermutationSolutionEasy
783Minimum Distance Between BST NodesSolutionEasy
779K-th Symbol in GrammarSolutionMedium
776Split BSTSolutionMediumRecursion
771Jewels and StonesSolutionEasy
769Max Chunks To Make SortedSolutionMediumArray
767Reorganize StringSolutionMedium
766Toeplitz MatrixSolutionEasy
765Couples Holding HandsSolutionHard
764Largest Plus SignSolutionMediumDP
763Partition LabelsSolutionMedium
762Prime Number of Set Bits in Binary RepresentationSolutionEasy
760Find Anagram MappingsSolutionEasy
758Bold Words in StringSolutionEasy
756Pyramid Transition MatrixSolutionMediumBacktracking
755Pour WaterSolutionMediumArray
754Reach a NumberSolutionMediumMath
750Number Of Corner RectanglesSolutionMedium
748Shortest Completing WordSolutionEasy
747Largest Number Greater Than Twice of OthersSolutionEasy
746Min Cost Climbing StairsSolutionEasy
744Find Smallest Letter Greater Than TargetSolutionEasy
743Network Delay TimeSolutionMediumGraph, Djikstra
742Closest Leaf in a Binary TreeSolutionMediumTree
740Delete and EarnSolutionMedium
739Daily TemperaturesSolutionMedium
738Monotone Increasing DigitsSolutionMedium
737Sentence Similarity IISolutionMediumUnion Find
735Asteroid CollisionSolutionMediumStack
734Sentence SimilaritySolutionEasyHashTable
733Flood FillSolutionEasyBFS, DFS
729My Calendar ISolutionMedium
728Self Dividing NumbersSolutionEasy
727Minimum Window SubsequenceSolutionHardDP
725Split Linked List in PartsSolutionMediumLinkedList
724Find Pivot IndexSolutionEasyArray
723Candy CrushSolutionMediumArray, Two Pointers
721Accounts MergeSolutionMediumDFS, Union Find
720Longest Word in DictionarySolutionEasyTrie
719Find K-th Smallest Pair DistanceSolutionHardBinary Search
718Maximum Length of Repeated SubarraySolutionMediumDP
7171-bit and 2-bit CharactersSolutionEasy
716Max StackSolutionHardDesign
714Best Time to Buy and Sell Stock with Transaction FeeSolutionMediumDP
713Subarray Product Less Than KSolutionMedium
712Minimum ASCII Delete Sum for Two StringsSolutionMediumDP
709To Lower CaseSolutionEasyString
706Design HashMapSolutionEasyDesign
705Design HashSetSolutionEasyDesign
704Binary SearchSolutionEasyBinary Search
703Kth Largest Element in a StreamSolutionEasy
701Insert into a Binary Search TreeSolutionMediumDFS, recursion
700Search in a Binary Search TreeSolutionEasyrecusion, dfs
699Falling SquaresSolutionHardSegment Tree
698Partition to K Equal Sum SubsetsSolution, C++MediumBacktracking + DP
697Degree of an ArraySolutionEasy
696Count Binary SubstringsSolutionEasy
695Max Area of IslandSolutionEasyDFS
694Number of Distinct IslandsSolutionMediumDFS
693Binary Number with Alternating BitsSolutionEasy
692Top K Frequent WordsSolutionMedium
691Stickers to Spell WordSolutionHardDP
690Employee ImportanceSolutionEasyDFS
689Maximum Sum of 3 Non-Overlapping SubarraysSolutionHardDP
688Knight Probability in ChessboardSolutionMediumDP
687Longest Univalue PathSolutionEasyDFS
686Repeated String MatchSolutionEasy
685Redundant Connection IISolutionHardUnion Find
684Redundant ConnectionSolutionMediumUnion Find
683K Empty SlotsSolutionHard
682Baseball GameSolutionEasy
681Next Closest TimeSolutionMedium
680Valid Palindrome IISolutionEasyString
67924 GameSolutionHardRecursion
678Valid Parenthesis StringSolutionMediumRecursion, Greedy
677Map Sum PairsSolutionMediumHashMap, Trie
676Implement Magic DictionarySolutionMedium
675Cut Off Trees for Golf EventSolutionHardBFS
674Longest Continuous Increasing SubsequenceSolutionEasy
673Number of Longest Increasing SubsequenceSolutionMediumDP
672Bulb Switcher IISolutionMediumMath
671Second Minimum Node In a Binary TreeSolutionEasyTree, DFS
670Maximum SwapSolutionMediumString
669Trim a Binary Search TreeSolutionEasyTree, DFS
668Kth Smallest Number in Multiplication TableSolutionHardBinary Search
667Beautiful Arrangement IISolutionMediumArray
666Path Sum IVSolutionMediumTree, DFS
665Non-decreasing ArraySolutionEasy
664Strange PrinterSolutionHardDP
663Equal Tree PartitionSolutionMediumTree
662Maximum Width of Binary TreeSolutionMediumBFS, DFS
661Image SmootherSolutionEasyArray
660Remove 9SolutionHardMath
659Split Array into Consecutive SubsequencesSolutionMediumHashMap
658Find K Closest ElementsSolutionMedium
657Judge Route CircleSolutionEasy
656Coin PathSolutionHardDP
655Print Binary TreeSolutionMediumRecursion
654Maximum Binary TreeSolutionMediumTree
653Two Sum IV - Input is a BSTSolutionEasyTree
652Find Duplicate SubtreesSolutionMediumTree
6514 Keys KeyboardSolutionMediumDP
6502 Keys KeyboardSolutionMediumDP
649Dota2 SenateSolutionMediumGreedy
648Replace WordsSolutionMediumTrie
647Palindromic SubstringsSolutionMediumDP
646Maximum Length of Pair ChainSolutionMediumDP, Greedy
645Set MismatchSolutionEasy
644Maximum Average Subarray IISolutionHardBinary Search
643Maximum Average Subarray ISolutionEasy
642Design Search Autocomplete SystemSolutionHardDesign
640Solve the EquationSolutionMedium
639Decode Ways IISolutionHardDP
638Shopping OffersSolutionMediumDP, DFS
637Average of Levels in Binary TreeSolutionEasy
636Exclusive Time of FunctionsSolutionMediumStack
635Design Log Storage SystemSolutionMediumDesign
634Find the Derangement of An ArraySolutionMediumMath
633Sum of Square NumbersSolutionEasyBinary Search
632Smallest RangeSolutionHardHeap
631Design Excel Sum FormulaSolutionHardDesign, Topological Sort
630Course Schedule IIISolutionHardHeap, Greedy
629K Inverse Pairs ArraySolutionHardDP
628Maximum Product of Three NumbersSolutionEasy
625Minimum FactorizationSolutionMedium
624Maximum Distance in ArraysSolutionEasySort, Array
623Add One Row to TreeSolutionMediumTree
621Task SchedulerSolutionMediumGreedy, Queue
617Merge Two Binary TreesSolutionEasyTree, Recursion
616Add Bold Tag in StringSolutionMediumString
611Valid Triangle NumberSolutionMediumBinary Search
609Find Duplicate File in SystemSolutionMediumHashMap
606Construct String from Binary TreeSolutionEasyTree, Recursion
605Can Place FlowersSolutionEasyArray
604Design Compressed String IteratorSolutionEasyDesign, String
600Non-negative Integers without Consecutive OnesSolutionHardBit Manipulation, DP
599Minimum Index Sum of Two ListsSolutionEasyHashMap
598Range Addition IISolutionEasy
594Longest Harmonious SubsequenceSolutionEasyArray, HashMap
593Valid SquareSolutionMediumMath
592Fraction Addition and SubtractionSolutionMediumMath
591Tag ValidatorSolutionHardStack, String
590N-ary Tree Postorder TraversalSolutionEasyDFS, recursion
589N-ary Tree Preorder TraversalSolutionEasyDFS, recursion
588Design In-Memory File SystemSolutionHardTrie, Design
587Erect the FenceSolutionHardGeometry
583Delete Operation for Two StringsSolutionMediumDP
582Kill ProcessSolutionMediumStack
581Shortest Unsorted Continuous SubarraySolutionEasyArray, Sort
576Out of Boundary PathsSolutionHardDP, DFS
575Distribute CandiesSolutionEasyArray
573Squirrel SimulationSolutionMediumMath
572Subtree of Another TreeSolutionEasyTree
568Maximum Vacation DaysSolutionHardDP
567Permutation in StringSolutionMediumSliding Windows, Two Pointers
566Reshape the MatrixSolutionEasy
565Array NestingSolutionMedium
563Binary Tree TiltSolutionEasyTree Recursion
562Longest Line of Consecutive One in MatrixSolutionMediumMatrix DP
561Array Partition ISolutionEasyArray
560Subarray Sum Equals KSolutionMediumArray, HashMap
559Maximum Depth of N-ary TreeSolutionEasyDFS, recursion
557Reverse Words in a String IIISolutionEasyString
556Next Greater Element IIISolutionMediumString
555Split Concatenated StringsSolutionMediumString
554Brick WallSolutionMediumHashMap
553Optimal DivisionSolutionMediumString, Math
552Student Attendance Record IISolutionHardDP
551Student Attendance Record ISolutionEasyString
549Binary Tree Longest Consecutive Sequence IISolutionMediumTree
548Split Array with Equal SumSolutionMediumArray
547Friend CirclesSolutionMediumUnion Find
546Remove BoxesSolutionHardDFS, DP
545Boundary of Binary TreeSolutionMediumRecursion
544Output Contest MatchesSolutionMediumRecursion
543Diameter of Binary TreeSolutionEasyTree/DFS/Recursion
54201 MatrixSolutionMediumBFS
541Reverse String IISolutionEasyString
540Single Element in a Sorted ArraySolutionMedium
539Minimum Time DifferenceSolutionMediumString
538Convert BST to Greater TreeSolutionEasyTree
537Complex Number MultiplicationSolutionMediumMath, String
536Construct Binary Tree from StringSolutionMediumRecursion, Stack
535Encode and Decode TinyURLSolutionMediumDesign
533Lonely Pixel IISolutionMediumHashMap
532K-diff Pairs in an ArraySolutionEasyHashMap
531Lonely Pixel ISolutionMedium
530Minimum Absolute Difference in BSTSolutionEasyDFS
529MinesweeperSolutionMediumBFS
527Word AbbreviationSolutionHard
526Beautiful ArrangementSolutionMediumBacktracking
525Contiguous ArraySolutionMediumHashMap
524Longest Word in Dictionary through DeletingSolutionMediumSort
523Continuous Subarray SumSolutionMediumDP
522Longest Uncommon Subsequence IISolutionMedium
521Longest Uncommon Subsequence ISolutionEasy
520Detect CapitalSolutionEasy
517Super Washing MachinesSolutionHardDP
516Longest Palindromic SubsequenceSolutionMediumDP
515Find Largest Value in Each Tree RowSolutionMediumBFS
514Freedom TrailSolutionHardDP
513Find Bottom Left Tree ValueSolutionMediumBFS
509Fibonacci NumberSolution๐Ÿ“บEasyArray
508Most Frequent Subtree SumSolutionMediumDFS, Tree
507Perfect NumberSolutionEasyMath
506Relative RanksSolutionEasy
505The Maze IISolutionMediumBFS
504Base 7SolutionEasy
503Next Greater Element IISolutionMediumStack
502IPOSolutionHardHeap, Greedy
501Find Mode in Binary TreeSolutionEasyBinary Tree
500Keyboard RowSolutionEasy
499The Maze IIISolutionHardBFS
496Next Greater Element ISolutionEasy
498Diagonal TraverseSolutionMedium
495Teemo AttackingSolutionMediumArray
494Target SumSolutionMedium
493Reverse PairsSolutionHardRecursion
492Construct the RectangleSolutionEasyArray
491Increasing SubsequencesSolutionMediumBacktracking, DFS
490The MazeSolutionMediumBFS
488Zuma GameSolutionHardDFS, Backtracking
487Max Consecutive Ones IISolutionMediumArray
486Predict the WinnerSolutionMediumDP
485Max Consecutive OnesJavaJavascriptEasyArray
484Find PermutationSolutionMediumArray, String, Greedy
483Smallest Good BaseSolutionHardBinary Search, Math
482License Key FormattingSolutionMedium
481Magical StringSolutionMedium
480Sliding Window MedianSolutionHardHeap
479Largest Palindrome ProductSolutionEasy
477Total Hamming DistanceSolutionMediumBit Manipulation
476Number ComplementSolutionEasyBit Manipulation
475HeatersSolutionEasyArray Binary Search
474Ones and ZeroesSolutionMediumDP
473Matchsticks to SquareSolutionMediumBacktracking, DFS
472Concatenated WordsSolutionHardTrie, DP, DFS
471Encode String with Shortest LengthSolutionHardDP
469Convex PolygonSolutionMediumMath
468Validate IP AddressSolutionMediumString
467Unique Substrings in Wraparound StringSolutionMediumDP
466Count The RepetitionsSolutionHardDP
465Optimal Account BalancingSolutionHardDP
464Can I WinSolutionMediumDP
463Island PerimeterSolutionEasy
462Minimum Moves to Equal Array Elements IISolutionMedium
461Hamming DistanceSolution, C++Easy
460LFU CacheSolutionHardDesign, LinkedHashMap, HashMap
459Repeated Substring PatternSolutionEasyString, KMP
458Poor PigsSolutionEasyMath
457Circular Array LoopSolutionMedium
456132 PatternSolutionMediumStack
455Assign CookiesSolutionEasy
4544Sum IISolutionMediumHashMap
453Minimum Moves to Equal Array ElementsSolutionEasy
452Minimum Number of Arrows to Burst BalloonsSolutionMediumArray, Greedy
451Sort Characters By FrequencySolutionMediumHashMap
450Delete Node in a BSTSolutionMediumTree, Recursion
449Serialize and Deserialize BSTSolutionMediumBFS
448Find All Numbers Disappeared in an ArraySolutionEasyArray, HashMap
447Number of BoomerangsSolutionEasyHashMap
446Arithmetic Slices II - SubsequenceSolutionHardDP
445Add Two Numbers IISolutionMediumStack, LinkedList
444Sequence ReconstructionSolutionMediumTopological Sort, Graph
443String CompressionSolutionEasy
442Find All Duplicates in an ArraySolutionMediumArray
441Arranging CoinsSolutionEasy
440K-th Smallest in Lexicographical OrderSolutionHard
439Ternary Expression ParserSolutionMediumStack
438Find All Anagrams in a StringSolutionEasySliding Window
437Path Sum IIISolutionEasyDFS, recursion
436Find Right IntervalSolutionMediumBinary Search
435Non-overlapping IntervalsSolutionMediumGreedy
434Number of Segments in a StringSolutionEasy
432All O`one Data StructureSolutionHardDesign
429N-ary Tree Level Order TraversalSolutionEasyBFS, Tree
425Word SquaresSolutionHardTrie, Backtracking, Recursion
424Longest Repeating Character ReplacementSolutionMediumSliding Window
423Reconstruct Original Digits from EnglishSolutionMediumMath
422Valid Word SquareSolutionEasy
421Maximum XOR of Two Numbers in an ArraySolutionMediumBit Manipulation, Trie
420Strong Password CheckerSolutionHard
419Battleships in a BoardSolutionMediumDFS
418Sentence Screen FittingSolutionMedium
417Pacific Atlantic Water FlowSolutionMediumDFS
416Partition Equal Subset SumJava, C++MediumDP
415Add StringsSolutionEasy
414Third Maximum NumberSolutionEasy
413Arithmetic SlicesSolutionMediumDP
412Fizz BuzzSolutionEasy
411Minimum Unique Word AbbreviationSolutionHardNP-Hard, Backtracking, Trie, Recursion
410Split Array Largest SumSolutionHardBinary Search, DP
409Longest PalindromeSolutionEasy
408Valid Word AbbreviationSolutionEasy
407Trapping Rain Water IISolutionHardHeap
406Queue Reconstruction by HeightSolutionMediumLinkedList, PriorityQueue
405Convert a Number to HexadecimalSolutionEasy
404Sum of Left LeavesSolutionEasy
403Frog JumpSolutionHardDP
402Remove K DigitsSolutionMediumGreedy, Stack
401Binary WatchSolutionEasy
400Nth DigitSolutionEasy
399Evaluate DivisionSolutionMediumGraph, DFS, Backtracking
398Random Pick IndexSolutionMediumReservoir Sampling
397Integer ReplacementSolutionEasyBFS
396Rotate FunctionSolutionEasy
395Longest Substring with At Least K Repeating CharactersSolutionMediumRecursion
394Decode StringSolutionMediumStack Depth-first-search
393UTF-8 ValidationSolutionMediumBit Manipulation
392Is SubsequenceSolutionMediumArray, String
391Perfect RectangleSolutionHard
390Elimination GameSolutionMedium
389Find the DifferenceSolutionEasy
388Longest Absolute File PathSolutionMediumStack
387First Unique Character in a StringSolutionEasyHashMap
386Lexicographical NumbersSolutionMedium
385Mini ParserSolutionMediumStack
384Shuffle an ArraySolutionMedium
383Ransom NoteSolutionEasyString
382Linked List Random NodeSolutionMediumReservoir Sampling
381Insert Delete GetRandom O(1) - Duplicates allowedSolutionHard
380Insert Delete GetRandom O(1)SolutionMediumDesign, HashMap
379Design Phone DirectorySolutionMedium
378Kth Smallest Element in a Sorted MatrixSolutionMediumBinary Search
377Combination Sum IVSolutionMediumDP
376Wiggle SubsequenceSolutionMediumDP, Greedy
375Guess Number Higher or Lower IISolutionMediumDP
374Guess Number Higher or LowerSolutionEasyBinary Search
373Find K Pairs with Smallest SumsSolutionMediumHeap
372Super PowSolutionMediumMath
371Sum of Two IntegersSolutionEasy
370Range AdditionSolutionMediumArray
369Plus One Linked ListSolutionMediumLinked List
368Largest Divisible SubsetSolutionMediumDP
367Valid Perfect SquareSolutionMedium
366Find Leaves of Binary TreeSolutionMediumDFS
365Water and Jug ProblemSolutionMediumMath
364Nested List Weight Sum IISolutionMediumDFS
363Max Sum of Rectangle No Larger Than KSolutionHardDP
362Design Hit CounterSolutionMediumDesign
361Bomb EnemySolutionMedium
360Sort Transformed ArraySolutionMediumTwo Pointers, Math
359Logger Rate LimiterSolutionEasyHashMap
358Rearrange String k Distance ApartSolutionHardHashMap, Heap, Greedy
357Count Numbers with Unique DigitsSolutionMediumDP, Math
356Line ReflectionSolutionMediumHashSet
355Design TwitterSolutionMediumDesign, HashMap, Heap
354Russian Doll EnvelopesSolutionHardDP, Binary Search
353Design Snake GameSolutionMedium
352Data Stream as Disjoint IntervalsSolutionHardTreeMap
351Android Unlock PatternsSolutionMedium
350Intersection of Two Arrays IISolution๐Ÿ“บEasyHashMap, Binary Search
349Intersection of Two ArraysSolution๐Ÿ“บEasyTwo Pointers, Binary Search
348Design Tic-Tac-ToeSolutionMediumDesign
347Top K Frequent ElementsSolutionMediumHashTable, Heap, Bucket Sort
346Moving Average from Data StreamSolutionEasyQueue
345Reverse Vowels of a StringSolutionEasyString
344Reverse StringSolution๐Ÿ“บEasyString
343Integer BreakSolutionMediumMath
342Power of FourSolutionEasyMath
341Flatten Nested List IteratorSolutionMediumStack
340Longest Substring with At Most K Distinct CharactersSolutionHardSliding Window
339Nested List Weight SumSolutionEasyDFS
338Counting BitsSolutionMedium
337House Robber IIISolutionMediumDP
336Palindrome PairsSolutionHard
335Self CrossingSolutionHardMath
334Increasing Triplet SubsequenceSolutionMedium
333Largest BST SubtreeSolutionMediumTree
332Reconstruct ItinerarySolutionMediumGraph, DFS
331Verify Preorder Serialization of a Binary TreeSolutionMediumStack
330Patching ArraySolutionHardGreedy
329Longest Increasing Path in a MatrixSolutionHardDFS, DP
328Odd Even Linked ListSolutionMediumLinked List
327Count of Range SumSolutionHardBST, Divide and Conquer
326Power of ThreeSolutionEasyMath
325Maximum Size Subarray Sum Equals kSolutionMediumHashTable
324Wiggle Sort IISolutionMediumSort
323Number of Connected Components in an Undirected GraphSolutionMedium
322Coin ChangeSolutionMediumDP
321Create Maximum NumberSolutionHard
320Generalized AbbreviationSolutionMediumBacktracking, Bit Manipulation
319Bulb SwitcherSolutionMediumBrainteaser
318Maximum Product of Word LengthsSolutionMedium
317Shortest Distance from All BuildingsSolutionHard
316Remove Duplicate LettersSolutionHardStack, Recursion, Greedy
315Count of Smaller Numbers After SelfSolutionHardTree
314Binary Tree Vertical Order TraversalSolutionMediumHashMap, BFS
313Super Ugly NumberSolutionMedium
312Burst BalloonsSolutionHardDP
311Sparse Matrix MultiplicationSolutionMedium
310Minimum Height TreesSolutionMedium
309Best Time to Buy and Sell Stock with CooldownSolutionMediumDP
308Range Sum Query 2D - MutableSolutionHardTree
307Range Sum Query - MutableSolutionMediumTree
306Additive NumberSolutionMedium
305Number of Islands IISolutionHardUnion Find
304Range Sum Query 2D - ImmutableSolutionMedium
303Range Sum Query - ImmutableSolutionEasy
302Smallest Rectangle Enclosing Black PixelsSolutionHardDFS, BFS
301Remove Invalid ParenthesesSolutionHardBFS
300Longest Increasing SubsequenceSolutionMediumDP
299Bulls and CowsSolutionEasy
298Binary Tree Longest Consecutive SequenceSolutionMediumTree
297Serialize and Deserialize Binary TreeSolutionHardBFS
296Best Meeting PointSolutionHard
295Find Median from Data StreamSolutionHardHeap
294Flip Game IISolutionMediumBacktracking
293Flip GameSolutionEasy
292Nim GameSolutionEasy
291Word Pattern IISolutionHardRecursion, Backtracking
290Word PatternSolutionEasyHashMap
289Game of LifeSolution๐Ÿ“บMedium
288Unique Word AbbreviationSolutionEasy
287Find the Duplicate NumberSolutionMedium
286Walls and GatesSolutionMediumBFS
285Inorder Successor In BSTSolutionMediumTree
284Peeking IteratorSolutionMediumDesign
283Move ZeroesSolution๐Ÿ“บEasy
282Expression Add OperatorsSolutionHard
281Zigzag IteratorSolutionMedium
280Wiggle SortSolutionMedium
279Perfect SquaresSolutionMedium
278First Bad VersionSolution๐Ÿ“บEasyBinary Search
277Find the CelebritySolutionMedium
276Paint FenceSolutionEasyDP
275H-Index IISolutionMediumBinary Search
274H-IndexSolutionMedium
273Integer to English WordsSolutionHardMath, String
272Closest Binary Search Tree Value IISolutionHardStack
271Encode and Decode StringsSolutionMedium
270Closest Binary Search Tree ValueSolutionEasy
269Alien DictionarySolutionHard
268Missing NumberSolutionEasy
267Palindrome Permutation IISolutionMedium
266Palindrome PermutationSolutionEasy
265Paint House IISolutionHardDP
264Ugly Number IISolutionMediumDP
263Ugly NumberSolutionEasy
261Graph Valid TreeSolutionMedium
260Single Number IIISolutionMedium
2593Sum SmallerSolutionMedium
258Add DigitsSolutionEasy
257Binary Tree PathsSolutionDFS/Recursion
256Paint HouseSolutionMediumDP
255Verify Preorder Sequence in Binary Search TreeSolutionMediumTree
254Factor CombinationsSolutionMediumBacktracking
253Meeting Rooms IISolutionMediumHeap
252Meeting RoomsSolutionEasy
251Flatten 2D VectorSolutionMedium
250Count Univalue SubtreesSolutionMediumDFS
249Group Shifted StringsSolution
248Strobogrammatic Number IIISolutionHardRecursion, DFS
247Strobogrammatic Number IISolutionMediumRecursion
246Strobogrammatic NumberSolutionEasy
245Shortest Word Distance IIISolutionMedium
244Shortest Word Distance IISolutionMediumHashMap
243Shortest Word DistanceSolutionEasy
242Valid AnagramSolutionEasy
241Different Ways to Add ParenthesesSolutionMediumDivide and Conquer
240Search a 2D Matrix IISolutionMediumBinary Search
239Sliding Window MaximumSolutionHardHeap
238Product of Array Except SelfSolutionMediumArray
237Delete Node in a Linked ListSolution๐Ÿ“บEasyLinkedList
236Lowest Common Ancestor of a Binary TreeSolutionMediumDFS
235Lowest Common Ancestor of a Binary Search TreeSolutionEasyDFS
234Palindrome Linked ListSolution๐Ÿ“บEasyLinked List
233Number of Digit OneSolutionHardMath
232Implement Queue using StacksSolutionMediumStack, Design
231Power of TwoSolutionEasy
230Kth Smallest Element in a BSTSolutionMediumTree
229Majority Element IISolutionMedium
228Summary RangesSolutionMediumArray
227Basic Calculator IISolutionMediumString
226Invert Binary TreeSolutionEasyDFS, recursion
225Implement Stack using QueuesSolutionEasyStack, Queue
224Basic CalculatorSolutionHard
223Rectangle AreaSolutionEasy
222Count Complete Tree NodesSolutionMediumRecursion
221Maximal SquareSolutionMediumRecursion
220Contains Duplicate IIISolution๐Ÿ“บMediumTreeSet
219Contains Duplicate IISolution๐Ÿ“บEasyHashMap
218The Skyline ProblemSolutionHardTreeMap, Design
217Contains DuplicateSolution๐Ÿ“บEasyHashSet
216Combination Sum IIISolutionMediumBacktracking
215Kth Largest Element in an ArraySolutionMediumHeap
214Shortest PalindromeSolutionHardKMP
213House Robber IISolutionMediumDP
212Word Search IISolutionHardTrie
211Add and Search Word - Data structure designSolutionMediumTrie
210Course Schedule IISolutionMedium
209Minimum Size Subarray SumSolutionMedium
208Implement TrieSolutionMediumTrie
207Course ScheduleSolutionMedium
206Reverse Linked ListSolution๐Ÿ“บEasyLinked List
205Isomorphic StringsSolutionEasy
204Count PrimesSolutionEasyThe Sieve of Eratosthenes
203Remove Linked List ElementsSolutionEasy
202Happy NumberSolutionEasy
201Bitwise AND of Numbers RangeSolutionMediumBit Manipulation
200Number of IslandsSolutionMediumUnion Find, DFS
199Binary Tree Right Side ViewSolutionMediumBFS
198House RobberSolutionEasyDP
191Number of 1 BitsSolutionEasyBit Manipulation
190Reverse BitsSolutionEasyBit Manipulation
189Rotate ArraySolution๐Ÿ“บEasy
188Best Time to Buy and Sell Stock IVSolutionHardDP
187Repeated DNA SequencesSolutionMedium
186Reverse Words in a String IISolutionMedium
179Largest NumberSolutionMedium
174Dungeon GameSolutionHardDP
173Binary Search Tree IteratorSolutionMediumStack, Design
172Factorial Trailing ZeroesSolutionEasy
171Excel Sheet Column NumberSolutionEasy
170Two Sum III - Data structure designSolutionEasy
169Majority ElementSolution๐Ÿ“บEasy
168Excel Sheet Column TitleSolutionEasy
167Two Sum II - Input array is sortedJava, JavascriptEasyBinary Search
166Fraction to Recurring DecimalSolutionMediumHashMap
165Compare Version NumbersSolutionEasy
164Maximum GapSolutionHard
163Missing RangesSolution
162Find Peak ElementSolutionBinary Search
161One Edit DistanceSolution
160Intersection of Two Linked ListsSolutionEasyLinked List
159Longest Substring with At Most Two Distinct CharactersSolutionHardString, Sliding Window
158Read N Characters Given Read4 II - Call multiple timesSolutionHard
157Read N Characters Given Read4SolutionEasy
156Binary Tree Upside DownSolutionMediumTree, Recursion
155Min StackSolutionEasyStack
154Find Minimum in Rotated Sorted Array IISolutionHardArray, Binary Search
153Find Minimum in Rotated Sorted ArraySolutionMediumArray, Binary Search
152Maximum Product SubarraySolutionMediumArray
151Reverse Words in a StringSolutionMediumString
150Evaluate Reverse Polish NotationSolutionMedium
149Max Points on a LineSolutionHard
147Insertion Sort ListSolutionMediumLinked List
146LRU CacheSolutionHardDoubly Linked List, LinkedHashMap
145Binary Tree Postorder TraversalSolution๐Ÿ“บHardBinary Tree
144Binary Tree Preorder TraversalSolution๐Ÿ“บ and ๐Ÿ“บMediumBinary Tree
143Reorder ListSolutionMedium
142Linked List Cycle IISolutionMediumLinked List
141Linked List CycleSolution๐Ÿ“บEasyLinked List
140Word Break IISolutionHardBacktracking/DFS
139Word BreakSolution๐Ÿ“บMediumDP, Pruning
138Copy List with Random PointerSolutionMediumLinkedList, HashMap
137Single Number IISolutionMediumBit Manipulation
136Single NumberSolution๐Ÿ“บEasyBit Manipulation
135CandySolutionHardGreedy
134Gas StationSolutionMediumGreedy
133Clone GraphSolutionMediumHashMap, BFS, Graph
132Palindrome Partitioning IISolutionHard
131Palindrome PartitioningSolutionMedium
130Surrounded RegionsSolutionMedium
129Sum Root to Leaf NumbersSolutionMediumDFS
128Longest Consecutive SequenceSolutionHardUnion Find
127Word LadderSolutionMediumBFS
126Word Ladder IISolutionHardBFS
125Valid PalindromeSolutionEasyTwo Pointers
124Binary Tree Maximum Path SumSolutionHardTree, DFS
123Best Time to Buy and Sell Stock IIISolutionHardDP
122Best Time to Buy and Sell Stock IISolutionEasyGreedy
121Best Time to Buy and Sell StockSolutionEasy
120TriangleSolutionMediumDP
119Pascal's Triangle IISolution๐Ÿ“บEasy
118Pascal's TriangleSolution๐Ÿ“บEasy
117Populating Next Right Pointers in Each Node IISolutionMediumBFS
116Populating Next Right Pointers in Each NodeSolutionMediumBFS
115Distinct SubsequencesSolutionHardDP
114Flatten Binary Tree to Linked ListSolutionMediumTree
113Path Sum IISolutionMediumDFS, Backtracking
112Path SumSolutionEasyDFS
111Minimum Depth of Binary TreeSolutionEasyBFS, DFS
110Balanced Binary TreeSolutionEasyDFS
109Convert Sorted List to Binary Search TreeSolutionMediumDFS, Recursion
108Convert Sorted Array to Binary Search TreeSolution๐Ÿ“บEasyTree
107Binary Tree Level Order Traversal IISolutionEasyBFS
106Construct Binary Tree from Inorder and Postorder TraversalSolutionMediumRecursion, Tree
105Construct Binary Tree from Preorder and Inorder TraversalSolutionMediumRecursion, Tree
104Maximum Depth of Binary TreeSolution๐Ÿ“บEasyDFS
103Binary Tree Zigzag Level Order TraversalSolutionMediumBFS,DFS
102Binary Tree Level Order TraversalSolution๐Ÿ“บMediumBFS
101Symmetric TreeSolution๐Ÿ“บEasyDFS
100Same TreeSolution๐Ÿ“บEasyDFS
99Recover Binary Search TreeSolutionHard
98Validate Binary Search TreeSolution๐Ÿ“บMediumDFS/Recursion
97Interleaving StringSolutionHardDP
96Unique Binary Search TreesSolutionMediumRecursion, DP
95Unique Binary Search Trees IISolutionMediumRecursion
94Binary Tree Inorder TraversalSolution๐Ÿ“บ๐Ÿ“บMediumBinary Tree
93Restore IP AddressesSolutionMediumBacktracking
92Reverse Linked List IISolutionMedium
91Decode WaysSolutionMediumDP
90Subsets IISolutionMediumBacktracking
89Gray CodeSolutionMediumBit Manipulation
88Merge Sorted ArraySolutionEasy
87Scramble StringSolutionHardRecursion
86Partition ListSolutionMediumLinked List
85Maximal RectangleSolutionHardDP
84Largest Rectangle in HistogramSolutionHardArray, Stack
83Remove Duplicates from Sorted ListSolutionEasyLinked List
82Remove Duplicates from Sorted List IISolutionMediumLinked List
81Search in Rotated Sorted Array IISolutionMediumBinary Search
80Remove Duplicates from Sorted Array IISolutionMedium
79Word SearchSolutionMediumBacktracking, DFS
78SubsetsSolutionMediumBacktracking
77CombinationsSolutionMediumBacktracking
76Minimum Window SubstringSolutionHardTwo Pointers
75Sort ColorsSolutionMediumTwo Pointers
74Search a 2D MatrixSolutionMediumBinary Search
73Set Matrix ZeroesSolutionMedium
72Edit DistanceSolutionHard
71Simplify PathSolutionMediumStack
70Climbing StairsSolution๐Ÿ“บEasyDP
69Sqrt(x)SolutionEasy
68Text JustificationSolutionHard
67Add BinarySolutionEasy
66Plus OneSolution๐Ÿ“บEasy
65Valid NumberSolutionHard
64Minimum Path SumSolutionMediumDP
63Unique Paths IISolutionMediumDP
62Unique PathsSolutionMediumDP
61Rotate ListSolutionMediumLinked List
60Permutation SequenceSolutionMediumMath, Backtracking
59Spiral Matrix IISolution๐Ÿ“บMedium
58Length of Last WordSolutionEasy
57Insert IntervalsSolutionHardArray, Sort
56Merge IntervalsSolutionMediumArray, Sort
55Jump GameSolutionMediumGreedy
54Spiral MatrixSolution๐Ÿ“บMediumArray
53Maximum SubarraySolutionEasyArray
52N-Queens IISolutionHardBacktracking
51N-QueensSolutionHard
50Pow(x, n)SolutionMedium
49Group AnagramsSolutionMediumHashMap
48Rotate ImageSolution๐Ÿ“บMediumArray
47Permutations IISolutionMediumBacktracking
46PermutationsSolutionMediumBacktracking
45Jump Game IISolutionHardArray, Greedy
44Wildcard MatchingSolutionHardBacktracking, DP, Greedy, String
43Multiply StringsSolutionMediumArray, String
42Trapping Rain WaterSolutionHard
41First Missing PositiveSolutionHardArray
40Combination Sum IISolutionMediumBacktracking
39Combination SumSolutionMediumBacktracking
38Count and SaySolutionEasyRecursion, LinkedList
37Sudoku SolverSolutionHard
36Valid SudokuSolutionMedium
35Search Insert PositionSolutionEasyArray
34Search for a RangeSolutionMediumArray, Binary Search
33Search in Rotated Sorted ArraySolutionMediumBinary Search
32Longest Valid ParenthesesSolutionHardStack, DP
31Next PermutationSolutionMediumArray
30Substring with Concatenation of All WordsSolutionHardHashMap
29Divide Two IntegersSolutionMedium
28Implement strStr()SolutionEasyString
27Remove ElementSolutionEasy
26Remove Duplicates from Sorted ArraySolution๐Ÿ“บEasyArray
25Reverse Nodes in k-GroupSolutionHardRecursion, LinkedList
24Swap Nodes in PairsSolutionMediumRecursion, LinkedList
23Merge k Sorted ListsSolution๐Ÿ“บHardHeap
22Generate ParenthesesSolutionMediumBacktracking
21Merge Two Sorted ListsSolution๐Ÿ“บEasyRecursion
20Valid ParenthesesSolution๐Ÿ“บEasyStack
19Remove Nth Node From End of ListSolution๐Ÿ“บMediumLinked List
184 SumSolutionMediumTwo Pointers
17Letter Combinations of a Phone NumberSolutionMediumBacktracking
163Sum ClosestSolutionMediumTwo Pointers
153SumSolution, C++๐Ÿ“บMediumTwo Pointers, Binary Search
14Longest Common PrefixSolution๐Ÿ“บEasy
13Roman to IntegerSolutionEasyMath, String
12Integer to RomanSolutionMediumMath, String
11Container With Most WaterSolutionMedium
10Regular Expression MatchingJava, JavascriptHardDP
9Palindrome NumberJava, C++Easy
8String to Integer (atoi)SolutionMedium
7Reverse IntegerSolution, C++๐Ÿ“บEasy
6ZigZag ConversionSolutionEasy
5Longest Palindromic SubstringSolutionMedium
4Median of Two Sorted ArraysSolution, C++HardDivide and Conquer
3Longest Substring Without Repeating CharactersSolution, C++MediumHashMap, Sliding Window
2Add Two NumbersSolutionMediumLinkedList
1Two SumJava, C++, Javascript๐Ÿ“บEasyHashMap

Database

#TitleSolutionsVideoDifficultyTag
1543Fix Product Name FormatSolutionEasy
1517Find Users With Valid E-MailsSolutionEasy
1495Friendly Movies Streamed Last MonthSolutionEasy
1484Group Sold Products By The DateSolutionEasy
1407Top TravellersSolutionEasy
1384Total Sales Amount by YearSolutionHard
1378Replace Employee ID With The Unique IdentifierSolutionEasy
1369Get the Second Most Recent ActivitySolutionHard
1364Number of Trusted Contacts of a CustomerSolutionMedium
1355Activity ParticipantsSolutionMedium
1350Students With Invalid DepartmentsSolutionEasy
1341Movie RatingSolutionMedium
1327List the Products Ordered in a PeriodSolutionEasy
1322Ads PerformanceSolutionEasy
1308Running Total for Different GendersSolutionMedium
1303Find the Team SizeSolutionEasy
1294Weather Type in Each CountrySolutionEasy
1285Find the Start and End Number of Continuous RangesSolutionMedium
1280Students and ExaminationsSolution๐Ÿ“บEasy
1270All People Report to the Given ManagerSolutionMedium
1251Average Selling PriceSolutionEasy
1241Number of Comments per PostSolutionEasy
1179Reformat Department TableSolutionEasy
1173Immediate Food Delivery ISolutionEasy
1148Article Views ISolutionEasy
1141User Activity for the Past 30 Days ISolutionEasy
1084Sales Analysis IIISolutionEasy
1083Sales Analysis IISolutionEasy
1082Sales Analysis ISolutionEasy
1076Project Employees IISolutionEasy
1075Project Employees ISolutionEasy
1069Product Sales Analysis IISolutionEasy
1068Product Sales Analysis ISolutionEasy
1050Actors and Directors Who Cooperated At Least Three TimesSolutionEasy
627Swap SalarySolutionEasy
626Exchange SeatsSolutionMedium
620Not Boring MoviesSolutionEasy
619Biggest Single NumberSolutionEasy
618Students Report By GeographySolutionHardSession Variables
615Average Salary: Departments VS CompanySolutionHard
614Second Degree FollowerSolutionMediumInner Join
613Shortest Distance in a LineSolutionEasy
612Shortest Distance in a PlaneSolutionMedium
610Triangle JudgementSolutionEasy
608Tree NodeSolutionMediumUnion
607Sales PersonSolutionEasy
603Consecutive Available SeatsSolutionEasy
602Friend Requests II: Who Has the Most FriendsSolutionMedium
601Human Traffic of StadiumSolutionHard
597Friend Requests I: Overall Acceptance RateSolutionEasy
596Classes More Than 5 StudentsSolutionEasy
595Big CountriesSolutionEasy
586Customer Placing the Largest Number of OrdersSolutionEasy
585Investments in 2016SolutionMedium
584Find Customer RefereeSolutionEasy
580Count Student Number in DepartmentsSolutionMediumLeft Join
578Get Highest Answer Rate QuestionSolutionMedium
577Employee BonusSolutionEasy
574Winning CandidateSolutionMedium
571Find Median Given Frequency of NumbersSolutionHard
570Managers with at Least 5 Direct ReportsSolutionMedium
569Median Employee SalarySolutionHard
534Game Play Analysis IIISolutionEasy
512Game Play Analysis IISolutionEasy
511Game Play Analysis ISolutionEasy
262Trips and UsersSolutionHardInner Join
197Rising TemperatureSolutionEasy
196Delete Duplicate EmailsSolutionEasy
185Department Top Three SalariesSolutionHard
184Department Highest SalarySolutionMedium
183Customers Who Never OrderSolutionEasy
182Duplicate EmailsSolutionEasy
181Employees Earning More Than Their ManagersSolutionEasy
180Consecutive NumbersSolutionMedium
178Rank ScoresSolutionMedium
177Nth Highest SalarySolutionMedium
176Second Highest SalarySolutionEasy
175Combine Two TablesSolutionEasy

Shell

#TitleSolutionsVideoDifficultyTag
195Tenth LineSolutionEasy
194Transpose FileSolutionMedium
193Valid Phone NumbersSolutionEasy
192Word FrequencySolutionMedium

Contributing

Your ideas/fixes/algorithms are more than welcome!

  1. Please make sure your PR builds after submitting! Check out here: https://travis-ci.org/github/fishercoder1534/Leetcode/pull_requests and look for your PR build.
  2. Fork this repo
  3. Clone your forked repo (git clone https://github.com/YOUR_GITHUB_USERNAME/Leetcode.git) onto your local machine
  4. cd into your cloned directory, create your feature branch (git checkout -b my-awesome-fix)
  5. git add your desired changes to this repo
  6. Commit your changes (git commit -m 'Added some awesome features/fixes')
  7. Push to the branch (git push origin my-awesome-feature)
  8. Open your forked repo on Github website, create a new Pull Request to this repo!

Best way to open this project

  1. Install IntelliJ on your machine, either CE or UE.
  2. git clone this repo to your local disk
  3. import this project as a new project (does need to be imported as a gradle project)
  4. If you run into "Could not determine Java version using executable ..." error, use local gradle distribution: "/usr/local/Cellar/gradle/4.8.1/libexec/" instead of the default one. More details, see this question on Stackoverflow.

About

Solutions to LeetCode problems; updated daily. Subscribe to my YouTube channel for more.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java99.4%
  • Other0.6%
close