feat(content): function signatures + test cases
This commit is contained in:
@@ -10,6 +10,22 @@ patterns:
|
||||
- tree-traversal
|
||||
- monotonic-stack
|
||||
|
||||
function_signature: "class BSTIterator:\n def __init__(self, root: TreeNode): ...\n def next(self) -> int: ...\n def hasNext(self) -> bool: ..."
|
||||
|
||||
test_cases:
|
||||
visible:
|
||||
- input: { operations: ["BSTIterator", "next", "next", "hasNext", "next", "hasNext", "next", "hasNext", "next", "hasNext"], args: [[[7, 3, 15, null, null, 9, 20]], [], [], [], [], [], [], [], [], []] }
|
||||
expected: [null, 3, 7, true, 9, true, 15, true, 20, false]
|
||||
hidden:
|
||||
- input: { operations: ["BSTIterator", "hasNext", "next", "hasNext"], args: [[[1]], [], [], []] }
|
||||
expected: [null, true, 1, false]
|
||||
- input: { operations: ["BSTIterator", "next", "next", "next", "hasNext"], args: [[[2, 1, 3]], [], [], [], []] }
|
||||
expected: [null, 1, 2, 3, false]
|
||||
- input: { operations: ["BSTIterator", "next", "next", "next", "next", "next"], args: [[[5, 3, 7, 2, 4, 6, 8]], [], [], [], [], []] }
|
||||
expected: [null, 2, 3, 4, 5, 6]
|
||||
- input: { operations: ["BSTIterator", "hasNext", "hasNext", "next", "hasNext"], args: [[[10]], [], [], [], []] }
|
||||
expected: [null, true, true, 10, false]
|
||||
|
||||
description: |
|
||||
Implement the `BSTIterator` class that represents an iterator over the **in-order traversal** of a binary search tree (BST):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user