Find the longest increasing path in a matrix.
Given an m x n integers matrix, return the length of the longest strictly increasing path in the matrix. From each cell, you can either move in four directions: left, right, up, or down.
Input: matrix = [[1,2],[3,4]]
Output: 3
Explanation: The longest strictly increasing path is 1 -> 3 ->…
Break a string into space-separated words using a dictionary.
Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words.
Input: s = "catsandog", wordDict = ["cats", "dog", "sand", "and", "cat"]
Output: FALSE
Explanation: There is no valid se…
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).
Decode Ways
Determine the number of valid ways to decode a string of digits.
Input: s = "10"
Output: 1
Explanation: The string can only be decoded one single way, as the sequence '10' maps exclusively to the letter 'J'.
Find the K closest points to the origin.
Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0).
Input: points = [[3,3],[5,-1],[-2,4]], k = 2
Output: [[3,3], [-2,4]]
Explanation: The squared distances are 18, 26, and 20 respectively. Th…