# Iterator class and continuous iterator with global index — coding interview question

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/questions/5859/implement-list-iterator
Source observed: 2026-11-05T00:16:40.585Z
Last checked: 2026-11-05T00:16:40.585+00:00
Indexed: 2026-11-06T23:08:49.515+00:00

---

# Iterator class and continuous iterator with global index

We use this coding interview question to practice designing an iterator class with state control and extending it across multiple iterators.

## Question

Implement an iterator class that supports:

- `next`
- `hasNext`
- `getState`
- `setState`

Then extend it so a list of iterators behaves as one continuous iterator with a global index.

## Question details

- **Category:** [Coding](https://www.aced.io/questions?type=coding)
- **Roles:** [Software Engineer](https://www.aced.io/questions?role=swe), [AI Engineer](https://www.aced.io/questions?role=ai-engineer)
- **Company association:** [xAI](https://www.aced.io/questions?company=x-ai)
- **Reported activity:** 3 interviews; last asked 5 months ago
- **Community answers:** No answers contributed by the community yet.

Detailed company statistics for this question are available through [Upgrade](https://www.aced.io/upgrade?src=questions).

## Interview experiences

One interview experience is shared for this question:

### [xAI · a year ago](https://www.aced.io/experiences/x-ai-senior-software-engineer-interview-3c2a0d)

**Role:** Software Engineer · Senior / L5

> “I originally applied to a different xAI role, and an engineer on that team redirected me to the Senior Safety role after a quick intro call. From there I did a hiring manager screen, a practical technical phone screen, and then an onsite in Palo Alto with one coding round and one hybrid coding/system design round, plus a short follow-up call after. The actual questions were much more practical class-design problems than LeetCode, which matched a broader trend I was seeing, but xAI gave almost no useful prep and the process felt pretty ad hoc. The onsite was easily my least favorite one because the whole thing started with armed guards, bag checks, and escorting me around the building, and then one interviewer spent a bunch of the coding round on his phone. I got rejected afterward with a vague note about a shift in prioritization of open roles, so I still do not know whether the role actually changed or if that was just their way of saying no.”

## Related courses

### [AI Engineering Interview Prep](https://www.aced.io/courses/ai-engineering)

![AI Engineering Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/25mhKSvDOiCwC89lDj89Ah/9a5fbfacc8d93f05c238ab55baa4e5e5/fde.png?w=800&h=800&fm=webp&q=75)

Prepare for AI engineering interviews at companies such as Google, Anthropic, Meta, and OpenAI. We cover detailed frameworks, example questions, mock interviews with senior engineers, system design, AI/ML concepts, AI-assisted coding, and behavioral rounds.

### [Generative AI Interviews](https://www.aced.io/courses/gen-ai-interviews)

![Generative AI Interviews](https://images.ctfassets.net/x78yjrjc11pq/BLBU7an1PjT0Mt2ZzAfDa/60e119c8bff0cfb8281dcb497177f6e3/AdobeStock_1510292201-min.jpeg?w=800&h=800&fm=webp&q=75)

Prepare for interviews at AI-first and AI-powered companies. We teach how generative AI works, where it fails, and how to use it responsibly, alongside how technology companies build and deploy AI products in production, including LLMs and RAG systems.

## Your answer

Submitting an answer marks this question complete. You must [log in](https://www.aced.io/login?src=nav) or [sign up](https://www.aced.io/signup?src=nav&returnPath=/questions/5859/implement-list-iterator) to answer.

## Explore Aced

We provide interview preparation through courses, interview questions, practice, and coaching. Available course areas include Product Management, Forward Deployed Engineering, Engineering Management, Software Engineering, System Design, Data Science, Machine Learning, Data Engineering, AI Engineering, Investment Banking, Generative AI, Security Engineer, TPM, Solutions Architect, UX / Product Design, and BizOps & Strategy.

- [All questions](https://www.aced.io/questions)
- [Courses](https://www.aced.io/courses?src=nav)
- [Practice](https://www.aced.io/practice?src=nav)
- [Experiences](https://www.aced.io/experiences?src=nav)
- [Coaching](https://www.aced.io/coaching?src=nav)
- [Pricing](https://www.aced.io/upgrade?src=nav)

We are Aced, formerly Exponent: [Aced home](https://www.aced.io/?src=nav).

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F5859%2Fimplement-list-iterator&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F5859%2Fimplement-list-iterator). Opening a form does not execute a tool.