The Chain Builder
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L3
Problem
Implement a singly linked list from scratch (a Node class plus a LinkedList class with insert and find) and drive it with a list of operations. The driver `linked_list_demo(ops)` receives `ops`, a list of `[operation, value]` pairs. For `['insert', val]`, append `val` to the end (tail) of the list and produce no result. For `['find', val]`, return True if `val` is currently in the list, else False. Return a list containing only the results of the `find` operations, in the order they appear. For the example `[['insert', 1], ['insert', 2], ['insert', 3], ['find', 2], ['find', 5]]` the result is `[True, False]`. If there are no `find` operations, return an empty list.
Summary
Links connect in sequence - build the chain from scratch.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.