These tasks evaluate algorithmic problem-solving, data structure mastery, and implementation skills within the Coding & Algorithms domain, touching on dynamic programming (longest increasing subsequence), order-statistics in sorted arrays, tree pointer manipulation for perfect binary trees, and graph traversal for connected components.
You are given three independent coding tasks. Implement a function for each.
Given an integer array nums, return the length of the longest strictly increasing subsequence.
nums
(array of integers)
1 <= n <= 2e5
(or smaller), values fit in 32-bit signed int
Given two arrays A and B, each sorted in non-decreasing order, and an integer k (1-indexed), return the k-th largest element in the multiset union of A and B.
A
,
B
(sorted arrays),
k
0 <= len(A), len(B) <= 2e5
,
1 <= k <= len(A)+len(B)
Given a perfect binary tree (all internal nodes have exactly two children and all leaves are at the same depth), populate each node’s next pointer so it points to its immediate neighbor to the right on the same level. If there is no neighbor, set next = null.
left
,
right
,
next
O(1)
extra space (excluding recursion stack)
Given an m x n grid of characters containing '1' (land) and '0' (water), return the number of connected components of land. Cells are connected 4-directionally (up/down/left/right).
grid
(2D array of
'0'
/
'1'
)
1 <= m,n <= 200
(or similar)