LeetCode 05xx

LeetCode practice notes for problems 500 through 599, including A clear explanation of filtering words that can be typed using only one row of an American keyboard.

100 items

LeetCode 05xx

# Title Difficulty Description
500 LeetCode 500: Keyboard Row Easy A clear explanation of filtering words that can be typed using only one row of an American keyboard.
501 LeetCode 501: Find Mode in Binary Search Tree Easy A clear explanation of finding the most frequent value or values in a binary search tree using inorder traversal.
502 LeetCode 502: IPO Hard A clear explanation of maximizing capital by selecting at most k projects using sorting and a max heap.
503 LeetCode 503: Next Greater Element II Medium A clear explanation of finding the next greater element in a circular array using a monotonic stack.
504 LeetCode 504: Base 7 Easy A clear explanation of converting an integer into its base 7 string representation using repeated division.
505 LeetCode 505: The Maze II Medium A clear explanation of finding the shortest rolling distance in a maze using Dijkstra’s algorithm.
506 LeetCode 506: Relative Ranks Easy A clear explanation of assigning athlete ranks from scores using sorting while preserving original indices.
507 LeetCode 507: Perfect Number Easy A clear explanation of checking whether a number equals the sum of its positive divisors excluding itself.
508 LeetCode 508: Most Frequent Subtree Sum Medium A clear explanation of finding the most frequent subtree sum in a binary tree using postorder DFS and a frequency map.
509 LeetCode 509: Fibonacci Number Easy A clear explanation of computing Fibonacci numbers using dynamic programming and iterative state transitions.
510 LeetCode 510: Inorder Successor in BST II Medium A clear explanation of finding the inorder successor in a binary search tree when nodes contain parent pointers.
511 LeetCode 511: Game Play Analysis I Easy A clear explanation of finding each player's first login date using SQL aggregation.
512 LeetCode 512: Game Play Analysis II Easy A clear explanation of finding the first device used by each player using SQL aggregation and a join.
513 LeetCode 513: Find Bottom Left Tree Value Medium A clear explanation of finding the leftmost value in the deepest row of a binary tree using level-order traversal.
514 LeetCode 514: Freedom Trail Hard A clear explanation of finding the minimum steps to spell a key on a circular ring using dynamic programming and memoized DFS.
515 LeetCode 515: Find Largest Value in Each Tree Row Medium A clear explanation of finding the maximum value at every depth of a binary tree using level-order traversal.
516 LeetCode 516: Longest Palindromic Subsequence Medium A clear explanation of finding the length of the longest palindromic subsequence using interval dynamic programming.
517 LeetCode 517: Super Washing Machines Hard A clear explanation of balancing dresses across washing machines using greedy prefix flow.
518 LeetCode 518: Coin Change II Medium A clear explanation of counting coin-change combinations using dynamic programming.
519 LeetCode 519: Random Flip Matrix Medium A clear explanation of randomly flipping zero cells in a matrix without repetition using hash mapping and virtual swapping.
520 LeetCode 520: Detect Capital Easy A clear explanation of checking whether a word uses capital letters correctly by counting uppercase letters.
521 LeetCode 521: Longest Uncommon Subsequence I Easy A clear explanation of finding the longest uncommon subsequence between two strings using simple case analysis.
522 LeetCode 522: Longest Uncommon Subsequence II Medium A clear explanation of finding the longest uncommon subsequence among many strings using subsequence checks.
523 LeetCode 523: Continuous Subarray Sum Medium A clear explanation of detecting a subarray whose sum is a multiple of k using prefix sums and modular arithmetic.
524 LeetCode 524: Longest Word in Dictionary through Deleting Medium A clear explanation of finding the longest dictionary word obtainable as a subsequence using two pointers and sorting rules.
525 LeetCode 525: Contiguous Array Medium A clear explanation of finding the longest contiguous subarray with equal numbers of 0 and 1 using prefix sums and a hash map.
526 LeetCode 526: Beautiful Arrangement Medium A clear explanation of counting beautiful arrangements using backtracking and divisibility pruning.
527 LeetCode 527: Word Abbreviation Hard A clear explanation of generating minimal unique word abbreviations using grouping and trie prefixes.
528 LeetCode 528: Random Pick with Weight Medium A clear explanation of weighted random sampling using prefix sums and binary search.
529 LeetCode 529: Minesweeper Medium A clear explanation of updating a Minesweeper board using DFS flood fill and adjacent mine counting.
530 LeetCode 530: Minimum Absolute Difference in BST Easy A clear explanation of finding the minimum difference between two BST node values using inorder traversal.
531 LeetCode 531: Lonely Pixel I Medium A clear explanation of counting black pixels that are alone in both their row and column.
532 LeetCode 532: K-diff Pairs in an Array Medium A clear explanation of counting unique pairs whose absolute difference is k using frequency counting.
533 LeetCode 533: Lonely Pixel II Medium A clear explanation of counting black lonely pixels using row counts, column counts, and duplicate row patterns.
534 LeetCode 534: Game Play Analysis III Medium A clear explanation of computing cumulative games played per player and date using SQL window functions.
535 LeetCode 535: Encode and Decode TinyURL Medium A clear explanation of designing a simple URL encoder and decoder using a hash map and generated keys.
536 LeetCode 536: Construct Binary Tree from String Medium A clear explanation of parsing a parenthesized string recursively to construct a binary tree.
537 LeetCode 537: Complex Number Multiplication Medium A clear explanation of multiplying complex numbers represented as strings using algebraic expansion.
538 LeetCode 538: Convert BST to Greater Tree Medium A clear explanation of converting a BST into a greater tree using reverse inorder traversal and a running sum.
539 LeetCode 539: Minimum Time Difference Medium A clear explanation of finding the minimum difference between 24-hour clock times using minute conversion and sorting.
540 LeetCode 540: Single Element in a Sorted Array Medium A clear explanation of finding the only non-duplicate element in a sorted array using binary search.
541 LeetCode 541: Reverse String II Easy A clear explanation of reversing the first k characters in every 2k block of a string.
542 LeetCode 542: 01 Matrix Medium A clear explanation of computing the distance to the nearest zero in a binary matrix using multi-source BFS.
543 LeetCode 543: Diameter of Binary Tree Easy A clear explanation of finding the longest path between any two nodes in a binary tree using DFS height computation.
544 LeetCode 544: Output Contest Matches Medium A clear explanation of building the final tournament bracket by repeatedly pairing strongest and weakest teams.
545 LeetCode 545: Boundary of Binary Tree Medium A clear explanation of collecting the boundary of a binary tree using separate left boundary, leaves, and right boundary traversals.
546 LeetCode 546: Remove Boxes Hard A clear explanation of maximizing remove-box scores using interval dynamic programming with memoization.
547 LeetCode 547: Number of Provinces Medium A clear explanation of counting connected components in an undirected graph represented by an adjacency matrix.
548 LeetCode 548: Split Array with Equal Sum Hard A clear explanation of splitting an array into four equal-sum parts using prefix sums and set-based search.
549 LeetCode 549: Binary Tree Longest Consecutive Sequence II Medium A clear explanation of finding the longest increasing or decreasing consecutive path in a binary tree using DFS.
550 LeetCode 550: Game Play Analysis IV Medium A clear explanation of calculating the fraction of players who logged in again the day after their first login.
551 LeetCode 551: Student Attendance Record I Easy A clear explanation of Student Attendance Record I using simple string checks and a one-pass counter solution.
552 LeetCode 552: Student Attendance Record II Hard A clear explanation of Student Attendance Record II using dynamic programming over absence count and late streak.
553 LeetCode 553: Optimal Division Medium A clear explanation of Optimal Division using the structure of division expressions to build the maximum-value expression.
554 LeetCode 554: Brick Wall Medium A clear explanation of Brick Wall using prefix sums and a hash map to find the best vertical cut position.
555 LeetCode 555: Split Concatenated Strings Medium A clear explanation of Split Concatenated Strings using string reversal choices and enumeration of every possible cut point.
556 LeetCode 556: Next Greater Element III Medium A clear explanation of Next Greater Element III using the next permutation algorithm on the digits of an integer.
557 LeetCode 557: Reverse Words in a String III Easy A clear explanation of Reverse Words in a String III using two-pointer scanning and string reversal.
558 LeetCode 558: Logical OR of Two Binary Grids Represented as Quad-Trees Medium A clear explanation of merging two quad-trees using recursive logical OR operations.
559 LeetCode 559: Maximum Depth of N-ary Tree Easy A clear explanation of Maximum Depth of N-ary Tree using recursive depth-first search.
560 LeetCode 560: Subarray Sum Equals K Medium A clear explanation of Subarray Sum Equals K using prefix sums and a hash map to count matching subarrays in linear time.
561 LeetCode 561: Array Partition Easy A clear explanation of Array Partition using sorting and adjacent pairing to maximize the sum of pair minimums.
562 LeetCode 562: Longest Line of Consecutive One in Matrix Medium A clear explanation of Longest Line of Consecutive One in Matrix using dynamic programming over four directions.
563 LeetCode 563: Binary Tree Tilt Easy A clear explanation of Binary Tree Tilt using postorder DFS to compute subtree sums and accumulate tilt.
564 LeetCode 564: Find the Closest Palindrome Hard A clear explanation of Find the Closest Palindrome using prefix mirroring and a small candidate set.
565 LeetCode 565: Array Nesting Medium A clear explanation of Array Nesting using cycle detection over a permutation.
566 LeetCode 566: Reshape the Matrix Easy A clear explanation of Reshape the Matrix using index mapping from the original matrix to the reshaped matrix.
567 LeetCode 567: Permutation in String Medium A clear explanation of Permutation in String using a fixed-size sliding window and character frequency counts.
568 LeetCode 568: Maximum Vacation Days Hard A clear explanation of Maximum Vacation Days using dynamic programming over weeks and cities.
569 LeetCode 569: Median Employee Salary Hard A clear explanation of Median Employee Salary using SQL window functions to rank employees inside each company.
570 LeetCode 570: Managers with at Least 5 Direct Reports Medium A clear explanation of Managers with at Least 5 Direct Reports using grouping and a self join.
571 LeetCode 571: Find Median Given Frequency of Numbers Hard A clear explanation of Find Median Given Frequency of Numbers using cumulative frequency and SQL window functions.
572 LeetCode 572: Subtree of Another Tree Easy A clear explanation of Subtree of Another Tree using recursive tree matching and DFS.
573 LeetCode 573: Squirrel Simulation Medium A clear explanation of Squirrel Simulation using Manhattan distance and the special first trip.
574 LeetCode 574: Winning Candidate Medium A clear explanation of Winning Candidate using SQL aggregation to count votes and return the candidate with the most votes.
575 LeetCode 575: Distribute Candies Easy A clear explanation of Distribute Candies using a set to count candy types and a simple limit argument.
576 LeetCode 576: Out of Boundary Paths Medium A clear dynamic programming solution for counting paths that move a ball out of a grid boundary.
577 LeetCode 577: Employee Bonus Easy A clear SQL guide for finding employees whose bonus is less than 1000 or missing.
578 LeetCode 578: Get Highest Answer Rate Question Medium A clear SQL guide for finding the question with the highest answer rate from survey logs.
579 LeetCode 579: Find Cumulative Salary of an Employee Hard A clear SQL guide for computing each employee's 3-month cumulative salary while excluding their most recent month.
580 LeetCode 580: Count Student Number in Departments Medium A clear SQL guide for counting students in every department, including departments with zero students.
581 LeetCode 581: Shortest Unsorted Continuous Subarray Medium A clear linear-time solution for finding the shortest subarray that must be sorted to make the whole array sorted.
582 LeetCode 582: Kill Process Medium A clear graph traversal solution for finding all processes terminated when killing a target process.
583 LeetCode 583: Delete Operation for Two Strings Medium A clear dynamic programming solution for finding the minimum deletions needed to make two strings equal.
584 LeetCode 584: Find Customer Referee Easy A clear SQL guide for selecting customers who were not referred by customer 2, including customers with no referee.
585 LeetCode 585: Investments in 2016 Medium A clear SQL guide for summing 2016 investments for policies with repeated 2015 investment values and unique locations.
586 LeetCode 586: Customer Placing the Largest Number of Orders Easy A clear SQL guide for finding the customer who placed the most orders.
587 LeetCode 587: Erect the Fence Hard A clear convex hull solution for returning all trees that lie on the fence boundary.
588 LeetCode 588: Design In-Memory File System Hard A clear design guide for implementing an in-memory file system with directory listing, directory creation, file append, and file read operations.
589 LeetCode 589: N-ary Tree Preorder Traversal Easy A clear DFS solution for returning the preorder traversal of an N-ary tree.
590 LeetCode 590: N-ary Tree Postorder Traversal Easy A clear DFS solution for returning the postorder traversal of an N-ary tree.
591 LeetCode 591: Tag Validator Hard A clear stack-based parser for validating nested XML-like tags with CDATA sections.
592 LeetCode 592: Fraction Addition and Subtraction Medium A clear parsing and math solution for evaluating fraction addition and subtraction expressions.
593 LeetCode 593: Valid Square Medium A clear geometry solution for checking whether four unordered points form a valid square.
594 LeetCode 594: Longest Harmonious Subsequence Easy A clear hash map solution for finding the longest subsequence whose maximum and minimum differ by exactly one.
595 LeetCode 595: Big Countries Easy A clear SQL guide for finding countries with either large area or large population.
596 LeetCode 596: Classes With at Least 5 Students Easy A clear SQL guide for finding classes that have at least five students.
597 LeetCode 597: Friend Requests I: Overall Acceptance Rate Easy A clear SQL guide for computing the overall friend request acceptance rate with duplicate pairs counted once.
598 LeetCode 598: Range Addition II Easy A clear math solution for counting the maximum values after repeated top-left matrix increment operations.
599 LeetCode 599: Minimum Index Sum of Two Lists Easy A clear hash map solution for finding common strings with the smallest index sum.