← 返回 snapchat 的题目列表Custom List, Iterator & Map Function
类型:qbank
Implement a list without built-in collections, then add an iterator and a map function on top of the custom data structure.
Requirements
Implement a custom list data structure without using built-in collection types as the core storage.
Expected API can be clarified, but a complete answer should support:
Append or insert values.
Retrieve values by index or iteration.
Track size.
Implement an iterator with the language's expected method signatures.
Implement mapFunction, returning a transformed list or iterable.
Run basic tests and handle empty-list behavior.
Notes
Choose the simplest backing structure you can implement correctly under interview time. An array-backed dynamic list needs resizing and index bounds; a linked list needs node traversal and simpler append if you keep a tail pointer. For Java-style iterators, know the method names and return types before the interview.
The mapFunction follow-up should not mutate the original list unless specified. It should iterate through the list, apply a callback to each value, and build a new custom list of transformed values.
Preparation
Memorize the iterator interface for your interview language.
Implement both an array-backed and linked-list-backed version once, then choose one for interviews.
Add tests for empty list, one element, multiple elements, mapping to a different type if the language supports generics, and iterator exhaustion.