Zigzag Iterator Over Two Lists
Updated
Problem statement
Given two integer arrays first and second, return their values in zigzag order.
Take one value from first, then one from second, and continue alternating. When one array is exhausted, append all remaining values from the other array in their original order.
Function
zigzagIterate(first: int[], second: int[]) → int[]Examples
Example 1
first = [1,2]second = [3,4,5,6]return = [1,3,2,4,5,6]The arrays alternate until first is exhausted, then the remaining values from second follow.
Example 2
first = []second = [7,8]return = [7,8]An empty first array is skipped.
Example 3
first = [1,2,3]second = []return = [1,2,3]An empty second array is skipped.
Constraints
0 <= first.length, second.length <= 100000.first.length + second.length >= 1.- Every value is a signed 32-bit integer.
More Google Phone Screen questions
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
- Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Design Hit CounterCharta Health · PHONE SCREENCharta Health interview questions
- Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
- Implement a FIFO QueueByteDance · PHONE SCREENByteDance interview questions
- Stateful Paginated Fetch NLyft · PHONE SCREENLyft interview questions
- Music Player Operation SequenceAtlassian · PHONE SCREENAtlassian interview questions
- Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
- Queue on a VectorCitadel · PHONE SCREENCitadel interview questions
- Implement a FIFO QueueOptiver · PHONE SCREENOptiver interview questions
- Bounded Circular QueueDatadog · PHONE SCREENDatadog interview questions
- Moving Average of a Data StreamSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions