Skip to content

Commit 66fe564

Browse files
committed
feat: add construct_binary_tree_from_preorder_and_inorder_traversal
1 parent 9f2c846 commit 66fe564

27 files changed

+751
-71
lines changed

.amazonq/rules/development-rules.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@
1818
- Test all: `make test`
1919
- Beautiful logging with loguru
2020

21+
### Multiple Solution Classes Pattern
22+
23+
When implementing multiple approaches (e.g., Solution, SolutionMath), use parametrized testing:
24+
25+
```python
26+
@pytest.mark.parametrize("solution_class", [Solution, SolutionMath])
27+
@pytest.mark.parametrize("input_params, expected", test_cases)
28+
def test_method(self, solution_class, input_params, expected):
29+
result = run_helper(solution_class, *input_params)
30+
assert_helper(result, expected)
31+
```
32+
33+
This pattern tests all solution approaches with the same test cases, ensuring consistency across implementations.
34+
2135
## File Structure
2236

2337
Each problem has:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repos:
2323
- repo: local
2424
hooks:
2525
- id: sync-submodules
26-
name: Sync git submodules
26+
name: sync git submodules
2727
entry: bash -c 'output=$(git submodule update --init --recursive --remote 2>&1); [ -z "$output" ]'
2828
language: system
2929
always_run: true

