Find the shortest distance from all buildings to an empty land in a grid.
You are given a grid of values 0, 1, or 2, where 0 is empty land, 1 is a building, and 2 is an obstacle. Find the shortest travel distance from all buildings to an empty land spot.
Input: grid = [[1,0],[0,1]]
Output: 2
Explanation: The empty lands are at (0,1) a…
Vertical Order Traversal
Perform a vertical order traversal of a binary tree.
Input: root = [1,2,3,4,5,6,7]
Output: [[4],[2],[1,5,6],[3],[7]]
Explanation: Traverses the tree maintaining column indices, seamlessly grouping nodes that share the exact same vertical alignment.
Palindrome After Deleting One Character
Determine if a string can be a palindrome after deleting at most one character.
Input: s = "abc"
Output: FALSE
Explanation: Deleting any single character leaves either "ab", "bc", or "ac", none of which result in a valid palindrome.
Find the median from a continuous data stream.
Implement a data structure that allows you to add integers from a continuous data stream and find the median of all elements so far efficiently.
Input: addNum(2), addNum(3), findMedian(), addNum(4), findMedian()
Output: 2.5 then 3.0
Explanation: After adding 2 and 3, the median is 2.5. Af…
Minimum Window Substring
Find the minimum window substring that contains all characters of another string.
Input: s = "a", t = "aa"
Output: "" (Empty String)
Explanation: The target requires two 'a's, but the source string only contains one, making it impossible to form a valid window.
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.