Solve string merge and grid path tasks
Company: Capital One
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Online Assessment
Overview: This multi-part question evaluates string manipulation and sequence merging, stateful shortest-path planning under resource constraints (health-aware grid pathfinding), and sliding-window optimization for arrays/strings within the Coding & Algorithms domain.
Constraints
- 0 <= n <= 200000, where n = len(s1) = len(s2)
- s1 and s2 must have equal length
- Characters may be any printable ASCII
- Aim for O(n) time and O(n) extra space
Examples
Input:
Expected Output: afbecd
Input:
Expected Output: aabdpj
Hints
- Use j = n - 1 - i to index s2 from the end while scanning s1 from the start.
- Build the result with a list of characters and join at the end for efficiency.
- Handle the empty-string case (n = 0) by returning an empty string.