PracHub
QuestionsPremiumLearningGuidesCheatsheetNEW
|Home/Coding & Algorithms/Snapchat

Implement a custom list with iterator and map

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in data structures and generic collection implementation, specifically list operations, iterator semantics, and higher-order map functions.

  • medium
  • Snapchat
  • Coding & Algorithms
  • Software Engineer

Implement a custom list with iterator and map

Company: Snapchat

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are asked to implement a simple generic list type **without using any built-in collection classes** (e.g., no `ArrayList`, `LinkedList`, `Vector`, etc.). You may use primitive arrays / custom nodes. ### Part 1 — Implement a List Design and implement `MyList<T>` with at least the following operations: - `void add(T value)` - `T get(int index)` - `void set(int index, T value)` (or return a new value) - `T remove(int index)` - `int size()` Requirements: - Handle invalid indices (define behavior: throw an exception or return a sentinel). - Aim for reasonable time complexity (state your choice of underlying structure: dynamic array or linked list). ### Part 2 — Implement an Iterator Extend `MyList<T>` so it is iterable. - Implement an iterator type with standard iterator methods (e.g., `hasNext()` and `next()`; optionally `remove()` if you support it). - The iterator should traverse the list from index `0` to `size()-1`. ### Part 3 — Implement a map function Add a `map`-style higher-order function: - `MyList<R> map(Function<T, R> f)` (or equivalent in your language) It should: - Apply `f` to each element in order - Return a **new** `MyList<R>` containing the mapped results - Not modify the original list ### Clarifications - Assume single-threaded use. - You may assume elements can be `null` unless you choose to forbid it (but document your choice).

Quick Answer: This question evaluates proficiency in data structures and generic collection implementation, specifically list operations, iterator semantics, and higher-order map functions.

Related Interview Questions

  • Determine Whether Courses Can Be Completed - Snapchat (medium)
  • Solve Decimal Coin Change - Snapchat (medium)
  • Find Maximum Island Perimeter - Snapchat (medium)
  • Solve Three Algorithmic Tasks - Snapchat (hard)
  • Implement a Timestamped Counter - Snapchat (medium)
Snapchat logo
Snapchat
Mar 1, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
6
0
Loading...

You are asked to implement a simple generic list type without using any built-in collection classes (e.g., no ArrayList, LinkedList, Vector, etc.). You may use primitive arrays / custom nodes.

Part 1 — Implement a List

Design and implement MyList<T> with at least the following operations:

  • void add(T value)
  • T get(int index)
  • void set(int index, T value) (or return a new value)
  • T remove(int index)
  • int size()

Requirements:

  • Handle invalid indices (define behavior: throw an exception or return a sentinel).
  • Aim for reasonable time complexity (state your choice of underlying structure: dynamic array or linked list).

Part 2 — Implement an Iterator

Extend MyList<T> so it is iterable.

  • Implement an iterator type with standard iterator methods (e.g., hasNext() and next() ; optionally remove() if you support it).
  • The iterator should traverse the list from index 0 to size()-1 .

Part 3 — Implement a map function

Add a map-style higher-order function:

  • MyList<R> map(Function<T, R> f) (or equivalent in your language)

It should:

  • Apply f to each element in order
  • Return a new MyList<R> containing the mapped results
  • Not modify the original list

Clarifications

  • Assume single-threaded use.
  • You may assume elements can be null unless you choose to forbid it (but document your choice).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Snapchat•More Software Engineer•Snapchat Software Engineer•Snapchat Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.