FastPrepImplement an Iterator Next Method
Problems/Implement an Iterator Next Method

Implement an Iterator Next Method

NVIDIA logoNVIDIA● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The NVIDIA AV Perception phone screen, for a new grad role, asks for a Python iterator class with __next__. It does not say what it iterates over. Here it walks a finite integer sequence, and running out is shown as a STOP result, so the stateful behavior can be checked in four languages.

Our version is about 65% the same as the reported question.

Implement an iterator over the supplied integer sequence. The iterator stores its current position. Every call to its next method returns the next value in the original order and advances by one. Once no values remain, it is exhausted and every later next call must continue to signal exhaustion.

For this exercise, initialize one iterator from values and make exactly nextCalls calls to it. Return one string per call: the yielded integer in decimal form, or STOP when that call finds the iterator exhausted. In Python, the iterator method should use the standard StopIteration exception, which the judge converts to STOP; other languages should expose the same observable sequence.

Keep repeated values as separate iterator items. The input sequence is not modified.

Function

iterateNextCalls(values: int[], nextCalls: int) → String[]

Examples

Example 1

values = [4,-2,4]nextCalls = 5return = ["4","-2","4","STOP","STOP"]

The first three calls consume the three values. Both later calls observe the same exhausted state.

Example 2

values = []nextCalls = 2return = ["STOP","STOP"]

An empty sequence is exhausted before the first call and remains exhausted.

Example 3

values = [0,9]nextCalls = 1return = ["0"]

The single call consumes only the first value; there is no request to exhaust the iterator.

Constraints

  • 0 <= values.length <= 100000
  • -10^9 <= values[i] <= 10^9
  • 0 <= nextCalls <= 100000

More NVIDIA Phone Screen questions

  • Network Layer Execution OrderPHONE SCREEN · Seen Nov 2026
  • Paged KV Cache AccessPHONE SCREEN · Seen Nov 2026
  • Sliding Window Attention over a KV CachePHONE SCREEN · Seen Nov 2026
  • Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
  • Hash Partition OffsetsPHONE SCREEN · Seen Oct 2026
  • Filter Paginated Medical RecordsPHONE SCREEN · Seen Oct 2026
  • Least Frequently Used CachePHONE SCREEN · Seen Oct 2026
  • Parallel String Counts with a Custom Hash TablePHONE SCREEN · Seen Oct 2026
  • Simulate a Reference-Counted Smart PointerPHONE SCREEN · Seen Aug 2026
  • Streaming Top-K Frequent ElementsPHONE SCREEN · Seen Aug 2026

Similar questions at other companies

  • Logger Rate LimiterGoogle · PHONE SCREENGoogle interview questions
  • Lazy Filter over a GeneratorSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Track New Values in Sorted OrderBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Array-Backed Set Without Library CollectionsOde with Anthropic · PHONE SCREEN
  • Stepped IteratorBridge · PHONE SCREENBridge interview questions
  • Implement a VectorCitadel · PHONE SCREENCitadel interview questions
  • Customer Bootstrap APIDoorDash · PHONE SCREEN · ONSITE INTERVIEWDoorDash interview questions
  • Design Hit CounterCharta Health · PHONE SCREENCharta Health interview questions
  • Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
  • Billing Log with Undo and RedoReddit · PHONE SCREENReddit interview questions

NVIDIA interview experiences

  • NVIDIA Full-Time SWE Onsite Scheduling: 1 Experience
  • NVIDIA OA: What It Tests (2026)
  • NVIDIA DevOps, QA and Infra Intern Interviews: 12 Experiences
  • NVIDIA Ignite Internship OA Experience
  • NVIDIA Software Intern Interview Questions: 9 Experiences
  • NVIDIA Ignite SWE Intern OA Questions: 6 Experiences
All NVIDIA interview questionsSee NVIDIA hiring insights
Saved
class Solution {
    public String[] iterateNextCalls(int[] values, int nextCalls) {
        // Write your solution here
    }
}
Checking account…