0500 - 0599
Solutions categorised by Problem IDs
501 - Find Mode in Binary Search TreeFind the most frequent values in a binary search tree by traversing its nodes and tracking occurrence counts.508 - Most Frequent Subtree SumCompute subtree sums from the leaves upward and count their frequencies to identify the most common sums.518 - Coin Change 2Count ways to make an amount with unlimited coins by processing denominations one at a time in dynamic programming.520 - Detect CapitalCheck whether a word uses capitals consistently by distinguishing uppercase, lowercase, and initial-capital patterns.523 - Continuous Subarray SumDetect a subarray of at least two values whose sum is a multiple of k by comparing prefix-sum remainders.525 - Contiguous ArrayFind the longest subarray with equal numbers of zeroes and ones by tracking where each prefix balance first occurs.532 - K-diff Pairs in an ArrayCount distinct pairs with a given difference using a frequency map that also handles a difference of zero.540 - Single Element in a Sorted ArrayFind the only unpaired value in a sorted array by binary searching for the point where adjacent pair alignment changes.542 - 01 MatrixCompute each cell's distance to the nearest zero with breadth-first traversal of the binary matrix.543 - Diameter of Binary TreeFind a binary tree's diameter by combining left and right subtree heights at every possible turning point.557 - Reverse Words in a String IIIReverse the characters within each word while keeping word order intact, using splitting or two pointers.559 - Maximum Depth of N-ary TreeFind the maximum depth of an N-ary tree by exploring its children and taking the deepest root-to-leaf path.560 - Subarray Sum Equals KCount subarrays that sum to k by looking up how often the required earlier prefix sum has occurred.567 - Permutation in StringDetect a permutation of one string inside another by tracking character frequencies in a fixed-length window.572 - Subtree of Another TreeCheck whether a tree contains a given subtree by comparing structure and values at candidate starting nodes.581 - Shortest Unsorted Continuous SubarrayFind the shortest segment that needs sorting by comparing the array with its sorted order.589 - N-ary Tree Preorder TraversalProduce the preorder traversal of an N-ary tree by visiting each node before its children from left to right.