Solve three classic coding problems
Company: TikTok
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Onsite
Quick Answer: 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.
Longest Increasing Subsequence Length
Constraints
- Inputs are provided as Python literals matching the function signature.
- Return a deterministic exact-match result.
Examples
Input: ([10,9,2,5,3,7,101,18],)
Expected Output: 4
Explanation: Classic example.
Input: ([7,7,7],)
Expected Output: 1
Explanation: Strictly increasing rejects equals.
Input: ([],)
Expected Output: 0
Explanation: Empty array.
Hints
- Choose a representation that makes the core operation simple.
- Handle empty and boundary inputs before the main algorithm.
K-th Largest in Two Sorted Arrays
Constraints
- Inputs are provided as Python literals matching the function signature.
- Return a deterministic exact-match result.
Examples
Input: ([1,3,5], [2,4,6], 2)
Expected Output: 5
Explanation: Second largest.
Input: ([1,2,2], [2,3], 3)
Expected Output: 2
Explanation: Duplicates count.
Input: ([], [5], 1)
Expected Output: 5
Explanation: One empty array.
Hints
- Choose a representation that makes the core operation simple.
- Handle empty and boundary inputs before the main algorithm.
Serialize Next Pointers by Level
Constraints
- Inputs are provided as Python literals matching the function signature.
- Return a deterministic exact-match result.
Examples
Input: ([1,2,3,4,5,6,7],)
Expected Output: [[[1, None]], [[2, 3], [3, None]], [[4, 5], [5, 6], [6, 7], [7, None]]]
Explanation: Three-level perfect tree.
Input: ([1],)
Expected Output: [[[1, None]]]
Explanation: Single node.
Hints
- Choose a representation that makes the core operation simple.
- Handle empty and boundary inputs before the main algorithm.
Number of Islands
Constraints
- Inputs are provided as Python literals matching the function signature.
- Return a deterministic exact-match result.
Examples
Input: ([['1','1','0'], ['0','1','0'], ['1','0','1']],)
Expected Output: 3
Explanation: Three islands.
Input: ([],)
Expected Output: 0
Explanation: Empty grid.
Hints
- Choose a representation that makes the core operation simple.
- Handle empty and boundary inputs before the main algorithm.