Minimum Path Sum
Find the minimum path sum from top-left to bottom-right in a grid.
Input: grid = [[1,2,3],[4,5,6]]
Output: 12
Explanation: The optimal path moves along 1 -> 2 -> 3 -> 6, resulting in a minimum accumulated sum of 12.
Clone an Undirected Graph
Clone an undirected graph.
Input: adjList = [[]]
Output: [[]]
Explanation: Creates a new, deeply cloned graph containing only one single node with zero connected neighbors.
Iterator over a Binary Search Tree
Implement an iterator over a binary search tree.
Input: root = [7,3,15,null,null,9,20], calls: next(), hasNext(), next()
Output: 3, TRUE, 7
Explanation: The iterator yields the smallest value (3), confirms more nodes exist, then properly yields the next in-order value (7).
Sort a String by Frequency
Sort a string by the frequency of its characters.
Input: s = "cccaaa"
Output: "cccaaa" or "aaaccc"
Explanation: Both 'c' and 'a' appear three times, so sorting them by descending frequency keeps them grouped equally.
Dot Product of Two Sparse Vectors
Calculate the dot product of two sparse vectors.
Input: nums1 = [0,1,0,0,2], nums2 = [0,0,0,0,5]
Output: 10
Explanation: Multiplies the aligned non-zero values (2 * 5) and ignores all the zeros, yielding a dot product of 10.
Find the node with the highest edge score in a directed graph.
You are given a directed graph. Calculate the edge score of each node, which is the sum of the labels of all nodes that have an edge pointing to it. Return the node with the highest edge score.
Input: edges = [1,0,1,1,1]
Output: 1
Explanation: Node 1 receives incoming edge…
Continuous Subarrays Sum Equals K
Find the total number of continuous subarrays whose sum equals K.
Input: nums = [1,2,3], k = 3
Output: 2
Explanation: Both the contiguous subarray [1,2] and the single-element subarray [3] sum perfectly to the target of 3.