FastPrepResumable List Iterator
Problems/Resumable List Iterator

Resumable List Iterator

xAI logoxAI● MediumFULLTIMEPHONE SCREEN

Updated Sep 2026

QuestionFunctionExamples

Problem statement

Source note: The interview report identifies a resumable-state iterator but does not reproduce its API or tests. This practice version uses an existing FastPrep resumable-list-iterator contract: save opaque state before iteration and after every consumed value, restore a fresh iterator from each state, and return the remaining suffixes.

Design a finite iterator over an integer array whose progress can be saved and restored.

Iterator Behavior

  • Return the next value and signal exhaustion after the final value.
  • getState() returns a serializable, opaque state representing the current position.
  • setState(state) restores the iterator so that subsequent values are exactly the values that remained when the state was saved.

A caller must not assume that a state is an array index. A saved state must continue to work after the original iterator has advanced or become exhausted.

State Restoration

Save the iterator state before reading the first value and after every returned value, including the exhausted position. Restore a fresh iterator from each saved state, read it to exhaustion, and return all resulting suffixes in save order.

Row i of the returned int[][] contains all values returned after restoring the state saved after exactly i values had been consumed. The final row is empty because it represents the exhausted state.

Function

resumeSuffixes(values: int[]) → int[][]

Examples

Example 1

values = [4, 7, 9]return = [[4, 7, 9], [7, 9], [9], []]

The saved states represent the positions before 4, before 7, before 9, and after the iterator is exhausted. Restoring each state produces the corresponding suffix.

More xAI interview questions

  • Earliest Dataset Readiness in a PipelinePHONE SCREEN · Seen Mar 2026
  • Most Common N-GramsPHONE SCREEN · Seen Mar 2025
  • Double-Base PalindromesPHONE SCREEN · Seen Oct 2024
  • Live Top-K Spaces by Active UsersONSITE INTERVIEW · Seen Jan 2026
  • Total Active Time by SpaceONSITE INTERVIEW · Seen Jan 2026
  • Dynamic Batch Decode TraceONSITE INTERVIEW · Seen Dec 2025
  • Nested Transaction Key-Value StoreONSITE INTERVIEW · Seen Oct 2025
  • Weighted LRU CacheONSITE INTERVIEW · Seen Oct 2025
  • LFU CacheONSITE INTERVIEW · Seen Sep 2025
  • Cached Lazy Token BucketsONSITE INTERVIEW · Seen Sep 2025

Similar questions at other companies

  • 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
  • Portfolio Tickers with Constant-Time Random PickCitadel · PHONE SCREENCitadel interview questions
  • Design Browser HistoryBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Count Events in Rolling Minute WindowsMeta · PHONE SCREENMeta interview questions
  • Build a Pivot Table with TotalsSigma Computing · PHONE SCREEN
  • Process On-Call Routing OperationsOpenAI · PHONE SCREENOpenAI interview questions
  • Implement a FIFO QueueByteDance · PHONE SCREENByteDance interview questions

xAI interview experiences

  • xAI New Grad AI Coding Interview and Take-Home: 3 Experiences
All xAI interview questionsSee xAI hiring insights
Saved
class Solution {
    public int[][] resumeSuffixes(int[] values) {
      // write your code here
    }

}
Checking account…