FastPrepZigzag Iterator Over Two Lists
Problems/Zigzag Iterator Over Two Lists

Zigzag Iterator Over Two Lists

Google logoGoogle● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The firsthand new-grad report from Google names the Zigzag Iterator problem and says only the story was changed, to flower planting. Here the function returns the whole sequence as a batch, in the same alternating order. Our version is about 94% the same as the reported question.

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

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int[] zigzagIterate(int[] first, int[] second) {
        // Write your code here.
    }
}
Checking account…