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.
Determine if a Sudoku board is valid.
Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to standard Sudoku rules: each row, column, and 3x3 sub-box must contain the digits 1-9 without repetition.
Input: board = 9x9 grid where the first row contains 7 twice
Output: FALSE
Explanation: A val…
Longest Consecutive Sequence
Determine the length of the longest consecutive elements sequence.
Input: nums = [0,3,7,2,5,8,4,6,0,1]
Output: 9
Explanation: The longest consecutive sequence is 0 through 8 (length 9), utilizing a hash set to check connectivity in linear time.