.templates/leetcode/json/accounts_merge.json

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,60 @@
55
"problem_title": "Accounts Merge",
66
"difficulty": "Medium",
77
"topics": "Array, Hash Table, String, Depth-First Search, Breadth-First Search, Union Find, Sorting",
8-
"tags": ["grind-75"],
9-
"readme_description": "Given a list of `accounts` where each element `accounts[i]` is a list of strings, where the first element `accounts[i][0]` is a name, and the rest of the elements are **emails** representing emails of the account.\n\nNow, we would like to merge these accounts. Two accounts definitely belong to the same person if there is some common email to both accounts. Note that even if two accounts have the same name, they may belong to different people as people could have the same name. A person can have any number of accounts initially, but all of their accounts definitely have the same name.\n\nAfter merging the accounts, return the accounts in the following format: the first element of each account is the name, and the rest of the elements are emails **in sorted order**. The accounts themselves can be returned in **any order**.",
10-
"readme_examples": [
11-
{
12-
"content": "```\nInput: accounts = [[\"John\",\"johnsmith@mail.com\",\"john_newyork@mail.com\"],[\"John\",\"johnsmith@mail.com\",\"john00@mail.com\"],[\"Mary\",\"mary@mail.com\"],[\"John\",\"johnnybravo@mail.com\"]]\nOutput: [[\"John\",\"john00@mail.com\",\"john_newyork@mail.com\",\"johnsmith@mail.com\"],[\"Mary\",\"mary@mail.com\"],[\"John\",\"johnnybravo@mail.com\"]]\n```\n**Explanation:** The first and second John's are the same person as they have the common email \"johnsmith@mail.com\". The third John and Mary are different people as none of their email addresses are used by other accounts."
13-
},
14-
{
15-
"content": "```\nInput: accounts = [[\"Gabe\",\"Gabe0@m.co\",\"Gabe3@m.co\",\"Gabe1@m.co\"],[\"Kevin\",\"Kevin3@m.co\",\"Kevin5@m.co\",\"Kevin0@m.co\"],[\"Ethan\",\"Ethan5@m.co\",\"Ethan4@m.co\",\"Ethan0@m.co\"],[\"Hanzo\",\"Hanzo3@m.co\",\"Hanzo1@m.co\",\"Hanzo0@m.co\"],[\"Fern\",\"Fern5@m.co\",\"Fern1@m.co\",\"Fern0@m.co\"]]\nOutput: [[\"Ethan\",\"Ethan0@m.co\",\"Ethan4@m.co\",\"Ethan5@m.co\"],[\"Gabe\",\"Gabe0@m.co\",\"Gabe1@m.co\",\"Gabe3@m.co\"],[\"Hanzo\",\"Hanzo0@m.co\",\"Hanzo1@m.co\",\"Hanzo3@m.co\"],[\"Kevin\",\"Kevin0@m.co\",\"Kevin3@m.co\",\"Kevin5@m.co\"],[\"Fern\",\"Fern0@m.co\",\"Fern1@m.co\",\"Fern5@m.co\"]]\n```"
16-
}
17-
],
18-
"readme_constraints": "- `1 <= accounts.length <= 1000`\n- `2 <= accounts[i].length <= 10`\n- `1 <= accounts[i][j].length <= 30`\n- `accounts[i][0]` consists of English letters.\n- `accounts[i][j] (for j > 0)` is a valid email.",
8+
"_tags": { "list": ["grind-75"] },
9+
"readme_description": "Given a list of `accounts` where each element `accounts[i]` is a list of strings, where the first element `accounts[i][0]` is a name, and the rest of the elements are emails representing emails of the account.\n\nNow, we would like to merge these accounts. Two accounts definitely belong to the same person if there is some common email to both accounts. Note that even if two accounts have the same name, they may belong to different people as people could have the same name. A person can have any number of accounts initially, but all of their accounts definitely have the same name.\n\nAfter merging the accounts, return the accounts in the following format: the first element of each account is the name, and the rest of the elements are emails in sorted order. The accounts themselves can be returned in any order.",
10+
"_readme_examples": {
11+
"list": [
12+
{
13+
"content": "```\nInput: accounts = [[\"John\",\"johnsmith@mail.com\",\"john_newyork@mail.com\"],[\"John\",\"johnsmith@mail.com\",\"john00@mail.com\"],[\"Mary\",\"mary@mail.com\"],[\"John\",\"johnnybravo@mail.com\"]]\nOutput: [[\"John\",\"john00@mail.com\",\"john_newyork@mail.com\",\"johnsmith@mail.com\"],[\"Mary\",\"mary@mail.com\"],[\"John\",\"johnnybravo@mail.com\"]]\n```\n**Explanation:** The first and second John's are the same person as they have the common email \"johnsmith@mail.com\". The third John and Mary are different people as none of their email addresses are used by other accounts."
14+
},
15+
{
16+
"content": "```\nInput: accounts = [[\"Gabe\",\"Gabe0@m.co\",\"Gabe3@m.co\",\"Gabe1@m.co\"],[\"Kevin\",\"Kevin3@m.co\",\"Kevin5@m.co\",\"Kevin0@m.co\"],[\"Ethan\",\"Ethan5@m.co\",\"Ethan4@m.co\",\"Ethan0@m.co\"],[\"Hanzo\",\"Hanzo3@m.co\",\"Hanzo1@m.co\",\"Hanzo0@m.co\"],[\"Fern\",\"Fern5@m.co\",\"Fern1@m.co\",\"Fern0@m.co\"]]\nOutput: [[\"Ethan\",\"Ethan0@m.co\",\"Ethan4@m.co\",\"Ethan5@m.co\"],[\"Gabe\",\"Gabe0@m.co\",\"Gabe1@m.co\",\"Gabe3@m.co\"],[\"Hanzo\",\"Hanzo0@m.co\",\"Hanzo1@m.co\",\"Hanzo3@m.co\"],[\"Kevin\",\"Kevin0@m.co\",\"Kevin3@m.co\",\"Kevin5@m.co\"],[\"Fern\",\"Fern0@m.co\",\"Fern1@m.co\",\"Fern5@m.co\"]]\n```"
17+
}
18+
]
19+
},
20+
"readme_constraints": "- 1 <= accounts.length <= 1000\n- 2 <= accounts[i].length <= 10\n- 1 <= accounts[i][j].length <= 30\n- accounts[i][0] consists of English letters.\n- accounts[i][j] (for j > 0) is a valid email.",
21+
"readme_additional": "",
1922
"helpers_imports": "",
23+
"helpers_content": "",
2024
"helpers_run_name": "accounts_merge",
2125
"helpers_run_signature": "(solution_class: type, accounts: list[list[str]])",
2226
"helpers_run_body": " implementation = solution_class()\n return implementation.accounts_merge(accounts)",
2327
"helpers_assert_name": "accounts_merge",
2428
"helpers_assert_signature": "(result: list[list[str]], expected: list[list[str]]) -> bool",
2529
"helpers_assert_body": " # Sort both result and expected for comparison since order doesn't matter\n result_sorted = [sorted(account) for account in sorted(result)]\n expected_sorted = [sorted(account) for account in sorted(expected)]\n assert result_sorted == expected_sorted\n return True",
26-
"solution_methods": [
27-
{
28-
"name": "accounts_merge",
29-
"signature": "(self, accounts: list[list[str]]) -> list[list[str]]",
30-
"body": " # TODO: Implement accounts_merge\n return []"
31-
}
32-
],
30+
"solution_imports": "",
31+
"solution_contents": "",
32+
"solution_class_content": "",
3333
"test_imports": "import pytest\nfrom leetcode_py.test_utils import logged_test\nfrom .helpers import assert_accounts_merge, run_accounts_merge\nfrom .solution import Solution",
3434
"test_content": "",
3535
"test_class_name": "AccountsMerge",
3636
"test_class_content": " def setup_method(self):\n self.solution = Solution()",
37-
"test_helper_methods": [],
38-
"test_methods": [
39-
{
40-
"name": "test_accounts_merge",
41-
"signature": "(self, accounts: list[list[str]], expected: list[list[str]])",
42-
"parametrize": "accounts, expected",
43-
"test_cases": "[([[\"John\", \"johnsmith@mail.com\", \"john_newyork@mail.com\"], [\"John\", \"johnsmith@mail.com\", \"john00@mail.com\"], [\"Mary\", \"mary@mail.com\"], [\"John\", \"johnnybravo@mail.com\"]], [[\"John\", \"john00@mail.com\", \"john_newyork@mail.com\", \"johnsmith@mail.com\"], [\"Mary\", \"mary@mail.com\"], [\"John\", \"johnnybravo@mail.com\"]]), ([[\"Gabe\", \"Gabe0@m.co\", \"Gabe3@m.co\", \"Gabe1@m.co\"], [\"Kevin\", \"Kevin3@m.co\", \"Kevin5@m.co\", \"Kevin0@m.co\"], [\"Ethan\", \"Ethan5@m.co\", \"Ethan4@m.co\", \"Ethan0@m.co\"], [\"Hanzo\", \"Hanzo3@m.co\", \"Hanzo1@m.co\", \"Hanzo0@m.co\"], [\"Fern\", \"Fern5@m.co\", \"Fern1@m.co\", \"Fern0@m.co\"]], [[\"Ethan\", \"Ethan0@m.co\", \"Ethan4@m.co\", \"Ethan5@m.co\"], [\"Gabe\", \"Gabe0@m.co\", \"Gabe1@m.co\", \"Gabe3@m.co\"], [\"Hanzo\", \"Hanzo0@m.co\", \"Hanzo1@m.co\", \"Hanzo3@m.co\"], [\"Kevin\", \"Kevin0@m.co\", \"Kevin3@m.co\", \"Kevin5@m.co\"], [\"Fern\", \"Fern0@m.co\", \"Fern1@m.co\", \"Fern5@m.co\"]]), ([[\"John\", \"john@mail.com\"]], [[\"John\", \"john@mail.com\"]]), ([[\"John\", \"john1@mail.com\"], [\"John\", \"john2@mail.com\"], [\"John\", \"john3@mail.com\"]], [[\"John\", \"john1@mail.com\"], [\"John\", \"john2@mail.com\"], [\"John\", \"john3@mail.com\"]]), ([[\"John\", \"a@mail.com\", \"b@mail.com\"], [\"John\", \"b@mail.com\", \"c@mail.com\"], [\"John\", \"d@mail.com\"]], [[\"John\", \"a@mail.com\", \"b@mail.com\", \"c@mail.com\"], [\"John\", \"d@mail.com\"]]), ([[\"Alice\", \"alice@mail.com\", \"alice1@mail.com\"], [\"Alice\", \"alice2@mail.com\", \"alice3@mail.com\"], [\"Alice\", \"alice1@mail.com\", \"alice2@mail.com\"]], [[\"Alice\", \"alice1@mail.com\", \"alice2@mail.com\", \"alice3@mail.com\", \"alice@mail.com\"]]), ([[\"Bob\", \"bob@mail.com\"], [\"Bob\", \"bob@mail.com\"]], [[\"Bob\", \"bob@mail.com\"]]), ([[\"David\", \"david1@mail.com\", \"david2@mail.com\"], [\"David\", \"david3@mail.com\"], [\"David\", \"david2@mail.com\", \"david4@mail.com\"]], [[\"David\", \"david1@mail.com\", \"david2@mail.com\", \"david4@mail.com\"], [\"David\", \"david3@mail.com\"]]), ([[\"Alex\", \"alex@mail.com\"], [\"Alex\", \"alex@mail.com\", \"alex2@mail.com\"], [\"Alex\", \"alex3@mail.com\"]], [[\"Alex\", \"alex2@mail.com\", \"alex@mail.com\"], [\"Alex\", \"alex3@mail.com\"]]), ([[\"Tom\", \"tom1@mail.com\"], [\"Tom\", \"tom2@mail.com\"], [\"Tom\", \"tom3@mail.com\"], [\"Tom\", \"tom4@mail.com\"]], [[\"Tom\", \"tom1@mail.com\"], [\"Tom\", \"tom2@mail.com\"], [\"Tom\", \"tom3@mail.com\"], [\"Tom\", \"tom4@mail.com\"]]), ([[\"Sam\", \"sam@mail.com\", \"sam1@mail.com\", \"sam2@mail.com\"]], [[\"Sam\", \"sam@mail.com\", \"sam1@mail.com\", \"sam2@mail.com\"]])]",
44-
"body": " result = run_accounts_merge(Solution, accounts)\n assert_accounts_merge(result, expected)"
45-
}
46-
],
37+
"_solution_methods": {
38+
"list": [
39+
{
40+
"name": "accounts_merge",
41+
"signature": "(self, accounts: list[list[str]]) -> list[list[str]]",
42+
"body": " # TODO: Implement accounts_merge\n return []"
43+
}
44+
]
45+
},
46+
"_test_helper_methods": {
47+
"list": [{ "name": "setup_method", "parameters": "", "body": "self.solution = Solution()" }]
48+
},
49+
"_test_methods": {
50+
"list": [
51+
{
52+
"name": "test_accounts_merge",
53+
"signature": "(self, accounts: list[list[str]], expected: list[list[str]])",
54+
"parametrize": "accounts, expected",
55+
"test_cases": "[([['John', 'johnsmith@mail.com', 'john_newyork@mail.com'], ['John', 'johnsmith@mail.com', 'john00@mail.com'], ['Mary', 'mary@mail.com'], ['John', 'johnnybravo@mail.com']], [['John', 'john00@mail.com', 'john_newyork@mail.com', 'johnsmith@mail.com'], ['Mary', 'mary@mail.com'], ['John', 'johnnybravo@mail.com']]), ([['Gabe', 'Gabe0@m.co', 'Gabe3@m.co', 'Gabe1@m.co'], ['Kevin', 'Kevin3@m.co', 'Kevin5@m.co', 'Kevin0@m.co'], ['Ethan', 'Ethan5@m.co', 'Ethan4@m.co', 'Ethan0@m.co'], ['Hanzo', 'Hanzo3@m.co', 'Hanzo1@m.co', 'Hanzo0@m.co'], ['Fern', 'Fern5@m.co', 'Fern1@m.co', 'Fern0@m.co']], [['Ethan', 'Ethan0@m.co', 'Ethan4@m.co', 'Ethan5@m.co'], ['Gabe', 'Gabe0@m.co', 'Gabe1@m.co', 'Gabe3@m.co'], ['Hanzo', 'Hanzo0@m.co', 'Hanzo1@m.co', 'Hanzo3@m.co'], ['Kevin', 'Kevin0@m.co', 'Kevin3@m.co', 'Kevin5@m.co'], ['Fern', 'Fern0@m.co', 'Fern1@m.co', 'Fern5@m.co']]), ([['Alice', 'alice@mail.com']], [['Alice', 'alice@mail.com']]), ([['Bob', 'bob1@mail.com'], ['Bob', 'bob2@mail.com']], [['Bob', 'bob1@mail.com'], ['Bob', 'bob2@mail.com']]), ([['Alice', 'alice@mail.com', 'alice2@mail.com'], ['Alice', 'alice2@mail.com', 'alice3@mail.com']], [['Alice', 'alice2@mail.com', 'alice3@mail.com', 'alice@mail.com']]), ([['A', 'a@mail.com', 'b@mail.com'], ['B', 'b@mail.com', 'c@mail.com'], ['C', 'c@mail.com', 'd@mail.com']], [['A', 'a@mail.com', 'b@mail.com', 'c@mail.com', 'd@mail.com']]), ([['David', 'david@mail.com'], ['David', 'david@mail.com']], [['David', 'david@mail.com']]), ([['Alex', 'alex1@mail.com'], ['Bob', 'bob1@mail.com'], ['Charlie', 'charlie1@mail.com']], [['Alex', 'alex1@mail.com'], ['Bob', 'bob1@mail.com'], ['Charlie', 'charlie1@mail.com']]), ([['John', 'john1@mail.com', 'john2@mail.com'], ['John', 'john3@mail.com'], ['Jane', 'jane1@mail.com']], [['John', 'john1@mail.com', 'john2@mail.com'], ['John', 'john3@mail.com'], ['Jane', 'jane1@mail.com']]), ([['User', 'user@mail.com', 'user1@mail.com'], ['User', 'user2@mail.com', 'user@mail.com'], ['User', 'user3@mail.com', 'user1@mail.com']], [['User', 'user1@mail.com', 'user2@mail.com', 'user3@mail.com', 'user@mail.com']]), ([['Test', 'test1@mail.com'], ['Test', 'test2@mail.com'], ['Test', 'test1@mail.com', 'test3@mail.com']], [['Test', 'test2@mail.com'], ['Test', 'test1@mail.com', 'test3@mail.com']]), ([['Name', 'a@mail.com', 'b@mail.com', 'c@mail.com'], ['Name', 'd@mail.com', 'e@mail.com'], ['Name', 'c@mail.com', 'f@mail.com']], [['Name', 'd@mail.com', 'e@mail.com'], ['Name', 'a@mail.com', 'b@mail.com', 'c@mail.com', 'f@mail.com']])]",
56+
"body": " result = run_accounts_merge(Solution, accounts)\n assert_accounts_merge(result, expected)"
57+
}
58+
]
59+
},
4760
"playground_imports": "from helpers import run_accounts_merge, assert_accounts_merge\nfrom solution import Solution",
48-
"playground_setup": "# Example test case\naccounts = [[\"John\", \"johnsmith@mail.com\", \"john_newyork@mail.com\"], [\"John\", \"johnsmith@mail.com\", \"john00@mail.com\"], [\"Mary\", \"mary@mail.com\"], [\"John\", \"johnnybravo@mail.com\"]]\nexpected = [[\"John\", \"john00@mail.com\", \"john_newyork@mail.com\", \"johnsmith@mail.com\"], [\"Mary\", \"mary@mail.com\"], [\"John\", \"johnnybravo@mail.com\"]]",
61+
"playground_setup": "# Example test case\naccounts = [['John', 'johnsmith@mail.com', 'john_newyork@mail.com'], ['John', 'johnsmith@mail.com', 'john00@mail.com'], ['Mary', 'mary@mail.com'], ['John', 'johnnybravo@mail.com']]\nexpected = [['John', 'john00@mail.com', 'john_newyork@mail.com', 'johnsmith@mail.com'], ['Mary', 'mary@mail.com'], ['John', 'johnnybravo@mail.com']]",
4962
"playground_run": "result = run_accounts_merge(Solution, accounts)\nresult",
5063
"playground_assert": "assert_accounts_merge(result, expected)"
5164
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"problem_name": "construct_binary_tree_from_preorder_and_inorder_traversal",
3+
"solution_class_name": "Solution",
4+
"problem_number": "105",
5+
"problem_title": "Construct Binary Tree from Preorder and Inorder Traversal",
6+
"difficulty": "Medium",
7+
"topics": "Array, Hash Table, Divide and Conquer, Tree, Binary Tree",
8+
"_tags": { "list": ["grind-75"] },
9+
"readme_description": "Given two integer arrays `preorder` and `inorder` where `preorder` is the preorder traversal of a binary tree and `inorder` is the inorder traversal of the same tree, construct and return the binary tree.",
10+
"_readme_examples": {
11+
"list": [
12+
{
13+
"content": "![Example 1](https://assets.leetcode.com/uploads/2021/02/19/tree.jpg)\n\n```\nInput: preorder = [3,9,20,15,7], inorder = [9,3,15,20,7]\nOutput: [3,9,20,null,null,15,7]\n```"
14+
},
15+
{ "content": "```\nInput: preorder = [-1], inorder = [-1]\nOutput: [-1]\n```" }
16+
]
17+
},
18+
"readme_constraints": "- 1 <= preorder.length <= 3000\n- inorder.length == preorder.length\n- -3000 <= preorder[i], inorder[i] <= 3000\n- preorder and inorder consist of unique values.\n- Each value of inorder also appears in preorder.\n- preorder is guaranteed to be the preorder traversal of the tree.\n- inorder is guaranteed to be the inorder traversal of the tree.",
19+
"readme_additional": "",
20+
"helpers_imports": "from leetcode_py import TreeNode",
21+
"helpers_content": "",
22+
"helpers_run_name": "build_tree",
23+
"helpers_run_signature": "(solution_class: type, preorder: list[int], inorder: list[int])",
24+
"helpers_run_body": " implementation = solution_class()\n return implementation.build_tree(preorder, inorder)",
25+
"helpers_assert_name": "build_tree",
26+
"helpers_assert_signature": "(result: TreeNode | None, expected_list: list[int | None]) -> bool",
27+
"helpers_assert_body": " expected = TreeNode.from_list(expected_list) if expected_list else None\n assert result == expected\n return True",
28+
"solution_imports": "from leetcode_py import TreeNode",
29+
"solution_contents": "",
30+
"solution_class_content": "",
31+
"test_imports": "import pytest\nfrom leetcode_py.test_utils import logged_test\nfrom .helpers import assert_build_tree, run_build_tree\nfrom .solution import Solution",
32+
"test_content": "",
33+
"test_class_name": "ConstructBinaryTreeFromPreorderAndInorderTraversal",
34+
"test_class_content": " def setup_method(self):\n self.solution = Solution()",
35+
"_solution_methods": {
36+
"list": [
37+
{
38+
"name": "build_tree",
39+
"signature": "(self, preorder: list[int], inorder: list[int]) -> TreeNode | None",
40+
"body": " # TODO: Implement build_tree\n return None"
41+
}
42+
]
43+
},
44+
"_test_helper_methods": {
45+
"list": [{ "name": "setup_method", "parameters": "", "body": "self.solution = Solution()" }]
46+
},
47+
"_test_methods": {
48+
"list": [
49+
{
50+
"name": "test_build_tree",
51+
"signature": "(self, preorder: list[int], inorder: list[int], expected_list: list[int | None])",
52+
"parametrize": "preorder, inorder, expected_list",
53+
"test_cases": "[([3, 9, 20, 15, 7], [9, 3, 15, 20, 7], [3, 9, 20, None, None, 15, 7]), ([-1], [-1], [-1]), ([1, 2], [2, 1], [1, 2]), ([1, 2], [1, 2], [1, None, 2]), ([1, 2, 3], [2, 1, 3], [1, 2, 3]), ([3, 9, 20, 15, 7], [9, 3, 15, 20, 7], [3, 9, 20, None, None, 15, 7]), ([1, 2, 4, 5, 3, 6], [4, 2, 5, 1, 6, 3], [1, 2, 3, 4, 5, 6]), ([1], [1], [1]), ([1, 2, 3, 4], [1, 2, 3, 4], [1, None, 2, None, 3, None, 4]), ([4, 3, 2, 1], [1, 2, 3, 4], [4, 3, None, 2, None, 1]), ([5, 4, 11, 7, 2, 8, 13, 4, 1], [7, 11, 2, 4, 5, 13, 8, 4, 1], [5, 4, 8, 11, None, 13, 4, 7, 2, None, None, None, 1]), ([10, 5, 1, 7, 40, 50], [1, 5, 7, 10, 40, 50], [10, 5, 40, 1, 7, None, 50])]",
54+
"body": " result = run_build_tree(Solution, preorder, inorder)\n assert_build_tree(result, expected_list)"
55+
}
56+
]
57+
},
58+
"playground_imports": "from helpers import run_build_tree, assert_build_tree\nfrom solution import Solution\nfrom leetcode_py import TreeNode",
59+
"playground_setup": "# Example test case\npreorder = [3, 9, 20, 15, 7]\ninorder = [9, 3, 15, 20, 7]\nexpected_list = [3, 9, 20, None, None, 15, 7]",
60+
"playground_run": "result = run_build_tree(Solution, preorder, inorder)\nresult",
61+
"playground_assert": "assert_build_tree(result, expected_list)"
62+
}

0 commit comments

Comments
 (0)