Split Array into Consecutive Subsequences
Split an array into consecutive subsequences.
Input: nums = [1,2,3,4,4,5]
Output: FALSE
Explanation: The numbers can form [1,2,3,4], but the remaining leftover group [4,5] is too short to form a valid sequence of length 3.
Serialize and Deserialize N-ary Tree
Serialize and deserialize an N-ary tree.
Input: root = [1]
Output: 1
Explanation: The tree only contains a root node, resulting in a minimal serialized string representation that can be accurately rebuilt.
Two Sum
You're presented with an array of integers and a specific target value. Your task is to identify and return the indices of two numbers from the array that add up to the target. You can assume there's exactly one solution, and you can't use the same element twice. The indices can be returned in any order.
Input: nums = [14,8,22,6…
Find the lowest common ancestor of a binary tree.
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. The LCA is defined between two nodes p and q as the lowest node in the tree that has both p and q as descendants.
Input: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 4
Output: 5
Explanation:…
Longest Substring with Two Distinct Characters
Find the longest substring with at most two distinct characters.
Input: s = "ccaabbb"
Output: 5
Explanation: The substring "aabbb" contains exactly two distinct characters and has a maximum length of 5.