← 返回 openai 的题目列表Resumable Iterator, Unit Tests, Time-Based KV Store, and Concurrency
类型:online_judge
openai
Implement a Resumable Iterator and perform the following four tasks:
Write an abstract class ResumableIterator in Python that supports saving and restoring the state of the iterator.
Write at least three unit tests to validate the functionality of the iterator. The tests must pass on the code pad.
Implement a Time-Based Key-Value Store.
After implementing the store, answer the following questions:
How to write tests for this storage?
How to mock timestamps?
How to lock in a multithreading environment? Compare the efficiency of different lock implementation methods.
Each stage proceeds after finishing the previous task, only brief comments in code are required for the fourth question.
Note: Focus on strategies for variable serialization for memory optimization.
Example
Input
[1, 2, 3, 4]