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.

100 items

LeetCode 06xx

# Title Difficulty Description
600 LeetCode 600: Non-negative Integers without Consecutive Ones Hard A clear digit dynamic programming solution for counting numbers whose binary representation does not contain consecutive ones.
601 LeetCode 601: Human Traffic of Stadium Hard A SQL guide for finding stadium records that belong to runs of at least three consecutive ids where each row has at least 100 people.
602 LeetCode 602: Friend Requests II: Who Has the Most Friends Medium A SQL guide for counting friendships from both requester and accepter sides, then returning the user with the most friends.
603 LeetCode 603: Consecutive Available Seats Easy A SQL guide for finding all cinema seats that are free and adjacent to at least one other free seat.
604 LeetCode 604: Design Compressed String Iterator Easy A guide to implementing a lazy iterator over a run-length encoded string without fully decompressing it.
605 LeetCode 605: Can Place Flowers Easy A greedy guide for determining whether a given number of flowers can be planted without violating the no-adjacent-flowers rule.
606 LeetCode 606: Construct String from Binary Tree Easy A 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.
607 LeetCode 607: Sales Person Easy A SQL guide for finding salespeople who never had an order related to the company named RED.
608 LeetCode 608: Tree Node Medium A SQL guide for classifying binary tree nodes as Root, Inner, or Leaf based on parent-child relationships.
609 LeetCode 609: Find Duplicate File in System Medium A hash map guide for grouping file paths by identical file content and returning only duplicate groups.
610 LeetCode 610: Triangle Judgement Easy A SQL guide for checking whether three side lengths can form a valid triangle using the triangle inequality.
611 LeetCode 611: Valid Triangle Number Medium A two-pointer guide for counting triplets that can form valid triangles after sorting the side lengths.
612 LeetCode 612: Shortest Distance in a Plane Medium A SQL guide for finding the minimum Euclidean distance between any two points in a 2D plane.
613 LeetCode 613: Shortest Distance in a Line Easy A SQL guide for finding the minimum distance between any two unique points on the X-axis.
614 LeetCode 614: Second Degree Follower Medium A SQL guide for finding users who both follow someone and have followers, then counting how many followers they have.
615 LeetCode 615: Average Salary: Departments VS Company Hard A SQL guide for comparing each department's monthly average salary against the company's monthly average salary.
616 LeetCode 616: Add Bold Tag in String Medium A string-marking guide for adding bold tags around all matched words while merging overlapping and adjacent bold regions.
617 LeetCode 617: Merge Two Binary Trees Easy A recursive tree traversal guide for merging two binary trees node by node.
618 LeetCode 618: Students Report By Geography Hard A SQL guide for pivoting rows into columns using ranking and conditional aggregation.
619 LeetCode 619: Biggest Single Number Easy A SQL guide for finding the largest number that appears exactly once in a table.
620 LeetCode 620: Not Boring Movies Easy A SQL guide for filtering movies with odd IDs and non-boring descriptions, then sorting by rating.
621 LeetCode 621: Task Scheduler Medium A clear explanation of Task Scheduler using frequency counting and the greedy block formula.
622 LeetCode 622: Design Circular Queue Medium A clear explanation of Design Circular Queue using a fixed array, a front pointer, and a size counter.
623 LeetCode 623: Add One Row to Tree Medium A clear explanation of Add One Row to Tree using tree traversal and careful subtree reconnection.
624 LeetCode 624: Maximum Distance in Arrays Medium A clear explanation of Maximum Distance in Arrays using sorted endpoints and a greedy scan.
625 LeetCode 625: Minimum Factorization Medium A clear explanation of Minimum Factorization using greedy digit factors from 9 down to 2.
626 LeetCode 626: Exchange Seats Medium A SQL solution for swapping every pair of adjacent student seats while leaving the final seat unchanged when the row count is odd.
627 LeetCode 627: Swap Salary Easy A SQL update solution for swapping all m and f values in the Salary table using a single statement.
628 LeetCode 628: Maximum Product of Three Numbers Easy A clear explanation of finding the largest product of three numbers using sorting or constant-space tracking.
629 LeetCode 629: K Inverse Pairs Array Hard A dynamic programming solution for counting permutations of 1 to n with exactly k inverse pairs.
630 LeetCode 630: Course Schedule III Hard A greedy heap solution for taking the maximum number of courses before their deadlines.
631 LeetCode 631: Design Excel Sum Formula Hard A design solution for a small Excel-like spreadsheet that supports set, get, and dynamic sum formulas.
632 LeetCode 632: Smallest Range Covering Elements from K Lists Hard A heap-based solution for finding the smallest range that contains at least one number from each sorted list.
633 LeetCode 633: Sum of Square Numbers Medium A two-pointer and number theory solution for checking whether an integer can be written as the sum of two square numbers.
634 LeetCode 634: Find the Derangement of An Array Medium A dynamic programming and combinatorics solution for counting permutations with no fixed positions.
635 LeetCode 635: Design Log Storage System Medium A design solution for storing timestamped logs and retrieving IDs by inclusive time range at a chosen granularity.
636 LeetCode 636: Exclusive Time of Functions Medium A stack-based solution for computing exclusive execution time from nested start and end logs.
637 LeetCode 637: Average of Levels in Binary Tree Easy A breadth-first search solution for computing the average value of nodes at each level of a binary tree.
638 LeetCode 638: Shopping Offers Medium A DFS and memoization solution for finding the minimum cost to satisfy item needs using individual prices and reusable special offers.
639 LeetCode 639: Decode Ways II Hard A dynamic programming solution for counting decodings of a digit string with wildcard characters.
640 LeetCode 640: Solve the Equation Medium A string parsing solution for reducing a linear equation into coefficient and constant terms.
641 LeetCode 641: Design Circular Deque Medium An array-based circular buffer solution for implementing a fixed-size double-ended queue.
642 LeetCode 642: Design Search Autocomplete System Hard A trie-based design for returning the top three historical sentences for a typed prefix.
643 LeetCode 643: Maximum Average Subarray I Easy A sliding window solution for finding the maximum average among all contiguous subarrays of fixed length k.
644 LeetCode 644: Maximum Average Subarray II Hard A binary search solution for finding the maximum average of any contiguous subarray with length at least k.
645 LeetCode 645: Set Mismatch Easy A counting and math solution for finding the duplicated number and the missing number in a corrupted set.
646 LeetCode 646: Maximum Length of Pair Chain Medium A greedy interval scheduling solution for finding the longest chain of valid pairs.
647 LeetCode 647: Palindromic Substrings Medium A center expansion solution for counting every palindromic substring in a string.
648 LeetCode 648: Replace Words Medium A trie-based solution for replacing each derivative word with the shortest matching root.
649 LeetCode 649: Dota2 Senate Medium A queue-based simulation for predicting which party wins after senators ban opponents in turn order.
650 LeetCode 650: 2 Keys Keyboard Medium A dynamic programming and prime factorization solution for finding the minimum operations needed to produce n characters.
651 LeetCode 651: 4 Keys Keyboard Medium A dynamic programming solution for maximizing the number of A characters printed with a limited number of keyboard operations.
652 LeetCode 652: Find Duplicate Subtrees Medium A clear explanation of finding duplicate binary tree subtrees using postorder traversal, serialization, and a hash map.
653 LeetCode 653: Two Sum IV - Input is a BST Easy A clear explanation of finding whether two different nodes in a binary search tree sum to a target value.
654 LeetCode 654: Maximum Binary Tree Medium A clear explanation of constructing a maximum binary tree recursively using divide and conquer.
655 LeetCode 655: Print Binary Tree Medium A clear explanation of formatting a binary tree into a 2D string matrix using tree height and recursive placement.
656 LeetCode 656: Coin Path Hard A clear explanation of finding the minimum-cost path with bounded jumps, blocked cells, and lexicographic tie-breaking.
657 LeetCode 657: Robot Return to Origin Easy A clear explanation of determining whether a robot returns to the origin after executing movement instructions.
658 LeetCode 658: Find K Closest Elements Medium A clear explanation of finding the k closest elements to a target using binary search and a sliding window.
659 LeetCode 659: Split Array into Consecutive Subsequences Medium A clear explanation of deciding whether a sorted array can be split into consecutive subsequences of length at least three.
660 LeetCode 660: Remove 9 Hard A clear explanation of finding the nth positive integer that does not contain the digit 9 using base-9 conversion.
661 LeetCode 661: Image Smoother Easy A clear explanation of averaging neighboring pixels in a matrix using direct simulation.
662 LeetCode 662: Maximum Width of Binary Tree Medium A clear explanation of computing the maximum width of a binary tree using level-order traversal and complete-tree indices.
663 LeetCode 663: Equal Tree Partition Medium A clear explanation of checking whether a binary tree can be split into two equal-sum trees by removing one edge.
664 LeetCode 664: Strange Printer Hard A clear explanation of minimizing printer turns using interval dynamic programming.
665 LeetCode 665: Non-decreasing Array Medium A clear explanation of checking whether an array can become non-decreasing by modifying at most one element.
666 LeetCode 666: Path Sum IV Medium A clear explanation of computing all root-to-leaf path sums from a compact three-digit binary tree encoding.
667 LeetCode 667: Beautiful Arrangement II Medium A clear explanation of constructing an array with exactly k distinct adjacent differences using a greedy pattern.
668 LeetCode 668: Kth Smallest Number in Multiplication Table Hard A clear explanation of finding the kth smallest value in an m by n multiplication table using binary search on answer.
669 LeetCode 669: Trim a Binary Search Tree Medium A clear explanation of trimming a BST so that all remaining node values lie inside a given inclusive range.
670 LeetCode 670: Maximum Swap Medium A clear explanation of maximizing an integer by swapping at most two digits once.
671 LeetCode 671: Second Minimum Node In a Binary Tree Easy A clear explanation of finding the second minimum value in a special binary tree using DFS.
672 LeetCode 672: Bulb Switcher II Medium A clear explanation of counting possible bulb states after pressing four toggle buttons exactly presses times.
673 LeetCode 673: Number of Longest Increasing Subsequence Medium A clear explanation of counting how many longest strictly increasing subsequences exist using dynamic programming.
674 LeetCode 674: Longest Continuous Increasing Subsequence Easy A clear explanation of finding the longest strictly increasing contiguous subarray using a single scan.
675 LeetCode 675: Cut Off Trees for Golf Event Hard A clear explanation of cutting trees in increasing height order using repeated BFS on a grid.
676 LeetCode 676: Implement Magic Dictionary Medium Design a dictionary that can check whether a word can match a stored word after changing exactly one character.
677 LeetCode 677: Map Sum Pairs Medium Design a map that supports key-value insertion and prefix-sum queries using a hash map and trie.
678 LeetCode 678: Valid Parenthesis String Medium Check whether a string containing parentheses and wildcard stars can be made valid using a greedy range of possible open counts.
679 LeetCode 679: 24 Game Hard Determine whether four numbers can be combined with arithmetic operations and parentheses to produce 24.
680 LeetCode 680: Valid Palindrome II Easy Check whether a string can become a palindrome after deleting at most one character using two pointers.
681 LeetCode 681: Next Closest Time Medium Find the next valid 24-hour time using only the digits from the current time.
682 LeetCode 682: Baseball Game Easy Simulate a baseball scoring system using a stack to process operations and compute the final score.
683 LeetCode 683: K Empty Slots Hard Find the earliest day when two turned-on bulbs have exactly k turned-off bulbs between them using a sliding window over bloom days.
684 LeetCode 684: Redundant Connection Medium Find the extra edge in an undirected graph that creates a cycle using Union-Find.
685 LeetCode 685: Redundant Connection II Hard Find the directed edge to remove so a graph becomes a rooted tree again, handling both cycles and nodes with two parents.
686 LeetCode 686: Repeated String Match Medium Find the minimum number of times one string must be repeated so another string becomes a substring.
687 LeetCode 687: Longest Univalue Path Medium Find the longest path in a binary tree where every node on the path has the same value using depth-first search.
688 LeetCode 688: Knight Probability in Chessboard Medium Compute the probability that a knight remains on an n x n chessboard after exactly k random moves using dynamic programming.
689 LeetCode 689: Maximum Sum of 3 Non-Overlapping Subarrays Hard Find three non-overlapping subarrays of length k with maximum total sum and return the lexicographically smallest starting indices.
690 LeetCode 690: Employee Importance Medium Compute the total importance of an employee and all direct and indirect subordinates using a hash map and depth-first search.
691 LeetCode 691: Stickers to Spell Word Hard Find the minimum number of stickers needed to form a target string using top-down dynamic programming with memoization.
692 LeetCode 692: Top K Frequent Words Medium Find the k most frequent words using frequency counting and custom sorting by count and lexicographical order.
693 LeetCode 693: Binary Number with Alternating Bits Easy Check whether every adjacent bit in a positive integer's binary representation is different.
694 LeetCode 694: Number of Distinct Islands Medium Count unique island shapes in a binary grid using DFS and relative coordinates.
695 LeetCode 695: Max Area of Island Medium Find the largest connected island area in a binary grid using depth-first search.
696 LeetCode 696: Count Binary Substrings Easy Count substrings with equal consecutive groups of 0s and 1s using run lengths.
697 LeetCode 697: Degree of an Array Easy Find the shortest contiguous subarray with the same degree as the whole array using frequency counts and first occurrence indices.
698 LeetCode 698: Partition to K Equal Sum Subsets Medium Decide whether an array can be divided into k non-empty subsets with equal sums using backtracking and pruning.
699 LeetCode 699: Falling Squares Hard Simulate falling squares on a number line and track the maximum stack height after each placement.