Skip to content

LeetCode 06xx

LeetCode practice notes for problems 600 through 699, including A clear digit dynamic programming solution for counting numbers whose binary representation does not contain consecutive ones.

#TitleDifficultyDescription
600LeetCode 600: Non-negative Integers without Consecutive OnesHardA clear digit dynamic programming solution for counting numbers whose binary representation does not contain consecutive ones.
601LeetCode 601: Human Traffic of StadiumHardA SQL guide for finding stadium records that belong to runs of at least three consecutive ids where each row has at least 100 people.
602LeetCode 602: Friend Requests II: Who Has the Most FriendsMediumA SQL guide for counting friendships from both requester and accepter sides, then returning the user with the most friends.
603LeetCode 603: Consecutive Available SeatsEasyA SQL guide for finding all cinema seats that are free and adjacent to at least one other free seat.
604LeetCode 604: Design Compressed String IteratorEasyA guide to implementing a lazy iterator over a run-length encoded string without fully decompressing it.
605LeetCode 605: Can Place FlowersEasyA greedy guide for determining whether a given number of flowers can be planted without violating the no-adjacent-flowers rule.
606LeetCode 606: Construct String from Binary TreeEasyA recursive guide for converting a binary tree into a preorder parenthesized string while preserving the one-to-one mapping between the tree and the string.
607LeetCode 607: Sales PersonEasyA SQL guide for finding salespeople who never had an order related to the company named RED.
608LeetCode 608: Tree NodeMediumA SQL guide for classifying binary tree nodes as Root, Inner, or Leaf based on parent-child relationships.
609LeetCode 609: Find Duplicate File in SystemMediumA hash map guide for grouping file paths by identical file content and returning only duplicate groups.
610LeetCode 610: Triangle JudgementEasyA SQL guide for checking whether three side lengths can form a valid triangle using the triangle inequality.
611LeetCode 611: Valid Triangle NumberMediumA two-pointer guide for counting triplets that can form valid triangles after sorting the side lengths.
612LeetCode 612: Shortest Distance in a PlaneMediumA SQL guide for finding the minimum Euclidean distance between any two points in a 2D plane.
613LeetCode 613: Shortest Distance in a LineEasyA SQL guide for finding the minimum distance between any two unique points on the X-axis.
614LeetCode 614: Second Degree FollowerMediumA SQL guide for finding users who both follow someone and have followers, then counting how many followers they have.
615LeetCode 615: Average Salary: Departments VS CompanyHardA SQL guide for comparing each department’s monthly average salary against the company’s monthly average salary.
616LeetCode 616: Add Bold Tag in StringMediumA string-marking guide for adding bold tags around all matched words while merging overlapping and adjacent bold regions.
617LeetCode 617: Merge Two Binary TreesEasyA recursive tree traversal guide for merging two binary trees node by node.
618LeetCode 618: Students Report By GeographyHardA SQL guide for pivoting rows into columns using ranking and conditional aggregation.
619LeetCode 619: Biggest Single NumberEasyA SQL guide for finding the largest number that appears exactly once in a table.
620LeetCode 620: Not Boring MoviesEasyA SQL guide for filtering movies with odd IDs and non-boring descriptions, then sorting by rating.
621LeetCode 621: Task SchedulerMediumA clear explanation of Task Scheduler using frequency counting and the greedy block formula.
622LeetCode 622: Design Circular QueueMediumA clear explanation of Design Circular Queue using a fixed array, a front pointer, and a size counter.
623LeetCode 623: Add One Row to TreeMediumA clear explanation of Add One Row to Tree using tree traversal and careful subtree reconnection.
624LeetCode 624: Maximum Distance in ArraysMediumA clear explanation of Maximum Distance in Arrays using sorted endpoints and a greedy scan.
625LeetCode 625: Minimum FactorizationMediumA clear explanation of Minimum Factorization using greedy digit factors from 9 down to 2.
626LeetCode 626: Exchange SeatsMediumA SQL solution for swapping every pair of adjacent student seats while leaving the final seat unchanged when the row count is odd.
627LeetCode 627: Swap SalaryEasyA SQL update solution for swapping all m and f values in the Salary table using a single statement.
628LeetCode 628: Maximum Product of Three NumbersEasyA clear explanation of finding the largest product of three numbers using sorting or constant-space tracking.
629LeetCode 629: K Inverse Pairs ArrayHardA dynamic programming solution for counting permutations of 1 to n with exactly k inverse pairs.
630LeetCode 630: Course Schedule IIIHardA greedy heap solution for taking the maximum number of courses before their deadlines.
631LeetCode 631: Design Excel Sum FormulaHardA design solution for a small Excel-like spreadsheet that supports set, get, and dynamic sum formulas.
632LeetCode 632: Smallest Range Covering Elements from K ListsHardA heap-based solution for finding the smallest range that contains at least one number from each sorted list.
633LeetCode 633: Sum of Square NumbersMediumA two-pointer and number theory solution for checking whether an integer can be written as the sum of two square numbers.
634LeetCode 634: Find the Derangement of An ArrayMediumA dynamic programming and combinatorics solution for counting permutations with no fixed positions.
635LeetCode 635: Design Log Storage SystemMediumA design solution for storing timestamped logs and retrieving IDs by inclusive time range at a chosen granularity.
636LeetCode 636: Exclusive Time of FunctionsMediumA stack-based solution for computing exclusive execution time from nested start and end logs.
637LeetCode 637: Average of Levels in Binary TreeEasyA breadth-first search solution for computing the average value of nodes at each level of a binary tree.
638LeetCode 638: Shopping OffersMediumA DFS and memoization solution for finding the minimum cost to satisfy item needs using individual prices and reusable special offers.
639LeetCode 639: Decode Ways IIHardA dynamic programming solution for counting decodings of a digit string with wildcard characters.
640LeetCode 640: Solve the EquationMediumA string parsing solution for reducing a linear equation into coefficient and constant terms.
641LeetCode 641: Design Circular DequeMediumAn array-based circular buffer solution for implementing a fixed-size double-ended queue.
642LeetCode 642: Design Search Autocomplete SystemHardA trie-based design for returning the top three historical sentences for a typed prefix.
643LeetCode 643: Maximum Average Subarray IEasyA sliding window solution for finding the maximum average among all contiguous subarrays of fixed length k.
644LeetCode 644: Maximum Average Subarray IIHardA binary search solution for finding the maximum average of any contiguous subarray with length at least k.
645LeetCode 645: Set MismatchEasyA counting and math solution for finding the duplicated number and the missing number in a corrupted set.
646LeetCode 646: Maximum Length of Pair ChainMediumA greedy interval scheduling solution for finding the longest chain of valid pairs.
647LeetCode 647: Palindromic SubstringsMediumA center expansion solution for counting every palindromic substring in a string.
648LeetCode 648: Replace WordsMediumA trie-based solution for replacing each derivative word with the shortest matching root.
649LeetCode 649: Dota2 SenateMediumA queue-based simulation for predicting which party wins after senators ban opponents in turn order.
650LeetCode 650: 2 Keys KeyboardMediumA dynamic programming and prime factorization solution for finding the minimum operations needed to produce n characters.
651LeetCode 651: 4 Keys KeyboardMediumA dynamic programming solution for maximizing the number of A characters printed with a limited number of keyboard operations.
652LeetCode 652: Find Duplicate SubtreesMediumA clear explanation of finding duplicate binary tree subtrees using postorder traversal, serialization, and a hash map.
653LeetCode 653: Two Sum IV - Input is a BSTEasyA clear explanation of finding whether two different nodes in a binary search tree sum to a target value.
654LeetCode 654: Maximum Binary TreeMediumA clear explanation of constructing a maximum binary tree recursively using divide and conquer.
655LeetCode 655: Print Binary TreeMediumA clear explanation of formatting a binary tree into a 2D string matrix using tree height and recursive placement.
656LeetCode 656: Coin PathHardA clear explanation of finding the minimum-cost path with bounded jumps, blocked cells, and lexicographic tie-breaking.
657LeetCode 657: Robot Return to OriginEasyA clear explanation of determining whether a robot returns to the origin after executing movement instructions.
658LeetCode 658: Find K Closest ElementsMediumA clear explanation of finding the k closest elements to a target using binary search and a sliding window.
659LeetCode 659: Split Array into Consecutive SubsequencesMediumA clear explanation of deciding whether a sorted array can be split into consecutive subsequences of length at least three.
660LeetCode 660: Remove 9HardA clear explanation of finding the nth positive integer that does not contain the digit 9 using base-9 conversion.
661LeetCode 661: Image SmootherEasyA clear explanation of averaging neighboring pixels in a matrix using direct simulation.
662LeetCode 662: Maximum Width of Binary TreeMediumA clear explanation of computing the maximum width of a binary tree using level-order traversal and complete-tree indices.
663LeetCode 663: Equal Tree PartitionMediumA clear explanation of checking whether a binary tree can be split into two equal-sum trees by removing one edge.
664LeetCode 664: Strange PrinterHardA clear explanation of minimizing printer turns using interval dynamic programming.
665LeetCode 665: Non-decreasing ArrayMediumA clear explanation of checking whether an array can become non-decreasing by modifying at most one element.
666LeetCode 666: Path Sum IVMediumA clear explanation of computing all root-to-leaf path sums from a compact three-digit binary tree encoding.
667LeetCode 667: Beautiful Arrangement IIMediumA clear explanation of constructing an array with exactly k distinct adjacent differences using a greedy pattern.
668LeetCode 668: Kth Smallest Number in Multiplication TableHardA clear explanation of finding the kth smallest value in an m by n multiplication table using binary search on answer.
669LeetCode 669: Trim a Binary Search TreeMediumA clear explanation of trimming a BST so that all remaining node values lie inside a given inclusive range.
670LeetCode 670: Maximum SwapMediumA clear explanation of maximizing an integer by swapping at most two digits once.
671LeetCode 671: Second Minimum Node In a Binary TreeEasyA clear explanation of finding the second minimum value in a special binary tree using DFS.
672LeetCode 672: Bulb Switcher IIMediumA clear explanation of counting possible bulb states after pressing four toggle buttons exactly presses times.
673LeetCode 673: Number of Longest Increasing SubsequenceMediumA clear explanation of counting how many longest strictly increasing subsequences exist using dynamic programming.
674LeetCode 674: Longest Continuous Increasing SubsequenceEasyA clear explanation of finding the longest strictly increasing contiguous subarray using a single scan.
675LeetCode 675: Cut Off Trees for Golf EventHardA clear explanation of cutting trees in increasing height order using repeated BFS on a grid.
676LeetCode 676: Implement Magic DictionaryMediumDesign a dictionary that can check whether a word can match a stored word after changing exactly one character.
677LeetCode 677: Map Sum PairsMediumDesign a map that supports key-value insertion and prefix-sum queries using a hash map and trie.
678LeetCode 678: Valid Parenthesis StringMediumCheck whether a string containing parentheses and wildcard stars can be made valid using a greedy range of possible open counts.
679LeetCode 679: 24 GameHardDetermine whether four numbers can be combined with arithmetic operations and parentheses to produce 24.
680LeetCode 680: Valid Palindrome IIEasyCheck whether a string can become a palindrome after deleting at most one character using two pointers.
681LeetCode 681: Next Closest TimeMediumFind the next valid 24-hour time using only the digits from the current time.
682LeetCode 682: Baseball GameEasySimulate a baseball scoring system using a stack to process operations and compute the final score.
683LeetCode 683: K Empty SlotsHardFind the earliest day when two turned-on bulbs have exactly k turned-off bulbs between them using a sliding window over bloom days.
684LeetCode 684: Redundant ConnectionMediumFind the extra edge in an undirected graph that creates a cycle using Union-Find.
685LeetCode 685: Redundant Connection IIHardFind the directed edge to remove so a graph becomes a rooted tree again, handling both cycles and nodes with two parents.
686LeetCode 686: Repeated String MatchMediumFind the minimum number of times one string must be repeated so another string becomes a substring.
687LeetCode 687: Longest Univalue PathMediumFind the longest path in a binary tree where every node on the path has the same value using depth-first search.
688LeetCode 688: Knight Probability in ChessboardMediumCompute the probability that a knight remains on an n x n chessboard after exactly k random moves using dynamic programming.
689LeetCode 689: Maximum Sum of 3 Non-Overlapping SubarraysHardFind three non-overlapping subarrays of length k with maximum total sum and return the lexicographically smallest starting indices.
690LeetCode 690: Employee ImportanceMediumCompute the total importance of an employee and all direct and indirect subordinates using a hash map and depth-first search.
691LeetCode 691: Stickers to Spell WordHardFind the minimum number of stickers needed to form a target string using top-down dynamic programming with memoization.
692LeetCode 692: Top K Frequent WordsMediumFind the k most frequent words using frequency counting and custom sorting by count and lexicographical order.
693LeetCode 693: Binary Number with Alternating BitsEasyCheck whether every adjacent bit in a positive integer’s binary representation is different.
694LeetCode 694: Number of Distinct IslandsMediumCount unique island shapes in a binary grid using DFS and relative coordinates.
695LeetCode 695: Max Area of IslandMediumFind the largest connected island area in a binary grid using depth-first search.
696LeetCode 696: Count Binary SubstringsEasyCount substrings with equal consecutive groups of 0s and 1s using run lengths.
697LeetCode 697: Degree of an ArrayEasyFind the shortest contiguous subarray with the same degree as the whole array using frequency counts and first occurrence indices.
698LeetCode 698: Partition to K Equal Sum SubsetsMediumDecide whether an array can be divided into k non-empty subsets with equal sums using backtracking and pruning.
699LeetCode 699: Falling SquaresHardSimulate falling squares on a number line and track the maximum stack height after each placement.
LeetCode 600: Non-negative Integers without Consecutive OnesA clear digit dynamic programming solution for counting numbers whose binary representation does not contain consecutive ones.
7 min
LeetCode 601: Human Traffic of StadiumA SQL guide for finding stadium records that belong to runs of at least three consecutive ids where each row has at least 100 people.
5 min
LeetCode 602: Friend Requests II: Who Has the Most FriendsA SQL guide for counting friendships from both requester and accepter sides, then returning the user with the most friends.
5 min
LeetCode 603: Consecutive Available SeatsA SQL guide for finding all cinema seats that are free and adjacent to at least one other free seat.
4 min
LeetCode 604: Design Compressed String IteratorA guide to implementing a lazy iterator over a run-length encoded string without fully decompressing it.
6 min
LeetCode 605: Can Place FlowersA greedy guide for determining whether a given number of flowers can be planted without violating the no-adjacent-flowers rule.
5 min
LeetCode 606: Construct String from Binary TreeA recursive guide for converting a binary tree into a preorder parenthesized string while preserving the one-to-one mapping between the tree and the string.
4 min
LeetCode 607: Sales PersonA SQL guide for finding salespeople who never had an order related to the company named RED.
5 min
LeetCode 608: Tree NodeA SQL guide for classifying binary tree nodes as Root, Inner, or Leaf based on parent-child relationships.
4 min
LeetCode 609: Find Duplicate File in SystemA hash map guide for grouping file paths by identical file content and returning only duplicate groups.
5 min
LeetCode 610: Triangle JudgementA SQL guide for checking whether three side lengths can form a valid triangle using the triangle inequality.
4 min
LeetCode 611: Valid Triangle NumberA two-pointer guide for counting triplets that can form valid triangles after sorting the side lengths.
5 min
LeetCode 612: Shortest Distance in a PlaneA SQL guide for finding the minimum Euclidean distance between any two points in a 2D plane.
4 min
LeetCode 613: Shortest Distance in a LineA SQL guide for finding the minimum distance between any two unique points on the X-axis.
3 min
LeetCode 614: Second Degree FollowerA SQL guide for finding users who both follow someone and have followers, then counting how many followers they have.
5 min
LeetCode 615: Average Salary: Departments VS CompanyA SQL guide for comparing each department's monthly average salary against the company's monthly average salary.
5 min
LeetCode 616: Add Bold Tag in StringA string-marking guide for adding bold tags around all matched words while merging overlapping and adjacent bold regions.
5 min
LeetCode 617: Merge Two Binary TreesA recursive tree traversal guide for merging two binary trees node by node.
4 min
LeetCode 618: Students Report By GeographyA SQL guide for pivoting rows into columns using ranking and conditional aggregation.
4 min
LeetCode 619: Biggest Single NumberA SQL guide for finding the largest number that appears exactly once in a table.
3 min
LeetCode 620: Not Boring MoviesA SQL guide for filtering movies with odd IDs and non-boring descriptions, then sorting by rating.
3 min
LeetCode 621: Task SchedulerA clear explanation of Task Scheduler using frequency counting and the greedy block formula.
6 min
LeetCode 622: Design Circular QueueA clear explanation of Design Circular Queue using a fixed array, a front pointer, and a size counter.
7 min
LeetCode 623: Add One Row to TreeA clear explanation of Add One Row to Tree using tree traversal and careful subtree reconnection.
7 min
LeetCode 624: Maximum Distance in ArraysA clear explanation of Maximum Distance in Arrays using sorted endpoints and a greedy scan.
6 min
LeetCode 625: Minimum FactorizationA clear explanation of Minimum Factorization using greedy digit factors from 9 down to 2.
6 min
LeetCode 626: Exchange SeatsA SQL solution for swapping every pair of adjacent student seats while leaving the final seat unchanged when the row count is odd.
5 min
LeetCode 627: Swap SalaryA SQL update solution for swapping all m and f values in the Salary table using a single statement.
4 min
LeetCode 628: Maximum Product of Three NumbersA clear explanation of finding the largest product of three numbers using sorting or constant-space tracking.
5 min
LeetCode 629: K Inverse Pairs ArrayA dynamic programming solution for counting permutations of 1 to n with exactly k inverse pairs.
7 min
LeetCode 630: Course Schedule IIIA greedy heap solution for taking the maximum number of courses before their deadlines.
5 min
LeetCode 631: Design Excel Sum FormulaA design solution for a small Excel-like spreadsheet that supports set, get, and dynamic sum formulas.
7 min
LeetCode 632: Smallest Range Covering Elements from K ListsA heap-based solution for finding the smallest range that contains at least one number from each sorted list.
7 min
LeetCode 633: Sum of Square NumbersA two-pointer and number theory solution for checking whether an integer can be written as the sum of two square numbers.
5 min
LeetCode 634: Find the Derangement of An ArrayA dynamic programming and combinatorics solution for counting permutations with no fixed positions.
5 min
LeetCode 635: Design Log Storage SystemA design solution for storing timestamped logs and retrieving IDs by inclusive time range at a chosen granularity.
5 min
LeetCode 636: Exclusive Time of FunctionsA stack-based solution for computing exclusive execution time from nested start and end logs.
5 min
LeetCode 637: Average of Levels in Binary TreeA breadth-first search solution for computing the average value of nodes at each level of a binary tree.
5 min
LeetCode 638: Shopping OffersA DFS and memoization solution for finding the minimum cost to satisfy item needs using individual prices and reusable special offers.
6 min
LeetCode 639: Decode Ways IIA dynamic programming solution for counting decodings of a digit string with wildcard characters.
7 min
LeetCode 640: Solve the EquationA string parsing solution for reducing a linear equation into coefficient and constant terms.
6 min
LeetCode 641: Design Circular DequeAn array-based circular buffer solution for implementing a fixed-size double-ended queue.
6 min
LeetCode 642: Design Search Autocomplete SystemA trie-based design for returning the top three historical sentences for a typed prefix.
7 min
LeetCode 643: Maximum Average Subarray IA sliding window solution for finding the maximum average among all contiguous subarrays of fixed length k.
4 min
LeetCode 644: Maximum Average Subarray IIA binary search solution for finding the maximum average of any contiguous subarray with length at least k.
6 min
LeetCode 645: Set MismatchA counting and math solution for finding the duplicated number and the missing number in a corrupted set.
4 min
LeetCode 646: Maximum Length of Pair ChainA greedy interval scheduling solution for finding the longest chain of valid pairs.
5 min
LeetCode 647: Palindromic SubstringsA center expansion solution for counting every palindromic substring in a string.
5 min
LeetCode 648: Replace WordsA trie-based solution for replacing each derivative word with the shortest matching root.
6 min
LeetCode 649: Dota2 SenateA queue-based simulation for predicting which party wins after senators ban opponents in turn order.
5 min
LeetCode 650: 2 Keys KeyboardA dynamic programming and prime factorization solution for finding the minimum operations needed to produce n characters.
5 min
LeetCode 651: 4 Keys KeyboardA dynamic programming solution for maximizing the number of A characters printed with a limited number of keyboard operations.
6 min
LeetCode 652: Find Duplicate SubtreesA clear explanation of finding duplicate binary tree subtrees using postorder traversal, serialization, and a hash map.
6 min
LeetCode 653: Two Sum IV - Input is a BSTA clear explanation of finding whether two different nodes in a binary search tree sum to a target value.
6 min
LeetCode 654: Maximum Binary TreeA clear explanation of constructing a maximum binary tree recursively using divide and conquer.
5 min
LeetCode 655: Print Binary TreeA clear explanation of formatting a binary tree into a 2D string matrix using tree height and recursive placement.
6 min
LeetCode 656: Coin PathA clear explanation of finding the minimum-cost path with bounded jumps, blocked cells, and lexicographic tie-breaking.
7 min
LeetCode 657: Robot Return to OriginA clear explanation of determining whether a robot returns to the origin after executing movement instructions.
4 min
LeetCode 658: Find K Closest ElementsA clear explanation of finding the k closest elements to a target using binary search and a sliding window.
5 min
LeetCode 659: Split Array into Consecutive SubsequencesA clear explanation of deciding whether a sorted array can be split into consecutive subsequences of length at least three.
6 min
LeetCode 660: Remove 9A clear explanation of finding the nth positive integer that does not contain the digit 9 using base-9 conversion.
3 min
LeetCode 661: Image SmootherA clear explanation of averaging neighboring pixels in a matrix using direct simulation.
5 min
LeetCode 662: Maximum Width of Binary TreeA clear explanation of computing the maximum width of a binary tree using level-order traversal and complete-tree indices.
6 min
LeetCode 663: Equal Tree PartitionA clear explanation of checking whether a binary tree can be split into two equal-sum trees by removing one edge.
6 min
LeetCode 664: Strange PrinterA clear explanation of minimizing printer turns using interval dynamic programming.
6 min
LeetCode 665: Non-decreasing ArrayA clear explanation of checking whether an array can become non-decreasing by modifying at most one element.
5 min
LeetCode 666: Path Sum IVA clear explanation of computing all root-to-leaf path sums from a compact three-digit binary tree encoding.
6 min
LeetCode 667: Beautiful Arrangement IIA clear explanation of constructing an array with exactly k distinct adjacent differences using a greedy pattern.
5 min
LeetCode 668: Kth Smallest Number in Multiplication TableA clear explanation of finding the kth smallest value in an m by n multiplication table using binary search on answer.
6 min
LeetCode 669: Trim a Binary Search TreeA clear explanation of trimming a BST so that all remaining node values lie inside a given inclusive range.
6 min
LeetCode 670: Maximum SwapA clear explanation of maximizing an integer by swapping at most two digits once.
5 min
LeetCode 671: Second Minimum Node In a Binary TreeA clear explanation of finding the second minimum value in a special binary tree using DFS.
5 min
LeetCode 672: Bulb Switcher IIA clear explanation of counting possible bulb states after pressing four toggle buttons exactly presses times.
6 min
LeetCode 673: Number of Longest Increasing SubsequenceA clear explanation of counting how many longest strictly increasing subsequences exist using dynamic programming.
5 min
LeetCode 674: Longest Continuous Increasing SubsequenceA clear explanation of finding the longest strictly increasing contiguous subarray using a single scan.
4 min
LeetCode 675: Cut Off Trees for Golf EventA clear explanation of cutting trees in increasing height order using repeated BFS on a grid.
7 min
LeetCode 676: Implement Magic DictionaryDesign a dictionary that can check whether a word can match a stored word after changing exactly one character.
6 min
LeetCode 677: Map Sum PairsDesign a map that supports key-value insertion and prefix-sum queries using a hash map and trie.
7 min
LeetCode 678: Valid Parenthesis StringCheck whether a string containing parentheses and wildcard stars can be made valid using a greedy range of possible open counts.
6 min
LeetCode 679: 24 GameDetermine whether four numbers can be combined with arithmetic operations and parentheses to produce 24.
7 min
LeetCode 680: Valid Palindrome IICheck whether a string can become a palindrome after deleting at most one character using two pointers.
6 min
LeetCode 681: Next Closest TimeFind the next valid 24-hour time using only the digits from the current time.
6 min
LeetCode 682: Baseball GameSimulate a baseball scoring system using a stack to process operations and compute the final score.
5 min
LeetCode 683: K Empty SlotsFind the earliest day when two turned-on bulbs have exactly k turned-off bulbs between them using a sliding window over bloom days.
7 min
LeetCode 684: Redundant ConnectionFind the extra edge in an undirected graph that creates a cycle using Union-Find.
5 min
LeetCode 685: Redundant Connection IIFind the directed edge to remove so a graph becomes a rooted tree again, handling both cycles and nodes with two parents.
6 min
LeetCode 686: Repeated String MatchFind the minimum number of times one string must be repeated so another string becomes a substring.
5 min
LeetCode 687: Longest Univalue PathFind the longest path in a binary tree where every node on the path has the same value using depth-first search.
6 min
LeetCode 688: Knight Probability in ChessboardCompute the probability that a knight remains on an n x n chessboard after exactly k random moves using dynamic programming.
6 min
LeetCode 689: Maximum Sum of 3 Non-Overlapping SubarraysFind three non-overlapping subarrays of length k with maximum total sum and return the lexicographically smallest starting indices.
8 min
LeetCode 690: Employee ImportanceCompute the total importance of an employee and all direct and indirect subordinates using a hash map and depth-first search.
5 min
LeetCode 691: Stickers to Spell WordFind the minimum number of stickers needed to form a target string using top-down dynamic programming with memoization.
6 min
LeetCode 692: Top K Frequent WordsFind the k most frequent words using frequency counting and custom sorting by count and lexicographical order.
4 min
LeetCode 693: Binary Number with Alternating BitsCheck whether every adjacent bit in a positive integer's binary representation is different.
3 min
LeetCode 694: Number of Distinct IslandsCount unique island shapes in a binary grid using DFS and relative coordinates.
6 min
LeetCode 695: Max Area of IslandFind the largest connected island area in a binary grid using depth-first search.
5 min
LeetCode 696: Count Binary SubstringsCount substrings with equal consecutive groups of 0s and 1s using run lengths.
5 min
LeetCode 697: Degree of an ArrayFind the shortest contiguous subarray with the same degree as the whole array using frequency counts and first occurrence indices.
6 min
LeetCode 698: Partition to K Equal Sum SubsetsDecide whether an array can be divided into k non-empty subsets with equal sums using backtracking and pruning.
6 min
LeetCode 699: Falling SquaresSimulate falling squares on a number line and track the maximum stack height after each placement.
5 min