diff --git a/.amazonq/rules/development-rules.md b/.amazonq/rules/development-rules.md index 671ffc8..aae1892 100644 --- a/.amazonq/rules/development-rules.md +++ b/.amazonq/rules/development-rules.md @@ -24,5 +24,7 @@ Each problem has: - `README.md` - Problem description - `solution.py` - Implementation with TODO placeholder -- `tests.py` - Parametrized pytest tests +- `test_solution.py` - Parametrized pytest tests +- `helpers.py` - Test helper functions +- `playground.ipynb` - Interactive Jupyter notebook - `__init__.py` - Empty package file diff --git a/.amazonq/rules/test-case-enhancement.md b/.amazonq/rules/test-case-enhancement.md index 7a65e36..11b5019 100644 --- a/.amazonq/rules/test-case-enhancement.md +++ b/.amazonq/rules/test-case-enhancement.md @@ -1,107 +1,63 @@ # Test Case Enhancement Rules -## Assistant Workflow for Adding Comprehensive Test Cases +## Simple Enhancement Workflow -When user requests to enhance test cases for a problem, the assistant will: +When user requests test case enhancement: -### 1. Problem Resolution (Priority Order) +### 1. Problem Resolution -- **FIRST**: Try to resolve from context - check active file path or user-provided problem name -- **SECOND**: If context resolution fails, THEN run `poetry run python .templates/check_test_cases.py --threshold=10 --max=1` to auto-detect 1 problem with <10 test cases -- **LAST**: If both above fail, ask user to explicitly specify problem name +- Use active file context or user-provided problem name +- If unclear, run: `poetry run python .templates/check_test_cases.py --threshold=10 --max=1` -### 2. Test Case Generation +### 2. Enhancement Process -- Read `leetcode/{problem_name}/README.md` for problem understanding -- Analyze existing test cases in `leetcode/{problem_name}/tests.py` -- Generate comprehensive test cases covering: - - **Edge cases**: Empty inputs, single elements, boundary values - - **Corner cases**: Maximum/minimum constraints, special patterns - - **Normal cases**: Typical scenarios with varied complexity - - **Error cases**: Invalid inputs (if applicable) - -### 3. Initial Validation - -- Run `make p-test PROBLEM={problem_name}` to verify current implementation -- **If errors found**: - - DO NOT update implementation automatically - - Only update test cases if they're incorrect - - If implementation seems wrong, ASK USER first before modifying - -### 4. JSON Template Update - -- Update corresponding `.templates/leetcode/json/{problem_name}.json` -- Add new test cases to `test_cases` field in proper format -- Maintain existing test structure and naming conventions - -### 5. Backup and Regeneration Process - -- **Backup**: Move `leetcode/{problem_name}/` to `.cache/leetcode/{problem_name}/` -- **Regenerate**: Run `make p-gen PROBLEM={problem_name} FORCE=1` -- **Lint check**: Run `make p-lint PROBLEM={problem_name}` -- **Iterate**: If lint fails, update JSON and regenerate until passes +```bash +# Simple 4-step process: +# 1. Update JSON template with more test cases (12-15 total) +# 2. Backup original +mv leetcode/{problem_name} .cache/leetcode/{problem_name} +# 3. Regenerate with enhanced tests +make p-gen PROBLEM={problem_name} FORCE=1 && make p-lint PROBLEM={problem_name} +# 4. Restore original solution, keep enhanced tests +cp .cache/leetcode/{problem_name}/solution.py leetcode/{problem_name}/solution.py +``` -### 6. Solution Preservation +### 3. Verification -- Copy `solution.py` from backup to newly generated structure -- Run `make p-test PROBLEM={problem_name}` to verify tests pass -- **If tests fail**: Go back to step 4, update JSON, and iterate until passes +- Run `make p-test PROBLEM={problem_name}` +- Fix any incorrect expected values in test cases +- Update JSON template with corrections -### 7. Cleanup and Restore +### 4. Restore Backup -- **CRITICAL**: Remove entire newly generated `leetcode/{problem_name}/` directory -- **CRITICAL**: Restore original structure from `.cache/leetcode/{problem_name}/` backup -- **CRITICAL**: Only THEN copy enhanced `test_solution.py` from generated files to restored structure -- **CRITICAL**: Preserve existing solution class parametrization - if original test had multiple solution classes, restore them -- Verify final state with `make p-test PROBLEM={problem_name}` -- Clean up backup directory after successful verification +```bash +# Copy enhanced test_solution.py to backup +cp leetcode/{problem_name}/test_solution.py .cache/leetcode/{problem_name}/ +# Restore all original files (preserves user edits) +rm -rf leetcode/{problem_name} +mv .cache/leetcode/{problem_name} leetcode/{problem_name} +``` -## Test Case Quality Standards +## Test Case Standards ### Coverage Requirements -- **Minimum 10 test cases** per problem -- **Edge cases**: 20-30% of total test cases -- **Normal cases**: 50-60% of total test cases -- **Corner cases**: 20-30% of total test cases +- **Minimum 12 test cases** per problem +- **Edge cases**: Empty inputs, single elements, boundary values +- **Corner cases**: Maximum/minimum constraints, duplicates, sorted arrays +- **Normal cases**: Mixed scenarios with varied complexity -### Test Case Categories +### JSON Format -#### Edge Cases - -- Empty inputs: `[]`, `""`, `None` -- Single element: `[1]`, `"a"` -- Boundary values: `[0]`, `[1]`, `[-1]` -- Maximum/minimum constraints from problem description - -#### Corner Cases - -- Duplicate elements: `[1,1,1]` -- Sorted/reverse sorted arrays: `[1,2,3]`, `[3,2,1]` -- All same elements: `[5,5,5,5]` -- Alternating patterns: `[1,0,1,0]` - -#### Normal Cases - -- Mixed positive/negative numbers -- Various array sizes within constraints -- Different data patterns and structures -- Representative problem scenarios - -### JSON Format Requirements - -- Use single quotes for Python strings in test cases +- Use single quotes for Python strings: `'hello'` not `"hello"` - Follow existing parametrize format -- Maintain type hints in parametrize_typed -- Ensure test_cases string is valid Python list syntax -- **NEVER include custom solution classes** in test_imports - only import the main solution class specified in solution_class_name -- **PRESERVE existing solution class parametrization** - if original test had multiple solution classes, restore them after JSON regeneration +- Ensure valid Python list syntax in test_cases field -## Commands Reference +## Quick Commands ```bash -# Find problems needing more test cases -poetry run python .templates/check_test_cases.py --threshold=10 --max=1 +# Find problems needing enhancement +poetry run python .templates/check_test_cases.py --threshold=10 # Test specific problem make p-test PROBLEM={problem_name} @@ -109,21 +65,14 @@ make p-test PROBLEM={problem_name} # Generate from JSON template make p-gen PROBLEM={problem_name} FORCE=1 -# Lint specific problem +# Lint check make p-lint PROBLEM={problem_name} ``` -## Error Handling - -- **Implementation errors**: Ask user before modifying solution code -- **Test failures**: Update JSON template and regenerate -- **Lint failures**: Fix JSON format and iterate -- **Backup failures**: Ensure `.cache/leetcode/` directory exists - ## Success Criteria - All tests pass with enhanced test cases -- Minimum 10 comprehensive test cases per problem -- Original solution code preserved and working +- Minimum 12 comprehensive test cases per problem +- Original solution code preserved +- **Enhanced test cases in final test_solution.py** - JSON template updated for future regeneration -- Clean final state with no temporary files diff --git a/.templates/leetcode/json/accounts_merge.json b/.templates/leetcode/json/accounts_merge.json index 436e531..bcbddb6 100644 --- a/.templates/leetcode/json/accounts_merge.json +++ b/.templates/leetcode/json/accounts_merge.json @@ -40,7 +40,7 @@ "name": "test_accounts_merge", "signature": "(self, accounts: list[list[str]], expected: list[list[str]])", "parametrize": "accounts, expected", - "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\"]], [[\"John\"]]), ([[\"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\"]]), ([[\"John\", \"shared@mail.com\"], [\"Jane\", \"shared@mail.com\"]], [[\"John\", \"shared@mail.com\"]])]", + "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\"]])]", "body": " result = run_accounts_merge(Solution, accounts)\n assert_accounts_merge(result, expected)" } ], diff --git a/.templates/leetcode/json/balanced_binary_tree.json b/.templates/leetcode/json/balanced_binary_tree.json index 1d9955d..c413c49 100644 --- a/.templates/leetcode/json/balanced_binary_tree.json +++ b/.templates/leetcode/json/balanced_binary_tree.json @@ -53,7 +53,7 @@ "name": "test_is_balanced", "signature": "(self, root_list: list[int | None], expected: bool)", "parametrize": "root_list, expected", - "test_cases": "[([3, 9, 20, None, None, 15, 7], True), ([1, 2, 2, 3, 3, None, None, 4, 4], False), ([], True), ([1], True), ([1, 2], True), ([1, None, 2], True), ([1, 2, 3, 4], True), ([1, 2, 2, 3, None, None, 3, 4, None, None, 4], False)]", + "test_cases": "[([3, 9, 20, None, None, 15, 7], True), ([1, 2, 2, 3, 3, None, None, 4, 4], False), ([], True), ([1], True), ([1, 2], True), ([1, None, 2], True), ([1, 2, 3, 4], True), ([1, 2, 2, 3, None, None, 3, 4, None, None, 4], False), ([1, 2, 3], True), ([1, 2, None, 3], False), ([1, None, 2, None, 3], False), ([1, 2, 3, 4, 5, 6, 7], True), ([1, 2, 3, None, None, 4, None, None, 5], False), ([5, 1, 4, None, None, 3, 6], True), ([1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, None, None, 5, 5], True)]", "body": " result = run_is_balanced(Solution, root_list)\n assert_is_balanced(result, expected)" } ] diff --git a/.templates/leetcode/json/best_time_to_buy_and_sell_stock.json b/.templates/leetcode/json/best_time_to_buy_and_sell_stock.json index 1cd4038..0c86cdb 100644 --- a/.templates/leetcode/json/best_time_to_buy_and_sell_stock.json +++ b/.templates/leetcode/json/best_time_to_buy_and_sell_stock.json @@ -52,7 +52,7 @@ "name": "test_max_profit", "signature": "(self, prices: list[int], expected: int)", "parametrize": "prices, expected", - "test_cases": "[([7, 1, 5, 3, 6, 4], 5), ([7, 6, 4, 3, 1], 0), ([1, 2, 3, 4, 5], 4), ([5, 4, 3, 2, 1], 0), ([1], 0), ([2, 1], 0), ([1, 2], 1), ([3, 2, 6, 5, 0, 3], 4)]", + "test_cases": "[([7, 1, 5, 3, 6, 4], 5), ([7, 6, 4, 3, 1], 0), ([1, 2, 3, 4, 5], 4), ([5, 4, 3, 2, 1], 0), ([1], 0), ([2, 1], 0), ([1, 2], 1), ([3, 2, 6, 5, 0, 3], 4), ([2, 4, 1], 2), ([1, 5, 3, 6, 4], 5), ([10, 1, 5, 6, 7, 1], 6), ([6, 1, 3, 2, 4, 7], 6), ([1, 4, 2], 3), ([3, 3, 5, 0, 0, 3, 1, 4], 4), ([2, 1, 2, 1, 0, 1, 2], 2)]", "body": " result = run_max_profit(Solution, prices)\n assert_max_profit(result, expected)" } ] diff --git a/.templates/leetcode/json/binary_tree_right_side_view.json b/.templates/leetcode/json/binary_tree_right_side_view.json index 56eba70..2607777 100644 --- a/.templates/leetcode/json/binary_tree_right_side_view.json +++ b/.templates/leetcode/json/binary_tree_right_side_view.json @@ -54,7 +54,7 @@ "name": "test_right_side_view", "signature": "(self, root_list: list[int | None], expected: list[int])", "parametrize": "root_list, expected", - "test_cases": "[([1, 2, 3, None, 5, None, 4], [1, 3, 4]), ([1, 2, 3, 4, None, None, None, 5], [1, 3, 4, 5]), ([1, None, 3], [1, 3]), ([], []), ([1], [1]), ([1, 2], [1, 2]), ([1, None, 2], [1, 2])]", + "test_cases": "[([1, 2, 3, None, 5, None, 4], [1, 3, 4]), ([1, 2, 3, 4, None, None, None, 5], [1, 3, 4, 5]), ([1, None, 3], [1, 3]), ([], []), ([1], [1]), ([1, 2], [1, 2]), ([1, None, 2], [1, 2]), ([1, 2, 3], [1, 3]), ([1, 2, None, 4], [1, 2, 4]), ([1, 2, 3, 4, 5, 6, 7], [1, 3, 7]), ([1, 2, 3, None, None, 4, 5], [1, 3, 5]), ([5, 4, 6, None, None, None, 7], [5, 6, 7]), ([1, 2, 3, 4, 5, None, None, 8], [1, 3, 5, 8]), ([10, 5, 15, None, 6, 12, 20], [10, 15, 20])]", "body": " result = run_right_side_view(Solution, root_list)\n assert_right_side_view(result, expected)" } ] diff --git a/.templates/leetcode/json/climbing_stairs.json b/.templates/leetcode/json/climbing_stairs.json index 8dcb90b..c5a1375 100644 --- a/.templates/leetcode/json/climbing_stairs.json +++ b/.templates/leetcode/json/climbing_stairs.json @@ -52,7 +52,7 @@ "name": "test_climb_stairs", "signature": "(self, n: int, expected: int)", "parametrize": "n, expected", - "test_cases": "[(1, 1), (2, 2), (3, 3), (4, 5), (5, 8), (6, 13), (10, 89), (20, 10946), (45, 1836311903)]", + "test_cases": "[(1, 1), (2, 2), (3, 3), (4, 5), (5, 8), (6, 13), (7, 21), (8, 34), (9, 55), (10, 89), (15, 987), (20, 10946), (25, 121393), (30, 1346269), (35, 14930352), (40, 165580141), (45, 1836311903)]", "body": " result = run_climb_stairs(Solution, n)\n assert_climb_stairs(result, expected)" } ] diff --git a/.templates/leetcode/json/coin_change.json b/.templates/leetcode/json/coin_change.json index 7702878..480f745 100644 --- a/.templates/leetcode/json/coin_change.json +++ b/.templates/leetcode/json/coin_change.json @@ -51,7 +51,7 @@ "name": "test_coin_change", "signature": "(self, coins: list[int], amount: int, expected: int)", "parametrize": "coins, amount, expected", - "test_cases": "[([1, 2, 5], 11, 3), ([2], 3, -1), ([1], 0, 0), ([1, 3, 4], 6, 2), ([2, 5, 10, 1], 27, 4), ([5], 3, -1), ([1], 1, 1), ([1, 2], 2, 1), ([186, 419, 83, 408], 6249, 20)]", + "test_cases": "[([1, 2, 5], 11, 3), ([2], 3, -1), ([1], 0, 0), ([1, 3, 4], 6, 2), ([2, 5, 10, 1], 27, 4), ([5], 3, -1), ([1], 1, 1), ([1, 2], 2, 1), ([186, 419, 83, 408], 6249, 20), ([1, 5, 10, 25], 30, 2), ([2, 3, 5], 9, 3), ([1, 4, 5], 8, 2), ([3, 5], 1, -1), ([1, 2, 5], 100, 20), ([7, 11], 14, 2)]", "body": " result = run_coin_change(Solution, coins, amount)\n assert_coin_change(result, expected)" } ] diff --git a/.templates/leetcode/json/combination_sum.json b/.templates/leetcode/json/combination_sum.json index d7f7e64..44610a1 100644 --- a/.templates/leetcode/json/combination_sum.json +++ b/.templates/leetcode/json/combination_sum.json @@ -53,7 +53,7 @@ "name": "test_combination_sum", "signature": "(self, candidates: list[int], target: int, expected: list[list[int]])", "parametrize": "candidates, target, expected", - "test_cases": "[([2, 3, 6, 7], 7, [[2, 2, 3], [7]]), ([2, 3, 5], 8, [[2, 2, 2, 2], [2, 3, 3], [3, 5]]), ([2], 1, [])]", + "test_cases": "[([2, 3, 6, 7], 7, [[2, 2, 3], [7]]), ([2, 3, 5], 8, [[2, 2, 2, 2], [2, 3, 3], [3, 5]]), ([2], 1, []), ([2, 3], 1, []), ([3, 5], 3, [[3]]), ([2, 4], 6, [[2, 2, 2], [2, 4]]), ([5], 5, [[5]]), ([2, 3, 4], 6, [[2, 2, 2], [2, 4], [3, 3]]), ([4, 2, 8], 8, [[2, 2, 2, 2], [2, 2, 4], [4, 4], [8]]), ([3, 4, 5], 9, [[3, 3, 3], [4, 5]]), ([6, 3, 2], 6, [[2, 2, 2], [3, 3], [6]]), ([2, 7], 9, [[2, 7]])]", "body": " result = run_combination_sum(Solution, candidates, target)\n assert_combination_sum(result, expected)" } ] diff --git a/.templates/leetcode/json/container_with_most_water.json b/.templates/leetcode/json/container_with_most_water.json index 604d452..f07668b 100644 --- a/.templates/leetcode/json/container_with_most_water.json +++ b/.templates/leetcode/json/container_with_most_water.json @@ -50,7 +50,7 @@ "name": "test_max_area", "signature": "(self, height: list[int], expected: int)", "parametrize": "height, expected", - "test_cases": "[([1,8,6,2,5,4,8,3,7], 49), ([1,1], 1), ([1,2,1], 2)]", + "test_cases": "[([1,8,6,2,5,4,8,3,7], 49), ([1,1], 1), ([1,2,1], 2), ([2,1], 1), ([1,2,4,3], 4), ([1,3,2,5,25,24,5], 24), ([2,3,4,5,18,17,6], 17), ([1,2,3,4,5], 6), ([5,4,3,2,1], 6), ([0,2], 0), ([3,9,3,4,7,2,12,6], 45), ([1,0,0,0,0,0,0,2,2], 8)]", "body": " result = run_max_area(Solution, height)\n assert_max_area(result, expected)" } ] diff --git a/.templates/leetcode/json/contains_duplicate.json b/.templates/leetcode/json/contains_duplicate.json index 8b540d0..0601beb 100644 --- a/.templates/leetcode/json/contains_duplicate.json +++ b/.templates/leetcode/json/contains_duplicate.json @@ -53,7 +53,7 @@ "name": "test_contains_duplicate", "signature": "(self, nums: list[int], expected: bool)", "parametrize": "nums, expected", - "test_cases": "[([1, 2, 3, 1], True), ([1, 2, 3, 4], False), ([1, 1, 1, 3, 3, 4, 3, 2, 4, 2], True)]", + "test_cases": "[([1, 2, 3, 1], True), ([1, 2, 3, 4], False), ([1, 1, 1, 3, 3, 4, 3, 2, 4, 2], True), ([1], False), ([1, 1], True), ([0, 0], True), ([-1, -1], True), ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], False), ([10, 9, 8, 7, 6, 5, 4, 3, 2, 1], False), ([1, 2, 3, 4, 5, 1], True), ([-1000000000, 1000000000, -1000000000], True), ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0], True)]", "body": " result = run_contains_duplicate(Solution, nums)\n assert_contains_duplicate(result, expected)" } ] diff --git a/.templates/leetcode/json/course_schedule.json b/.templates/leetcode/json/course_schedule.json index f04589d..f02e646 100644 --- a/.templates/leetcode/json/course_schedule.json +++ b/.templates/leetcode/json/course_schedule.json @@ -52,7 +52,7 @@ "name": "test_can_finish", "signature": "(self, num_courses: int, prerequisites: list[list[int]], expected: bool)", "parametrize": "num_courses, prerequisites, expected", - "test_cases": "[(2, [[1, 0]], True), (2, [[1, 0], [0, 1]], False), (1, [], True), (3, [[1, 0], [2, 1]], True), (4, [[1, 0], [2, 1], [3, 2], [1, 3]], False)]", + "test_cases": "[(2, [[1, 0]], True), (2, [[1, 0], [0, 1]], False), (1, [], True), (3, [[1, 0], [2, 1]], True), (4, [[1, 0], [2, 1], [3, 2], [1, 3]], False), (3, [[0, 1], [0, 2], [1, 2]], True), (4, [[0, 1], [1, 2], [2, 3], [3, 1]], False), (6, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]], True), (3, [[1, 0], [2, 0]], True), (5, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]], False), (4, [[1, 0], [2, 0], [3, 1], [3, 2]], True), (5, [[1, 0], [2, 1], [3, 2], [4, 3], [0, 4]], False)]", "body": " result = run_can_finish(Solution, num_courses, prerequisites)\n assert_can_finish(result, expected)" } ] diff --git a/.templates/leetcode/json/diameter_of_binary_tree.json b/.templates/leetcode/json/diameter_of_binary_tree.json index 37ca4c0..0eec11f 100644 --- a/.templates/leetcode/json/diameter_of_binary_tree.json +++ b/.templates/leetcode/json/diameter_of_binary_tree.json @@ -50,7 +50,7 @@ "name": "test_diameter_of_binary_tree", "signature": "(self, root_list: list[int | None], expected: int)", "parametrize": "root_list, expected", - "test_cases": "[([1, 2, 3, 4, 5], 3), ([1, 2], 1), ([], 0), ([1], 0), ([1, 2, 3], 2), ([1, None, 2], 1)]", + "test_cases": "[([1, 2, 3, 4, 5], 3), ([1, 2], 1), ([], 0), ([1], 0), ([1, 2, 3], 2), ([1, None, 2], 1), ([1, 2, 3, 4, 5, None, None, 6, 7], 4), ([4, 2, 6, 1, 3, 5, 7], 4), ([1, 2, None, 3, None, 4], 3), ([1, 2, 3, None, None, 4, 5, None, None, 6, 7], 4), ([10, 5, 15, 3, 7, 12, 20], 4), ([1, None, 2, None, 3, None, 4], 3)]", "body": " result = run_diameter_of_binary_tree(Solution, root_list)\n assert_diameter_of_binary_tree(result, expected)" } ] diff --git a/.templates/leetcode/json/evaluate_reverse_polish_notation.json b/.templates/leetcode/json/evaluate_reverse_polish_notation.json index 781c301..7d4e83d 100644 --- a/.templates/leetcode/json/evaluate_reverse_polish_notation.json +++ b/.templates/leetcode/json/evaluate_reverse_polish_notation.json @@ -55,7 +55,7 @@ "name": "test_eval_rpn", "signature": "(self, tokens: list[str], expected: int)", "parametrize": "tokens, expected", - "test_cases": "[(['2', '1', '+', '3', '*'], 9), (['4', '13', '5', '/', '+'], 6), (['10', '6', '9', '3', '+', '-11', '*', '/', '*', '17', '+', '5', '+'], 22)]", + "test_cases": "[(['2', '1', '+', '3', '*'], 9), (['4', '13', '5', '/', '+'], 6), (['10', '6', '9', '3', '+', '-11', '*', '/', '*', '17', '+', '5', '+'], 22), (['3'], 3), (['15', '7', '1', '1', '+', '-', '/', '3', '*', '2', '1', '1', '+', '+', '-'], 5), (['2', '1', '+'], 3), (['2', '1', '-'], 1), (['3', '4', '*'], 12), (['8', '2', '/'], 4), (['5', '1', '2', '+', '4', '*', '+', '3', '-'], 14), (['-1', '2', '+'], 1), (['0', '3', '/'], 0), (['18', '6', '/', '3', '/'], 1)]", "body": " result = run_eval_rpn(Solution, tokens)\n assert_eval_rpn(result, expected)" } ] diff --git a/.templates/leetcode/json/first_bad_version.json b/.templates/leetcode/json/first_bad_version.json index 20b50af..0b30e0b 100644 --- a/.templates/leetcode/json/first_bad_version.json +++ b/.templates/leetcode/json/first_bad_version.json @@ -55,7 +55,7 @@ "name": "test_first_bad_version", "signature": "(self, n: int, bad: int, expected: int)", "parametrize": "n, bad, expected", - "test_cases": "[(5, 4, 4), (1, 1, 1), (3, 1, 1), (10, 7, 7), (100, 50, 50), (2, 1, 1), (2, 2, 2), (1000, 1, 1), (1000, 999, 999), (1000, 500, 500)]", + "test_cases": "[(5, 4, 4), (1, 1, 1), (3, 1, 1), (10, 7, 7), (100, 50, 50), (2, 1, 1), (2, 2, 2), (1000, 1, 1), (1000, 999, 999), (1000, 500, 500), (20, 15, 15), (50, 25, 25), (8, 3, 3), (16, 9, 9), (200, 150, 150)]", "body": " result = run_first_bad_version(Solution, n, bad)\n assert_first_bad_version(result, expected)" } ] diff --git a/.templates/leetcode/json/flood_fill.json b/.templates/leetcode/json/flood_fill.json index 4c660d1..a889a3d 100644 --- a/.templates/leetcode/json/flood_fill.json +++ b/.templates/leetcode/json/flood_fill.json @@ -52,7 +52,7 @@ "name": "test_flood_fill", "signature": "(self, image: list[list[int]], sr: int, sc: int, color: int, expected: list[list[int]])", "parametrize": "image, sr, sc, color, expected", - "test_cases": "[([[1, 1, 1], [1, 1, 0], [1, 0, 1]], 1, 1, 2, [[2, 2, 2], [2, 2, 0], [2, 0, 1]]), ([[0, 0, 0], [0, 0, 0]], 0, 0, 0, [[0, 0, 0], [0, 0, 0]]), ([[0, 0, 0], [0, 1, 1]], 1, 1, 1, [[0, 0, 0], [0, 1, 1]]), ([[1, 1, 1], [1, 1, 0], [1, 0, 1]], 1, 1, 1, [[1, 1, 1], [1, 1, 0], [1, 0, 1]])]", + "test_cases": "[([[1, 1, 1], [1, 1, 0], [1, 0, 1]], 1, 1, 2, [[2, 2, 2], [2, 2, 0], [2, 0, 1]]), ([[0, 0, 0], [0, 0, 0]], 0, 0, 0, [[0, 0, 0], [0, 0, 0]]), ([[0, 0, 0], [0, 1, 1]], 1, 1, 1, [[0, 0, 0], [0, 1, 1]]), ([[1, 1, 1], [1, 1, 0], [1, 0, 1]], 1, 1, 1, [[1, 1, 1], [1, 1, 0], [1, 0, 1]]), ([[1]], 0, 0, 2, [[2]]), ([[0, 1], [1, 0]], 0, 0, 3, [[3, 1], [1, 0]]), ([[1, 1], [1, 1]], 0, 0, 2, [[2, 2], [2, 2]]), ([[0, 1, 0], [1, 0, 1], [0, 1, 0]], 1, 1, 2, [[0, 1, 0], [1, 2, 1], [0, 1, 0]]), ([[2, 2, 2], [2, 2, 0], [2, 0, 1]], 0, 0, 3, [[3, 3, 3], [3, 3, 0], [3, 0, 1]]), ([[1, 0, 1], [0, 1, 0], [1, 0, 1]], 1, 1, 5, [[1, 0, 1], [0, 5, 0], [1, 0, 1]]), ([[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]], 1, 1, 2, [[0, 0, 0, 0], [0, 2, 2, 0], [0, 2, 2, 0], [0, 0, 0, 0]]), ([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 1, 1, 0, [[1, 2, 3], [4, 0, 6], [7, 8, 9]])]", "body": " result = run_flood_fill(Solution, image, sr, sc, color)\n assert_flood_fill(result, expected)" } ] diff --git a/.templates/leetcode/json/implement_queue_using_stacks.json b/.templates/leetcode/json/implement_queue_using_stacks.json index a412491..f2adeb5 100644 --- a/.templates/leetcode/json/implement_queue_using_stacks.json +++ b/.templates/leetcode/json/implement_queue_using_stacks.json @@ -67,7 +67,7 @@ "name": "test_queue_operations", "signature": "(self, operations: list[str], inputs: list[list[int]], expected: list[int | None | bool])", "parametrize": "operations, inputs, expected", - "test_cases": "[(['MyQueue', 'push', 'push', 'peek', 'pop', 'empty'], [[], [1], [2], [], [], []], [None, None, None, 1, 1, False]), (['MyQueue', 'empty', 'push', 'peek', 'pop', 'empty'], [[], [], [1], [], [], []], [None, True, None, 1, 1, True]), (['MyQueue', 'push', 'push', 'push', 'pop', 'pop', 'peek', 'pop', 'empty'], [[], [1], [2], [3], [], [], [], [], []], [None, None, None, None, 1, 2, 3, 3, True])]", + "test_cases": "[(['MyQueue', 'push', 'push', 'peek', 'pop', 'empty'], [[], [1], [2], [], [], []], [None, None, None, 1, 1, False]), (['MyQueue', 'empty', 'push', 'peek', 'pop', 'empty'], [[], [], [1], [], [], []], [None, True, None, 1, 1, True]), (['MyQueue', 'push', 'push', 'push', 'pop', 'pop', 'peek', 'pop', 'empty'], [[], [1], [2], [3], [], [], [], [], []], [None, None, None, None, 1, 2, 3, 3, True]), (['MyQueue', 'push', 'peek', 'pop'], [[], [5], [], []], [None, None, 5, 5]), (['MyQueue', 'push', 'push', 'pop', 'push', 'peek'], [[], [1], [2], [], [3], []], [None, None, None, 1, None, 2]), (['MyQueue', 'empty'], [[], []], [None, True]), (['MyQueue', 'push', 'push', 'push', 'push', 'pop', 'pop', 'pop', 'pop', 'empty'], [[], [1], [2], [3], [4], [], [], [], [], []], [None, None, None, None, None, 1, 2, 3, 4, True]), (['MyQueue', 'push', 'pop', 'push', 'pop', 'empty'], [[], [7], [], [8], [], []], [None, None, 7, None, 8, True]), (['MyQueue', 'push', 'push', 'peek', 'peek', 'pop', 'peek'], [[], [9], [8], [], [], [], []], [None, None, None, 9, 9, 9, 8]), (['MyQueue', 'push', 'push', 'push', 'push', 'push', 'pop', 'pop', 'pop', 'push', 'peek'], [[], [1], [2], [3], [4], [5], [], [], [], [6], []], [None, None, None, None, None, None, 1, 2, 3, None, 4]), (['MyQueue', 'push', 'empty', 'pop', 'empty', 'push', 'empty'], [[], [1], [], [], [], [2], []], [None, None, False, 1, True, None, False]), (['MyQueue', 'push', 'push', 'push', 'pop', 'push', 'pop', 'pop', 'push', 'pop'], [[], [1], [2], [3], [], [4], [], [], [5], []], [None, None, None, None, 1, None, 2, 3, None, 4])]", "body": " result, _ = run_my_queue(MyQueue, operations, inputs)\n assert_my_queue(result, expected)" } ] diff --git a/.templates/leetcode/json/implement_trie_prefix_tree.json b/.templates/leetcode/json/implement_trie_prefix_tree.json index dcc8fa0..c800080 100644 --- a/.templates/leetcode/json/implement_trie_prefix_tree.json +++ b/.templates/leetcode/json/implement_trie_prefix_tree.json @@ -20,7 +20,7 @@ "helpers_content": "", "helpers_run_name": "trie_operations", "helpers_run_signature": "(solution_class: type, operations: list[str], inputs: list[list[str]])", - "helpers_run_body": " trie = None\n results: list[bool | None] = []\n for i, op in enumerate(operations):\n if op == 'Trie':\n trie = solution_class()\n results.append(None)\n elif op == 'insert' and trie is not None:\n trie.insert(inputs[i][0])\n results.append(None)\n elif op == 'search' and trie is not None:\n results.append(trie.search(inputs[i][0]))\n elif op == 'starts_with' and trie is not None:\n results.append(trie.starts_with(inputs[i][0]))\n return results, trie", + "helpers_run_body": " trie = None\n results: list[bool | None] = []\n for i, op in enumerate(operations):\n if op == 'Trie':\n trie = solution_class()\n results.append(None)\n elif op == 'insert' and trie is not None:\n trie.insert(inputs[i][0])\n results.append(None)\n elif op == 'search' and trie is not None:\n results.append(trie.search(inputs[i][0]))\n elif op == 'starts_with' and trie is not None:\n results.append(trie.starts_with(inputs[i][0]))\n elif op == 'startsWith' and trie is not None:\n results.append(trie.starts_with(inputs[i][0]))\n return results, trie", "helpers_assert_name": "trie_operations", "helpers_assert_signature": "(result: list[bool | None], expected: list[bool | None]) -> bool", "helpers_assert_body": " assert result == expected\n return True", @@ -62,7 +62,7 @@ "name": "test_trie_operations", "signature": "(self, operations: list[str], inputs: list[list[str]], expected: list[bool | None])", "parametrize": "operations, inputs, expected", - "test_cases": "[(['Trie', 'insert', 'search', 'search', 'starts_with', 'insert', 'search'], [[], ['apple'], ['apple'], ['app'], ['app'], ['app'], ['app']], [None, None, True, False, True, None, True]), (['Trie', 'insert', 'insert', 'search', 'search', 'starts_with', 'starts_with'], [[], ['hello'], ['world'], ['hello'], ['hi'], ['hel'], ['wor']], [None, None, None, True, False, True, True]), (['Trie', 'insert', 'insert', 'search', 'search', 'starts_with', 'starts_with'], [[], ['a'], ['aa'], ['a'], ['aa'], ['a'], ['aa']], [None, None, None, True, True, True, True]), (['Trie', 'insert', 'search', 'starts_with', 'insert', 'search', 'starts_with'], [[], ['test'], ['testing'], ['test'], ['testing'], ['testing'], ['test']], [None, None, False, True, None, True, True]), (['Trie', 'search', 'starts_with'], [[], ['empty'], ['empty']], [None, False, False])]", + "test_cases": "[([\"Trie\", \"insert\", \"insert\", \"search\", \"search\", \"search\"], [[], [\"app\"], [\"apple\"], [\"app\"], [\"apple\"], [\"appl\"]], [None, None, None, True, True, False]), ([\"Trie\", \"insert\", \"insert\", \"insert\", \"search\", \"search\", \"search\"], [[], [\"cat\"], [\"car\"], [\"card\"], [\"cat\"], [\"car\"], [\"care\"]], [None, None, None, None, True, True, False]), ([\"Trie\", \"insert\", \"insert\", \"starts_with\", \"starts_with\", \"starts_with\"], [[], [\"test\"], [\"testing\"], [\"test\"], [\"testing\"], [\"te\"]], [None, None, None, True, True, True]), ([\"Trie\", \"insert\", \"search\", \"search\", \"insert\", \"search\", \"search\"], [[], [\"abc\"], [\"abc\"], [\"ab\"], [\"ab\"], [\"ab\"], [\"abc\"]], [None, None, True, False, None, True, True]), ([\"Trie\", \"insert\", \"search\", \"starts_with\"], [[], [\"a\"], [\"a\"], [\"a\"]], [None, None, True, True]), ([\"Trie\", \"search\", \"starts_with\"], [[], [\"empty\"], [\"empty\"]], [None, False, False]), ([\"Trie\", \"insert\", \"insert\", \"search\", \"search\", \"starts_with\", \"starts_with\"], [[], [\"word\"], [\"world\"], [\"word\"], [\"world\"], [\"wor\"], [\"wo\"]], [None, None, None, True, True, True, True]), ([\"Trie\", \"insert\", \"insert\", \"insert\", \"search\", \"search\", \"search\", \"starts_with\"], [[], [\"aa\"], [\"aaa\"], [\"aaaa\"], [\"aa\"], [\"aaa\"], [\"aaaa\"], [\"a\"]], [None, None, None, None, True, True, True, True]), ([\"Trie\", \"insert\", \"search\", \"search\", \"starts_with\", \"starts_with\"], [[], [\"hello\"], [\"hello\"], [\"hell\"], [\"hello\"], [\"hel\"]], [None, None, True, False, True, True]), ([\"Trie\", \"insert\", \"insert\", \"insert\", \"search\", \"search\", \"search\", \"starts_with\", \"starts_with\"], [[], [\"she\"], [\"sells\"], [\"sea\"], [\"she\"], [\"shells\"], [\"sea\"], [\"se\"], [\"s\"]], [None, None, None, None, True, False, True, True, True]), ([\"Trie\", \"insert\", \"insert\", \"search\", \"search\", \"starts_with\", \"starts_with\", \"starts_with\"], [[], [\"programming\"], [\"program\"], [\"programming\"], [\"program\"], [\"prog\"], [\"programming\"], [\"programm\"]], [None, None, None, True, True, True, True, True]), ([\"Trie\", \"insert\", \"search\", \"starts_with\", \"insert\", \"search\", \"starts_with\"], [[], [\"z\"], [\"z\"], [\"z\"], [\"zzz\"], [\"zzz\"], [\"zz\"]], [None, None, True, True, None, True, True])]", "body": " result, _ = run_trie_operations(Trie, operations, inputs)\n assert_trie_operations(result, expected)" } ] diff --git a/.templates/leetcode/json/insert_interval.json b/.templates/leetcode/json/insert_interval.json index 64e4a18..44280d1 100644 --- a/.templates/leetcode/json/insert_interval.json +++ b/.templates/leetcode/json/insert_interval.json @@ -52,7 +52,7 @@ "name": "test_insert", "signature": "(self, intervals: list[list[int]], new_interval: list[int], expected: list[list[int]])", "parametrize": "intervals, new_interval, expected", - "test_cases": "[([[1,3],[6,9]], [2,5], [[1,5],[6,9]]), ([[1,2],[3,5],[6,7],[8,10],[12,16]], [4,8], [[1,2],[3,10],[12,16]]), ([], [5,7], [[5,7]]), ([[1,5]], [2,3], [[1,5]]), ([[1,5]], [6,8], [[1,5],[6,8]]), ([[1,5]], [0,0], [[0,0],[1,5]]), ([[3,5],[12,15]], [6,6], [[3,5],[6,6],[12,15]])]", + "test_cases": "[([[1,3],[6,9]], [2,5], [[1,5],[6,9]]), ([[1,2],[3,5],[6,7],[8,10],[12,16]], [4,8], [[1,2],[3,10],[12,16]]), ([], [5,7], [[5,7]]), ([[1,5]], [2,3], [[1,5]]), ([[1,5]], [6,8], [[1,5],[6,8]]), ([[1,5]], [0,0], [[0,0],[1,5]]), ([[3,5],[12,15]], [6,6], [[3,5],[6,6],[12,15]]), ([[1,2],[4,5]], [3,3], [[1,2],[3,3],[4,5]]), ([[2,5],[6,7],[8,9]], [0,1], [[0,1],[2,5],[6,7],[8,9]]), ([[1,3],[6,9]], [10,12], [[1,3],[6,9],[10,12]]), ([[1,4],[5,6]], [2,3], [[1,4],[5,6]]), ([[1,2],[3,4],[5,6]], [0,7], [[0,7]]), ([[2,3],[5,6]], [1,4], [[1,4],[5,6]]), ([[1,5],[10,15]], [6,9], [[1,5],[6,9],[10,15]])]", "body": " result = run_insert(Solution, intervals, new_interval)\n assert_insert(result, expected)" } ] diff --git a/.templates/leetcode/json/invert_binary_tree.json b/.templates/leetcode/json/invert_binary_tree.json index d95e35c..b0d5f66 100644 --- a/.templates/leetcode/json/invert_binary_tree.json +++ b/.templates/leetcode/json/invert_binary_tree.json @@ -49,7 +49,7 @@ "name": "test_invert_tree", "signature": "(self, root_list: list[int | None], expected_list: list[int | None])", "parametrize": "root_list, expected_list", - "test_cases": "[([4, 2, 7, 1, 3, 6, 9], [4, 7, 2, 9, 6, 3, 1]), ([2, 1, 3], [2, 3, 1]), ([], []), ([1], [1]), ([1, 2], [1, None, 2]), ([1, None, 2], [1, 2]), ([1, 2, 3, 4, 5], [1, 3, 2, None, None, 5, 4]), ([1, 2, 3, None, None, 4, 5], [1, 3, 2, 5, 4])]", + "test_cases": "[([4, 2, 7, 1, 3, 6, 9], [4, 7, 2, 9, 6, 3, 1]), ([2, 1, 3], [2, 3, 1]), ([], []), ([1], [1]), ([1, 2], [1, None, 2]), ([1, None, 2], [1, 2]), ([1, 2, 3, 4, 5], [1, 3, 2, None, None, 5, 4]), ([1, 2, 3, None, None, 4, 5], [1, 3, 2, 5, 4]), ([1, 2, 3, 4, 5, 6, 7], [1, 3, 2, 7, 6, 5, 4]), ([5, 3, 8, 2, 4, 7, 9], [5, 8, 3, 9, 7, 4, 2]), ([10, 5, 15, None, 6, 12, 20], [10, 15, 5, 20, 12, 6]), ([1, 2, None, 3], [1, None, 2, None, 3]), ([0, -1, 1], [0, 1, -1]), ([100, 50, 150], [100, 150, 50]), ([1, 2, 3, None, 4, None, 5], [1, 3, 2, 5, None, 4])]", "body": " result = run_invert_tree(Solution, root_list)\n assert_invert_tree(result, expected_list)" } ] diff --git a/.templates/leetcode/json/k_closest_points_to_origin.json b/.templates/leetcode/json/k_closest_points_to_origin.json index 8a648e5..d5ebb8f 100644 --- a/.templates/leetcode/json/k_closest_points_to_origin.json +++ b/.templates/leetcode/json/k_closest_points_to_origin.json @@ -52,7 +52,7 @@ "name": "test_k_closest", "signature": "(self, points: list[list[int]], k: int, expected: list[list[int]])", "parametrize": "points, k, expected", - "test_cases": "[([[1, 3], [-2, 2]], 1, [[-2, 2]]), ([[3, 3], [5, -1], [-2, 4]], 2, [[3, 3], [-2, 4]]), ([[0, 1], [1, 0]], 2, [[0, 1], [1, 0]]), ([[1, 1], [1, 1], [1, 1]], 2, [[1, 1], [1, 1]]), ([[0, 0]], 1, [[0, 0]]), ([[1, 0], [2, 0], [3, 0]], 2, [[1, 0], [2, 0]])]", + "test_cases": "[([[1, 3], [-2, 2]], 1, [[-2, 2]]), ([[3, 3], [5, -1], [-2, 4]], 2, [[3, 3], [-2, 4]]), ([[0, 1], [1, 0]], 2, [[0, 1], [1, 0]]), ([[1, 1], [1, 1], [1, 1]], 2, [[1, 1], [1, 1]]), ([[0, 0]], 1, [[0, 0]]), ([[1, 0], [2, 0], [3, 0]], 2, [[1, 0], [2, 0]]), ([[0, 3], [4, 0]], 1, [[0, 3]]), ([[-5, 4], [4, 6], [2, -1]], 1, [[2, -1]]), ([[1, 1], [2, 2], [3, 3]], 1, [[1, 1]]), ([[10, 10], [1, 1], [5, 5]], 2, [[1, 1], [5, 5]]), ([[-1, -1], [1, 1], [-1, 1], [1, -1]], 3, [[-1, 1], [1, -1], [1, 1]]), ([[6, 10], [-3, 3], [-2, 5], [0, 2]], 3, [[-3, 3], [0, 2], [-2, 5]])]", "body": " result = run_k_closest(Solution, points, k)\n assert_k_closest(result, expected)" } ] diff --git a/.templates/leetcode/json/kth_smallest_element_in_a_bst.json b/.templates/leetcode/json/kth_smallest_element_in_a_bst.json index e41818c..0b4f072 100644 --- a/.templates/leetcode/json/kth_smallest_element_in_a_bst.json +++ b/.templates/leetcode/json/kth_smallest_element_in_a_bst.json @@ -52,7 +52,7 @@ "name": "test_kth_smallest", "signature": "(self, root_list: list[int | None], k: int, expected: int)", "parametrize": "root_list, k, expected", - "test_cases": "[([3, 1, 4, None, 2], 1, 1), ([5, 3, 6, 2, 4, None, None, 1], 3, 3), ([1], 1, 1), ([2, 1, 3], 2, 2), ([4, 2, 6, 1, 3, 5, 7], 4, 4), ([1, None, 2], 2, 2)]", + "test_cases": "[([3, 1, 4, None, 2], 1, 1), ([5, 3, 6, 2, 4, None, None, 1], 3, 3), ([1], 1, 1), ([2, 1, 3], 2, 2), ([4, 2, 6, 1, 3, 5, 7], 4, 4), ([1, None, 2], 2, 2), ([5, 3, 6, 2, 4, None, None, 1], 1, 1), ([5, 3, 6, 2, 4, None, None, 1], 4, 4), ([10, 5, 15, 3, 7, 12, 20], 1, 3), ([10, 5, 15, 3, 7, 12, 20], 7, 20), ([1, None, 2, None, 3], 3, 3), ([3, 1, 4, None, 2], 4, 4)]", "body": " result = run_kth_smallest(Solution, root_list, k)\n assert_kth_smallest(result, expected)" } ] diff --git a/.templates/leetcode/json/linked_list_cycle.json b/.templates/leetcode/json/linked_list_cycle.json index eeb89c9..53aefe2 100644 --- a/.templates/leetcode/json/linked_list_cycle.json +++ b/.templates/leetcode/json/linked_list_cycle.json @@ -55,7 +55,7 @@ "name": "test_has_cycle", "signature": "(self, values: list[int], pos: int, expected: bool)", "parametrize": "values, pos, expected", - "test_cases": "[([3, 2, 0, -4], 1, True), ([1, 2], 0, True), ([1], -1, False), ([], -1, False), ([1, 2, 3], -1, False), ([1, 2, 3, 4, 5], 0, True), ([1, 2, 3, 4, 5], 2, True), ([1, 2, 3, 4, 5], 4, True), ([1], 0, True), ([1, 2], 1, True)]", + "test_cases": "[([3, 2, 0, -4], 1, True), ([1, 2], 0, True), ([1], -1, False), ([], -1, False), ([1, 2, 3], -1, False), ([1, 2, 3, 4, 5], 0, True), ([1, 2, 3, 4, 5], 2, True), ([1, 2, 3, 4, 5], 4, True), ([1], 0, True), ([1, 2], 1, True), ([1, 2, 3, 4], -1, False), ([1, 2, 3, 4, 5, 6], 3, True), ([10, 20, 30], 1, True), ([100], -1, False), ([1, 2, 3, 4, 5, 6, 7, 8], 5, True)]", "body": " result = run_has_cycle(Solution, values, pos)\n assert_has_cycle(result, expected)" } ] diff --git a/.templates/leetcode/json/lowest_common_ancestor_of_a_binary_search_tree.json b/.templates/leetcode/json/lowest_common_ancestor_of_a_binary_search_tree.json index fab73c4..e310ef7 100644 --- a/.templates/leetcode/json/lowest_common_ancestor_of_a_binary_search_tree.json +++ b/.templates/leetcode/json/lowest_common_ancestor_of_a_binary_search_tree.json @@ -53,7 +53,7 @@ "name": "test_lowest_common_ancestor", "signature": "(self, root_list: list[int | None], p_val: int, q_val: int, expected_val: int)", "parametrize": "root_list, p_val, q_val, expected_val", - "test_cases": "[([6, 2, 8, 0, 4, 7, 9, None, None, 3, 5], 2, 8, 6), ([6, 2, 8, 0, 4, 7, 9, None, None, 3, 5], 2, 4, 2), ([2, 1], 2, 1, 2), ([2, 1], 1, 2, 2), ([6, 2, 8, 0, 4, 7, 9], 0, 4, 2), ([6, 2, 8, 0, 4, 7, 9], 7, 9, 8)]", + "test_cases": "[([6, 2, 8, 0, 4, 7, 9, None, None, 3, 5], 2, 8, 6), ([6, 2, 8, 0, 4, 7, 9, None, None, 3, 5], 2, 4, 2), ([2, 1], 2, 1, 2), ([2, 1], 1, 2, 2), ([6, 2, 8, 0, 4, 7, 9], 0, 4, 2), ([6, 2, 8, 0, 4, 7, 9], 7, 9, 8), ([5, 3, 6, 2, 4, None, None, 1], 1, 4, 3), ([10, 5, 15, 3, 7, 12, 20], 3, 7, 5), ([1, None, 2], 1, 2, 1), ([3, 1, 4, None, 2], 1, 2, 1), ([20, 8, 22, 4, 12, None, None, None, None, 10, 14], 10, 14, 12), ([50, 30, 70, 20, 40, 60, 80], 20, 40, 30)]", "body": " result = run_lowest_common_ancestor(Solution, root_list, p_val, q_val)\n assert_lowest_common_ancestor(result, expected_val)" } ] diff --git a/.templates/leetcode/json/lowest_common_ancestor_of_a_binary_tree.json b/.templates/leetcode/json/lowest_common_ancestor_of_a_binary_tree.json index c1f4b0e..44c77e2 100644 --- a/.templates/leetcode/json/lowest_common_ancestor_of_a_binary_tree.json +++ b/.templates/leetcode/json/lowest_common_ancestor_of_a_binary_tree.json @@ -53,7 +53,7 @@ "name": "test_lowest_common_ancestor", "signature": "(self, root_list: list[int | None], p_val: int, q_val: int, expected_val: int)", "parametrize": "root_list, p_val, q_val, expected_val", - "test_cases": "[([3,5,1,6,2,0,8,None,None,7,4], 5, 1, 3), ([3,5,1,6,2,0,8,None,None,7,4], 5, 4, 5), ([1,2], 1, 2, 1), ([2,1], 2, 1, 2), ([3,5,1,6,2,0,8,None,None,7,4], 6, 7, 5), ([3,5,1,6,2,0,8,None,None,7,4], 0, 8, 1)]", + "test_cases": "[([3,5,1,6,2,0,8,None,None,7,4], 5, 1, 3), ([3,5,1,6,2,0,8,None,None,7,4], 5, 4, 5), ([1,2], 1, 2, 1), ([2,1], 2, 1, 2), ([3,5,1,6,2,0,8,None,None,7,4], 6, 7, 5), ([3,5,1,6,2,0,8,None,None,7,4], 0, 8, 1), ([1, None, 2, None, 3], 2, 3, 2), ([4, 2, 6, 1, 3, 5, 7], 1, 7, 4), ([10, 5, 15, 3, 7, None, 18], 3, 7, 5), ([1, 2, 3, 4, 5, 6, 7], 4, 5, 2), ([20, 8, 22, 4, 12, None, 25], 4, 12, 8), ([50, 30, 70, 20, 40, 60, 80], 20, 40, 30)]", "body": " result = run_lowest_common_ancestor(Solution, root_list, p_val, q_val)\n assert_lowest_common_ancestor(result, expected_val)" } ] diff --git a/.templates/leetcode/json/lru_cache.json b/.templates/leetcode/json/lru_cache.json index 3bc81d9..2765e1f 100644 --- a/.templates/leetcode/json/lru_cache.json +++ b/.templates/leetcode/json/lru_cache.json @@ -57,7 +57,7 @@ "name": "test_lru_cache", "signature": "(self, operations: list[str], inputs: list[list[int]], expected: list[int | None])", "parametrize": "operations, inputs, expected", - "test_cases": "[(['LRUCache', 'put', 'put', 'get', 'put', 'get', 'put', 'get', 'get', 'get'], [[2], [1, 1], [2, 2], [1], [3, 3], [2], [4, 4], [1], [3], [4]], [None, None, None, 1, None, -1, None, -1, 3, 4]), (['LRUCache', 'get', 'put', 'get', 'put', 'put', 'get', 'get'], [[2], [2], [2, 6], [1], [1, 5], [1, 2], [1], [2]], [None, -1, None, -1, None, None, 2, 6]), (['LRUCache', 'put', 'get', 'put', 'get', 'get'], [[1], [2, 1], [2], [3, 2], [2], [3]], [None, None, 1, None, -1, 2])]", + "test_cases": "[(['LRUCache', 'put', 'put', 'get', 'put', 'get', 'put', 'get', 'get', 'get'], [[2], [1, 1], [2, 2], [1], [3, 3], [2], [4, 4], [1], [3], [4]], [None, None, None, 1, None, -1, None, -1, 3, 4]), (['LRUCache', 'get', 'put', 'get', 'put', 'put', 'get', 'get'], [[2], [2], [2, 6], [1], [1, 5], [1, 2], [1], [2]], [None, -1, None, -1, None, None, 2, 6]), (['LRUCache', 'put', 'get', 'put', 'get', 'get'], [[1], [2, 1], [2], [3, 2], [2], [3]], [None, None, 1, None, -1, 2]), (['LRUCache', 'get'], [[1], [1]], [None, -1]), (['LRUCache', 'put', 'get'], [[1], [1, 100], [1]], [None, None, 100]), (['LRUCache', 'put', 'put', 'get', 'get'], [[2], [1, 1], [2, 2], [1], [2]], [None, None, None, 1, 2]), (['LRUCache', 'put', 'put', 'put', 'get', 'get', 'get'], [[2], [1, 1], [2, 2], [3, 3], [1], [2], [3]], [None, None, None, None, -1, 2, 3]), (['LRUCache', 'put', 'get', 'put', 'get', 'put', 'get'], [[3], [1, 1], [1], [2, 2], [2], [3, 3], [3]], [None, None, 1, None, 2, None, 3]), (['LRUCache', 'put', 'put', 'put', 'put', 'get', 'get'], [[3], [1, 1], [2, 2], [3, 3], [4, 4], [4], [3]], [None, None, None, None, None, 4, 3]), (['LRUCache', 'put', 'put', 'get', 'put', 'get', 'get'], [[2], [2, 1], [1, 1], [2], [4, 1], [1], [2]], [None, None, None, 1, None, -1, 1]), (['LRUCache', 'put', 'put', 'get', 'put', 'put', 'get'], [[2], [2, 1], [2, 2], [2], [1, 1], [4, 1], [2]], [None, None, None, 2, None, None, -1]), (['LRUCache', 'put', 'put', 'put', 'get', 'put', 'get', 'get', 'get', 'get'], [[3], [1, 1], [2, 2], [3, 3], [2], [4, 4], [1], [3], [4], [2]], [None, None, None, None, 2, None, -1, 3, 4, 2])]", "body": " result, _ = run_lru_cache(LRUCache, operations, inputs)\n assert_lru_cache(result, expected)" } ] diff --git a/.templates/leetcode/json/majority_element.json b/.templates/leetcode/json/majority_element.json index 1fc620a..36f438e 100644 --- a/.templates/leetcode/json/majority_element.json +++ b/.templates/leetcode/json/majority_element.json @@ -48,7 +48,7 @@ "name": "test_majority_element", "signature": "(self, nums: list[int], expected: int)", "parametrize": "nums, expected", - "test_cases": "[([3,2,3], 3), ([2,2,1,1,1,2,2], 2), ([1], 1), ([1,1,2], 1), ([2,2,2,1,1], 2), ([5,5,5,5,1,2,3], 5), ([1,2,3,4,4,4,4], 4), ([0,0,0], 0), ([-1,-1,-1,1,1], -1)]", + "test_cases": "[([3,2,3], 3), ([2,2,1,1,1,2,2], 2), ([1], 1), ([1,1,2], 1), ([2,2,2,1,1], 2), ([5,5,5,5,1,2,3], 5), ([1,2,3,4,4,4,4], 4), ([0,0,0], 0), ([-1,-1,-1,1,1], -1), ([100,100,100,99,99], 100), ([7,7,7,7,7,8,8], 7), ([1,1,1,1,1,1,2,2,2], 1), ([9,9,9,9,8,8,8], 9), ([-5,-5,-5,-4,-4], -5), ([1000,1000,999,999,1000], 1000)]", "body": " result = run_majority_element(Solution, nums)\n assert_majority_element(result, expected)" } ] diff --git a/.templates/leetcode/json/maximum_depth_of_binary_tree.json b/.templates/leetcode/json/maximum_depth_of_binary_tree.json index fed5f39..1d62f00 100644 --- a/.templates/leetcode/json/maximum_depth_of_binary_tree.json +++ b/.templates/leetcode/json/maximum_depth_of_binary_tree.json @@ -50,7 +50,7 @@ "name": "test_max_depth", "signature": "(self, root_list: list[int | None], expected: int)", "parametrize": "root_list, expected", - "test_cases": "[([3, 9, 20, None, None, 15, 7], 3), ([1, None, 2], 2), ([], 0), ([1], 1), ([1, 2], 2), ([1, 2, 3], 2), ([1, 2, 3, 4], 3), ([1, None, 2, None, 3], 3)]", + "test_cases": "[([3, 9, 20, None, None, 15, 7], 3), ([1, None, 2], 2), ([], 0), ([1], 1), ([1, 2], 2), ([1, 2, 3], 2), ([1, 2, 3, 4], 3), ([1, None, 2, None, 3], 3), ([1, 2, 3, 4, 5, 6, 7], 3), ([1, 2, None, 4, None, None, None, 8], 3), ([5, 4, 8, 11, None, 13, 4, 7, 2, None, None, None, 1], 4), ([1, 2, 3, None, None, 4, 5, None, None, 6], 4), ([10], 1), ([1, 2, 2, 3, 3, 3, 3], 3), ([0, -1, 1, -2, -1, 0, 2], 3)]", "body": " result = run_max_depth(Solution, root_list)\n assert_max_depth(result, expected)" } ] diff --git a/.templates/leetcode/json/maximum_profit_in_job_scheduling.json b/.templates/leetcode/json/maximum_profit_in_job_scheduling.json index c765195..54c0cd2 100644 --- a/.templates/leetcode/json/maximum_profit_in_job_scheduling.json +++ b/.templates/leetcode/json/maximum_profit_in_job_scheduling.json @@ -55,7 +55,7 @@ "name": "test_job_scheduling", "signature": "(self, start_time: list[int], end_time: list[int], profit: list[int], expected: int)", "parametrize": "start_time, end_time, profit, expected", - "test_cases": "[([1, 2, 3, 3], [3, 4, 5, 6], [50, 10, 40, 70], 120), ([1, 2, 3, 4, 6], [3, 5, 10, 6, 9], [20, 20, 100, 70, 60], 150), ([1, 1, 1], [2, 3, 4], [5, 6, 4], 6), ([1], [2], [100], 100)]", + "test_cases": "[([1, 2, 3, 3], [3, 4, 5, 6], [50, 10, 40, 70], 120), ([1, 2, 3, 4, 6], [3, 5, 10, 6, 9], [20, 20, 100, 70, 60], 150), ([1, 1, 1], [2, 3, 4], [5, 6, 4], 6), ([1, 2], [2, 3], [100, 200], 300), ([6, 15, 7, 11, 1, 3, 16, 2], [19, 18, 19, 16, 10, 8, 19, 8], [2, 9, 1, 19, 5, 7, 3, 19], 41), ([1], [2], [100], 100), ([1, 2, 3], [2, 3, 4], [1, 1, 1], 3), ([1, 3, 6, 7, 8, 12], [4, 5, 10, 11, 12, 16], [20, 20, 100, 70, 60, 120], 240), ([1, 4, 6], [3, 5, 7], [50, 10, 40], 100), ([1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [10, 20, 30, 40, 50], 50), ([5, 4, 3, 2, 1], [6, 5, 4, 3, 2], [1, 2, 3, 4, 5], 15), ([1, 1000000000], [2, 1000000001], [1, 10000], 10001)]", "body": " result = run_job_scheduling(Solution, start_time, end_time, profit)\n assert_job_scheduling(result, expected)" } ] diff --git a/.templates/leetcode/json/maximum_subarray.json b/.templates/leetcode/json/maximum_subarray.json index bb4e76a..8c9bd1b 100644 --- a/.templates/leetcode/json/maximum_subarray.json +++ b/.templates/leetcode/json/maximum_subarray.json @@ -55,7 +55,7 @@ "name": "test_max_sub_array", "signature": "(self, nums: list[int], expected: int)", "parametrize": "nums, expected", - "test_cases": "[([-2, 1, -3, 4, -1, 2, 1, -5, 4], 6), ([1], 1), ([5, 4, -1, 7, 8], 23), ([-1], -1), ([-2, -1], -1), ([1, 2, 3, 4, 5], 15), ([-5, -2, -8, -1], -1)]", + "test_cases": "[([-2, 1, -3, 4, -1, 2, 1, -5, 4], 6), ([1], 1), ([5, 4, -1, 7, 8], 23), ([-1], -1), ([-2, -1], -1), ([1, 2, 3, 4, 5], 15), ([-5, -2, -8, -1], -1), ([0], 0), ([0, -1, 0], 0), ([-3, -2, -1, -5], -1), ([2, -1, 2, -1, 2], 4), ([1, -3, 2, 1, -1], 3), ([-2, -3, 4, -1, -2, 1, 5, -3], 7), ([10, -5, 3, -2, 8], 14), ([100], 100)]", "body": " result = run_max_sub_array(Solution, nums)\n assert_max_sub_array(result, expected)" } ] diff --git a/.templates/leetcode/json/merge_intervals.json b/.templates/leetcode/json/merge_intervals.json index 7c0efbf..606741c 100644 --- a/.templates/leetcode/json/merge_intervals.json +++ b/.templates/leetcode/json/merge_intervals.json @@ -55,7 +55,7 @@ "name": "test_merge", "signature": "(self, intervals: list[list[int]], expected: list[list[int]])", "parametrize": "intervals, expected", - "test_cases": "[([[1,3],[2,6],[8,10],[15,18]], [[1,6],[8,10],[15,18]]), ([[1,4],[4,5]], [[1,5]]), ([[4,7],[1,4]], [[1,7]]), ([[1,3]], [[1,3]]), ([[1,4],[2,3]], [[1,4]]), ([[1,2],[3,4],[5,6]], [[1,2],[3,4],[5,6]])]", + "test_cases": "[([[1,3],[2,6],[8,10],[15,18]], [[1,6],[8,10],[15,18]]), ([[1,4],[4,5]], [[1,5]]), ([[4,7],[1,4]], [[1,7]]), ([[1,3]], [[1,3]]), ([[1,4],[2,3]], [[1,4]]), ([[1,2],[3,4],[5,6]], [[1,2],[3,4],[5,6]]), ([[0,0]], [[0,0]]), ([[1,10],[2,3],[4,5],[6,7],[8,9]], [[1,10]]), ([[1,3],[2,6],[8,10],[9,12],[15,18]], [[1,6],[8,12],[15,18]]), ([[2,3],[4,5],[6,7],[8,9],[1,10]], [[1,10]]), ([[1,4],[0,4]], [[0,4]]), ([[1,4],[0,0],[3,5]], [[0,0],[1,5]])]", "body": " result = run_merge(Solution, intervals)\n assert_merge(result, expected)" } ] diff --git a/.templates/leetcode/json/merge_k_sorted_lists.json b/.templates/leetcode/json/merge_k_sorted_lists.json index 3031430..d85adc6 100644 --- a/.templates/leetcode/json/merge_k_sorted_lists.json +++ b/.templates/leetcode/json/merge_k_sorted_lists.json @@ -51,7 +51,7 @@ "name": "test_merge_k_lists", "signature": "(self, lists_data: list[list[int]], expected_data: list[int])", "parametrize": "lists_data, expected_data", - "test_cases": "[([[1, 4, 5], [1, 3, 4], [2, 6]], [1, 1, 2, 3, 4, 4, 5, 6]), ([], []), ([[]], []), ([[1]], [1]), ([[1, 2], [3, 4]], [1, 2, 3, 4]), ([[5], [1, 3], [2, 4, 6]], [1, 2, 3, 4, 5, 6]), ([[-1, 0, 1], [-2, 2]], [-2, -1, 0, 1, 2]), ([[1, 1, 1], [2, 2, 2]], [1, 1, 1, 2, 2, 2]), ([[], [1], []], [1])]", + "test_cases": "[([[1, 4, 5], [1, 3, 4], [2, 6]], [1, 1, 2, 3, 4, 4, 5, 6]), ([], []), ([[]], []), ([[1]], [1]), ([[1, 2], [3, 4]], [1, 2, 3, 4]), ([[5], [1, 3], [2, 4, 6]], [1, 2, 3, 4, 5, 6]), ([[-1, 0, 1], [-2, 2]], [-2, -1, 0, 1, 2]), ([[1, 1, 1], [2, 2, 2]], [1, 1, 1, 2, 2, 2]), ([[], [1], []], [1]), ([[0, 0, 0], [1, 1, 1]], [0, 0, 0, 1, 1, 1]), ([[10], [5], [1]], [1, 5, 10]), ([[1, 2, 3, 4, 5]], [1, 2, 3, 4, 5]), ([[-10, -5], [-8, -3], [-6, -1]], [-10, -8, -6, -5, -3, -1]), ([[100]], [100]), ([[1, 3, 5], [2, 4, 6], [7, 8, 9]], [1, 2, 3, 4, 5, 6, 7, 8, 9])]", "body": " result = run_merge_k_lists(Solution, lists_data)\n assert_merge_k_lists(result, expected_data)" } ] diff --git a/.templates/leetcode/json/merge_two_sorted_lists.json b/.templates/leetcode/json/merge_two_sorted_lists.json index fe7dfb6..a6f7231 100644 --- a/.templates/leetcode/json/merge_two_sorted_lists.json +++ b/.templates/leetcode/json/merge_two_sorted_lists.json @@ -51,7 +51,7 @@ "name": "test_merge_two_lists", "signature": "(self, list1_vals: list[int], list2_vals: list[int], expected_vals: list[int])", "parametrize": "list1_vals, list2_vals, expected_vals", - "test_cases": "[([1, 2, 4], [1, 3, 4], [1, 1, 2, 3, 4, 4]), ([], [], []), ([], [0], [0]), ([1], [2], [1, 2]), ([2], [1], [1, 2]), ([1, 3, 5], [2, 4, 6], [1, 2, 3, 4, 5, 6]), ([1, 1, 1], [2, 2, 2], [1, 1, 1, 2, 2, 2])]", + "test_cases": "[([1, 2, 4], [1, 3, 4], [1, 1, 2, 3, 4, 4]), ([], [], []), ([], [0], [0]), ([1], [2], [1, 2]), ([2], [1], [1, 2]), ([1, 3, 5], [2, 4, 6], [1, 2, 3, 4, 5, 6]), ([1, 1, 1], [2, 2, 2], [1, 1, 1, 2, 2, 2]), ([0], [], [0]), ([1, 2, 3], [], [1, 2, 3]), ([5], [1, 2, 3, 4], [1, 2, 3, 4, 5]), ([-1, 0, 1], [-2, 2, 3], [-2, -1, 0, 1, 2, 3]), ([1, 5, 9], [2, 6, 8], [1, 2, 5, 6, 8, 9]), ([10, 20, 30], [15, 25, 35], [10, 15, 20, 25, 30, 35]), ([1, 1], [1, 1], [1, 1, 1, 1])]", "body": " result = run_merge_two_lists(Solution, list1_vals, list2_vals)\n assert_merge_two_lists(result, expected_vals)" } ] diff --git a/.templates/leetcode/json/middle_of_the_linked_list.json b/.templates/leetcode/json/middle_of_the_linked_list.json index 9e6b152..f64df0a 100644 --- a/.templates/leetcode/json/middle_of_the_linked_list.json +++ b/.templates/leetcode/json/middle_of_the_linked_list.json @@ -52,7 +52,7 @@ "name": "test_middle_node", "signature": "(self, head_list: list[int], expected_list: list[int])", "parametrize": "head_list, expected_list", - "test_cases": "[([1, 2, 3, 4, 5], [3, 4, 5]), ([1, 2, 3, 4, 5, 6], [4, 5, 6]), ([1], [1]), ([1, 2], [2]), ([1, 2, 3], [2, 3]), ([1, 2, 3, 4], [3, 4]), ([10, 20, 30, 40, 50, 60, 70], [40, 50, 60, 70])]", + "test_cases": "[([1, 2, 3, 4, 5], [3, 4, 5]), ([1, 2, 3, 4, 5, 6], [4, 5, 6]), ([1], [1]), ([1, 2], [2]), ([1, 2, 3], [2, 3]), ([1, 2, 3, 4], [3, 4]), ([10, 20, 30, 40, 50, 60, 70], [40, 50, 60, 70]), ([5, 10], [10]), ([1, 3, 5, 7, 9], [5, 7, 9]), ([2, 4, 6, 8, 10, 12], [8, 10, 12]), ([100], [100]), ([7, 14, 21], [14, 21]), ([11, 22, 33, 44], [33, 44]), ([1, 1, 1, 1, 1], [1, 1, 1])]", "body": " result = run_middle_node(Solution, head_list)\n assert_middle_node(result, expected_list)" } ] diff --git a/.templates/leetcode/json/min_stack.json b/.templates/leetcode/json/min_stack.json index 5e902b9..7ed6490 100644 --- a/.templates/leetcode/json/min_stack.json +++ b/.templates/leetcode/json/min_stack.json @@ -67,7 +67,7 @@ "name": "test_min_stack", "signature": "(self, operations: list[str], inputs: list[list[int]], expected: list[int | None])", "parametrize": "operations, inputs, expected", - "test_cases": "[(['MinStack', 'push', 'push', 'push', 'getMin', 'pop', 'top', 'getMin'], [[], [-2], [0], [-3], [], [], [], []], [None, None, None, None, -3, None, 0, -2]), (['MinStack', 'push', 'top', 'getMin', 'pop'], [[], [5], [], [], []], [None, None, 5, 5, None]), (['MinStack', 'push', 'push', 'push', 'getMin', 'pop', 'getMin', 'pop', 'getMin'], [[], [1], [1], [2], [], [], [], [], []], [None, None, None, None, 1, None, 1, None, 1])]", + "test_cases": "[(['MinStack', 'push', 'push', 'push', 'getMin', 'pop', 'top', 'getMin'], [[], [-2], [0], [-3], [], [], [], []], [None, None, None, None, -3, None, 0, -2]), (['MinStack', 'push', 'top', 'getMin', 'pop'], [[], [5], [], [], []], [None, None, 5, 5, None]), (['MinStack', 'push', 'push', 'push', 'getMin', 'pop', 'getMin', 'pop', 'getMin'], [[], [1], [1], [2], [], [], [], [], []], [None, None, None, None, 1, None, 1, None, 1]), (['MinStack', 'push', 'getMin', 'top'], [[], [0], [], []], [None, None, 0, 0]), (['MinStack', 'push', 'push', 'getMin', 'push', 'getMin', 'pop', 'getMin'], [[], [2], [1], [], [0], [], [], []], [None, None, None, 1, None, 0, None, 1]), (['MinStack', 'push', 'push', 'push', 'top', 'getMin', 'pop', 'pop', 'top', 'getMin'], [[], [3], [1], [4], [], [], [], [], [], []], [None, None, None, None, 4, 1, None, None, 3, 3]), (['MinStack', 'push', 'push', 'getMin', 'pop', 'push', 'getMin'], [[], [-1], [-2], [], [], [0], []], [None, None, None, -2, None, None, -1]), (['MinStack', 'push', 'push', 'push', 'push', 'getMin', 'pop', 'pop', 'getMin'], [[], [5], [3], [7], [2], [], [], [], []], [None, None, None, None, None, 2, None, None, 3]), (['MinStack', 'push', 'push', 'push', 'getMin', 'pop', 'getMin', 'pop', 'getMin', 'pop', 'push', 'getMin'], [[], [10], [5], [15], [], [], [], [], [], [], [8], []], [None, None, None, None, 5, None, 5, None, 10, None, None, 8]), (['MinStack', 'push', 'push', 'push', 'push', 'push', 'getMin', 'pop', 'getMin', 'pop', 'getMin'], [[], [1], [2], [0], [3], [4], [], [], [], [], []], [None, None, None, None, None, None, 0, None, 0, None, 0]), (['MinStack', 'push', 'getMin', 'push', 'getMin', 'push', 'getMin', 'top'], [[], [2147483647], [], [-2147483648], [], [0], [], []], [None, None, 2147483647, None, -2147483648, None, -2147483648, 0]), (['MinStack', 'push', 'push', 'push', 'push', 'push', 'top', 'getMin', 'pop', 'top', 'getMin', 'pop', 'getMin'], [[], [1], [1], [1], [1], [1], [], [], [], [], [], [], []], [None, None, None, None, None, None, 1, 1, None, 1, 1, None, 1])]", "body": " result = run_min_stack_operations(MinStack, operations, inputs)\n assert_min_stack_operations(result, expected)" } ] diff --git a/.templates/leetcode/json/minimum_height_trees.json b/.templates/leetcode/json/minimum_height_trees.json index bc83ead..3378d91 100644 --- a/.templates/leetcode/json/minimum_height_trees.json +++ b/.templates/leetcode/json/minimum_height_trees.json @@ -52,7 +52,7 @@ "name": "test_find_min_height_trees", "signature": "(self, n: int, edges: list[list[int]], expected: list[int])", "parametrize": "n, edges, expected", - "test_cases": "[(4, [[1,0],[1,2],[1,3]], [1]), (6, [[3,0],[3,1],[3,2],[3,4],[5,4]], [3,4]), (1, [], [0]), (2, [[0,1]], [0,1]), (3, [[0,1],[1,2]], [1])]", + "test_cases": "[(4, [[1, 0], [1, 2], [1, 3]], [1]), (6, [[3, 0], [3, 1], [3, 2], [3, 4], [5, 4]], [3, 4]), (1, [], [0]), (2, [[0, 1]], [0, 1]), (3, [[0, 1], [1, 2]], [1]), (5, [[0, 1], [1, 2], [2, 3], [3, 4]], [2]), (7, [[0, 1], [1, 2], [1, 3], [2, 4], [3, 5], [4, 6]], [1, 2]), (6, [[0, 3], [1, 3], [2, 3], [4, 3], [5, 4]], [3, 4]), (10, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]], [4, 5]), (8, [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [6, 7]], [0, 4]), (9, [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8]], [0, 1]), (11, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]], [5])]", "body": " result = run_find_min_height_trees(Solution, n, edges)\n assert_find_min_height_trees(result, expected)" } ] diff --git a/.templates/leetcode/json/minimum_window_substring.json b/.templates/leetcode/json/minimum_window_substring.json index 6a146ad..7032f45 100644 --- a/.templates/leetcode/json/minimum_window_substring.json +++ b/.templates/leetcode/json/minimum_window_substring.json @@ -55,7 +55,7 @@ "name": "test_min_window", "signature": "(self, s: str, t: str, expected: str)", "parametrize": "s, t, expected", - "test_cases": "[(\"ADOBECODEBANC\", \"ABC\", \"BANC\"), (\"a\", \"a\", \"a\"), (\"a\", \"aa\", \"\"), (\"ab\", \"b\", \"b\"), (\"abc\", \"cba\", \"abc\")]", + "test_cases": "[(\"ADOBECODEBANC\", \"ABC\", \"BANC\"), (\"a\", \"a\", \"a\"), (\"a\", \"aa\", \"\"), (\"ab\", \"b\", \"b\"), (\"abc\", \"cba\", \"abc\"), (\"aa\", \"aa\", \"aa\"), (\"a\", \"b\", \"\"), (\"ab\", \"a\", \"a\"), (\"bba\", \"ab\", \"ba\"), (\"acbbaca\", \"aba\", \"baca\"), (\"cabwefgewcwaefgcf\", \"cae\", \"cwae\")]", "body": " result = run_min_window(Solution, s, t)\n assert_min_window(result, expected)" } ] diff --git a/.templates/leetcode/json/number_of_islands.json b/.templates/leetcode/json/number_of_islands.json index d1cf6ef..66f120d 100644 --- a/.templates/leetcode/json/number_of_islands.json +++ b/.templates/leetcode/json/number_of_islands.json @@ -52,7 +52,7 @@ "name": "test_num_islands", "signature": "(self, grid: list[list[str]], expected: int)", "parametrize": "grid, expected", - "test_cases": "[([['1','1','1','1','0'],['1','1','0','1','0'],['1','1','0','0','0'],['0','0','0','0','0']], 1), ([['1','1','0','0','0'],['1','1','0','0','0'],['0','0','1','0','0'],['0','0','0','1','1']], 3), ([['1']], 1), ([['0']], 0), ([['1','0','1'],['0','1','0'],['1','0','1']], 5)]", + "test_cases": "[([[\"1\", \"1\", \"1\", \"1\", \"0\"], [\"1\", \"1\", \"0\", \"1\", \"0\"], [\"1\", \"1\", \"0\", \"0\", \"0\"], [\"0\", \"0\", \"0\", \"0\", \"0\"]], 1), ([[\"1\", \"1\", \"0\", \"0\", \"0\"], [\"1\", \"1\", \"0\", \"0\", \"0\"], [\"0\", \"0\", \"1\", \"0\", \"0\"], [\"0\", \"0\", \"0\", \"1\", \"1\"]], 3), ([[\"1\", \"0\", \"1\", \"1\", \"1\"], [\"1\", \"0\", \"1\", \"0\", \"1\"], [\"1\", \"1\", \"1\", \"0\", \"1\"]], 1), ([[\"0\", \"0\", \"0\", \"0\", \"0\"], [\"0\", \"0\", \"0\", \"0\", \"0\"], [\"0\", \"0\", \"0\", \"0\", \"0\"]], 0), ([[\"1\", \"1\", \"1\"], [\"0\", \"1\", \"0\"], [\"1\", \"1\", \"1\"]], 1), ([[\"1\"]], 1), ([[\"0\"]], 0), ([[\"1\", \"0\"], [\"0\", \"1\"]], 2), ([[\"1\", \"1\"], [\"1\", \"1\"]], 1), ([[\"1\", \"0\", \"1\"], [\"0\", \"1\", \"0\"], [\"1\", \"0\", \"1\"]], 5), ([[\"1\", \"1\", \"0\"], [\"0\", \"0\", \"1\"], [\"0\", \"1\", \"1\"]], 2), ([[\"1\", \"0\", \"0\", \"1\"], [\"0\", \"1\", \"1\", \"0\"], [\"0\", \"1\", \"1\", \"0\"], [\"1\", \"0\", \"0\", \"1\"]], 5), ([[\"0\", \"1\", \"0\"], [\"1\", \"0\", \"1\"], [\"0\", \"1\", \"0\"]], 4), ([[\"1\", \"1\", \"1\", \"1\"], [\"1\", \"0\", \"0\", \"1\"], [\"1\", \"1\", \"1\", \"1\"]], 1)]", "body": " result = run_num_islands(Solution, grid)\n assert_num_islands(result, expected)" } ] diff --git a/.templates/leetcode/json/partition_equal_subset_sum.json b/.templates/leetcode/json/partition_equal_subset_sum.json index da63474..64fa8db 100644 --- a/.templates/leetcode/json/partition_equal_subset_sum.json +++ b/.templates/leetcode/json/partition_equal_subset_sum.json @@ -52,7 +52,7 @@ "name": "test_can_partition", "signature": "(self, nums: list[int], expected: bool)", "parametrize": "nums, expected", - "test_cases": "[([1, 5, 11, 5], True), ([1, 2, 3, 5], False), ([1, 1], True), ([1], False), ([2, 2, 1, 1], True), ([100], False), ([1, 2, 5], False)]", + "test_cases": "[([1, 5, 11, 5], True), ([1, 2, 3, 5], False), ([1, 1], True), ([1], False), ([2, 2, 1, 1], True), ([100], False), ([1, 2, 5], False), ([1, 3, 5, 7], True), ([2, 2, 3, 5], False), ([1, 2, 3, 4, 5, 6, 7], True), ([3, 3, 3, 4, 5], True), ([1, 1, 1, 1], True), ([23, 13, 11, 7, 6, 5, 5], True), ([1, 5, 3], False), ([4, 4, 4, 4, 4, 4], True)]", "body": " result = run_can_partition(Solution, nums)\n assert_can_partition(result, expected)" } ] diff --git a/.templates/leetcode/json/permutations.json b/.templates/leetcode/json/permutations.json index 081332d..cb974c4 100644 --- a/.templates/leetcode/json/permutations.json +++ b/.templates/leetcode/json/permutations.json @@ -51,7 +51,7 @@ "name": "test_permute", "signature": "(self, nums: list[int], expected: list[list[int]])", "parametrize": "nums, expected", - "test_cases": "[([1, 2, 3], [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]), ([0, 1], [[0, 1], [1, 0]]), ([1], [[1]]), ([2, 1], [[2, 1], [1, 2]])]", + "test_cases": "[([1, 2, 3], [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]), ([0, 1], [[0, 1], [1, 0]]), ([1], [[1]]), ([2, 1], [[2, 1], [1, 2]]), ([0], [[0]]), ([-1, 0], [[-1, 0], [0, -1]]), ([1, 2], [[1, 2], [2, 1]]), ([3, 2, 1], [[3, 2, 1], [3, 1, 2], [2, 3, 1], [2, 1, 3], [1, 3, 2], [1, 2, 3]]), ([-1, 1], [[-1, 1], [1, -1]]), ([5, 4, 3, 2], [[5, 4, 3, 2], [5, 4, 2, 3], [5, 3, 4, 2], [5, 3, 2, 4], [5, 2, 4, 3], [5, 2, 3, 4], [4, 5, 3, 2], [4, 5, 2, 3], [4, 3, 5, 2], [4, 3, 2, 5], [4, 2, 5, 3], [4, 2, 3, 5], [3, 5, 4, 2], [3, 5, 2, 4], [3, 4, 5, 2], [3, 4, 2, 5], [3, 2, 5, 4], [3, 2, 4, 5], [2, 5, 4, 3], [2, 5, 3, 4], [2, 4, 5, 3], [2, 4, 3, 5], [2, 3, 5, 4], [2, 3, 4, 5]]), ([0, -1, 1], [[0, -1, 1], [0, 1, -1], [-1, 0, 1], [-1, 1, 0], [1, 0, -1], [1, -1, 0]]), ([10, -10], [[10, -10], [-10, 10]])]", "body": " result = run_permute(Solution, nums)\n assert_permute(result, expected)" } ] diff --git a/.templates/leetcode/json/product_of_array_except_self.json b/.templates/leetcode/json/product_of_array_except_self.json index d99aa69..d698e0c 100644 --- a/.templates/leetcode/json/product_of_array_except_self.json +++ b/.templates/leetcode/json/product_of_array_except_self.json @@ -48,7 +48,7 @@ "name": "test_product_except_self", "signature": "(self, nums: list[int], expected: list[int])", "parametrize": "nums, expected", - "test_cases": "[([1, 2, 3, 4], [24, 12, 8, 6]), ([-1, 1, 0, -3, 3], [0, 0, 9, 0, 0]), ([2, 3, 4, 5], [60, 40, 30, 24]), ([1, 1], [1, 1]), ([5, 2], [2, 5]), ([0, 1, 2, 3], [6, 0, 0, 0]), ([1, 0, 3, 4], [0, 12, 0, 0])]", + "test_cases": "[([1, 2, 3, 4], [24, 12, 8, 6]), ([-1, 1, 0, -3, 3], [0, 0, 9, 0, 0]), ([2, 3, 4, 5], [60, 40, 30, 24]), ([1, 1], [1, 1]), ([5, 2], [2, 5]), ([0, 1, 2, 3], [6, 0, 0, 0]), ([1, 0, 3, 4], [0, 12, 0, 0]), ([-1, -2, -3], [6, 3, 2]), ([2, 2, 2], [4, 4, 4]), ([10, 3, 5, 6, 2], [180, 600, 360, 300, 900]), ([0, 0], [0, 0]), ([1, 2, 0, 4], [0, 0, 8, 0]), ([-2, 0, -3, 4], [0, 24, 0, 0]), ([7, 1, 3], [3, 21, 7]), ([4, 5, 1, 8, 2], [80, 64, 320, 40, 160])]", "body": " result = run_product_except_self(Solution, nums)\n assert_product_except_self(result, expected)" } ] diff --git a/.templates/leetcode/json/reverse_linked_list.json b/.templates/leetcode/json/reverse_linked_list.json index 2166957..9ea3b51 100644 --- a/.templates/leetcode/json/reverse_linked_list.json +++ b/.templates/leetcode/json/reverse_linked_list.json @@ -53,7 +53,7 @@ "name": "test_reverse_list", "signature": "(self, head_list: list[int], expected_list: list[int])", "parametrize": "head_list, expected_list", - "test_cases": "[([1, 2, 3, 4, 5], [5, 4, 3, 2, 1]), ([1, 2], [2, 1]), ([1], [1]), ([], []), ([1, 2, 3], [3, 2, 1]), ([1, 2, 3, 4], [4, 3, 2, 1]), ([-1, -2, -3], [-3, -2, -1]), ([0], [0]), ([5000, -5000], [-5000, 5000]), ([1, 1, 1], [1, 1, 1])]", + "test_cases": "[([1, 2, 3, 4, 5], [5, 4, 3, 2, 1]), ([1, 2], [2, 1]), ([1], [1]), ([], []), ([1, 2, 3], [3, 2, 1]), ([1, 2, 3, 4], [4, 3, 2, 1]), ([-1, -2, -3], [-3, -2, -1]), ([0], [0]), ([5000, -5000], [-5000, 5000]), ([1, 1, 1], [1, 1, 1]), ([10, 20, 30, 40, 50, 60], [60, 50, 40, 30, 20, 10]), ([-100, 0, 100], [100, 0, -100]), ([7], [7]), ([1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1]), ([42, 42, 42, 42], [42, 42, 42, 42])]", "body": " result = run_reverse_list(Solution, head_list)\n assert_reverse_list(result, expected_list)" } ] diff --git a/.templates/leetcode/json/reverse_linked_list_ii.json b/.templates/leetcode/json/reverse_linked_list_ii.json index 2efc947..75d9318 100644 --- a/.templates/leetcode/json/reverse_linked_list_ii.json +++ b/.templates/leetcode/json/reverse_linked_list_ii.json @@ -50,7 +50,7 @@ "name": "test_reverse_between", "signature": "(self, head_list: list[int], left: int, right: int, expected_list: list[int])", "parametrize": "head_list, left, right, expected_list", - "test_cases": "[([1, 2, 3, 4, 5], 2, 4, [1, 4, 3, 2, 5]), ([5], 1, 1, [5]), ([1, 2], 1, 2, [2, 1]), ([1, 2, 3], 1, 3, [3, 2, 1]), ([1, 2, 3, 4, 5], 1, 5, [5, 4, 3, 2, 1]), ([1, 2, 3, 4, 5], 3, 3, [1, 2, 3, 4, 5])]", + "test_cases": "[([1, 2, 3, 4, 5], 2, 4, [1, 4, 3, 2, 5]), ([5], 1, 1, [5]), ([1, 2], 1, 2, [2, 1]), ([1, 2, 3], 1, 3, [3, 2, 1]), ([1, 2, 3, 4, 5], 1, 5, [5, 4, 3, 2, 1]), ([1, 2, 3, 4, 5], 3, 3, [1, 2, 3, 4, 5]), ([1, 2, 3, 4], 2, 3, [1, 3, 2, 4]), ([1, 2, 3, 4, 5, 6], 3, 5, [1, 2, 5, 4, 3, 6]), ([10], 1, 1, [10]), ([1, 2, 3, 4, 5, 6, 7], 1, 7, [7, 6, 5, 4, 3, 2, 1]), ([3, 5], 1, 1, [3, 5]), ([7, 9, 2, 10, 1, 8, 6], 4, 6, [7, 9, 2, 8, 1, 10, 6])]", "body": " result = run_reverse_between(Solution, head_list, left, right)\n assert_reverse_between(result, expected_list)" } ] diff --git a/.templates/leetcode/json/search_in_rotated_sorted_array.json b/.templates/leetcode/json/search_in_rotated_sorted_array.json index 9f2165b..b20a54c 100644 --- a/.templates/leetcode/json/search_in_rotated_sorted_array.json +++ b/.templates/leetcode/json/search_in_rotated_sorted_array.json @@ -49,7 +49,7 @@ "name": "test_search", "signature": "(self, nums: list[int], target: int, expected: int)", "parametrize": "nums, target, expected", - "test_cases": "[([4, 5, 6, 7, 0, 1, 2], 0, 4), ([4, 5, 6, 7, 0, 1, 2], 3, -1), ([1], 0, -1), ([1], 1, 0), ([3, 1], 1, 1), ([1, 3], 3, 1), ([2, 1], 2, 0), ([5, 1, 3], 3, 2), ([4, 5, 6, 7, 8, 1, 2, 3], 8, 4)]", + "test_cases": "[([4, 5, 6, 7, 0, 1, 2], 0, 4), ([4, 5, 6, 7, 0, 1, 2], 3, -1), ([1], 0, -1), ([1], 1, 0), ([3, 1], 1, 1), ([1, 3], 3, 1), ([2, 1], 2, 0), ([5, 1, 3], 3, 2), ([4, 5, 6, 7, 8, 1, 2, 3], 8, 4), ([6, 7, 0, 1, 2, 3, 4, 5], 6, 0), ([7, 0, 1, 2, 3, 4, 5, 6], 7, 0), ([0, 1, 2, 3, 4, 5, 6, 7], 4, 4), ([3, 4, 5, 6, 7, 0, 1, 2], 2, 7), ([9, 0, 2, 7, 8], 3, -1), ([8, 9, 2, 3, 4], 9, 1)]", "body": " result = run_search(Solution, nums, target)\n assert_search(result, expected)" } ] diff --git a/.templates/leetcode/json/serialize_and_deserialize_binary_tree.json b/.templates/leetcode/json/serialize_and_deserialize_binary_tree.json index 552c8b7..e45c6e4 100644 --- a/.templates/leetcode/json/serialize_and_deserialize_binary_tree.json +++ b/.templates/leetcode/json/serialize_and_deserialize_binary_tree.json @@ -58,7 +58,7 @@ "name": "test_serialize_deserialize", "signature": "(self, root_list: list[int | None])", "parametrize": "root_list", - "test_cases": "[([1, 2, 3, None, None, 4, 5]), ([]), ([1]), ([1, 2]), ([1, None, 2]), ([1, 2, 3, 4, 5, 6, 7]), ([5, 2, 3, None, None, 2, 4, 3, 1])]", + "test_cases": "[([1, 2, 3, None, None, 4, 5]), ([]), ([1]), ([1, 2]), ([1, None, 2]), ([1, 2, 3, 4, 5, 6, 7]), ([5, 2, 3, None, None, 2, 4, 3, 1]), ([1, 2, 3]), ([1, None, None]), ([1, 2, None, 4]), ([1, None, 2, None, 3]), ([10, 5, 15, None, 6, 12, 20]), ([0, -1, 1]), ([100]), ([1, 2, 3, 4, None, None, 7, 8])]", "body": " result = run_serialize_deserialize(Codec, root_list)\n assert_serialize_deserialize(result, root_list)" } ] diff --git a/.templates/leetcode/json/sort_colors.json b/.templates/leetcode/json/sort_colors.json index 3525a54..6633cb0 100644 --- a/.templates/leetcode/json/sort_colors.json +++ b/.templates/leetcode/json/sort_colors.json @@ -48,7 +48,7 @@ "name": "test_sort_colors", "signature": "(self, nums: list[int], expected: list[int])", "parametrize": "nums, expected", - "test_cases": "[([2, 0, 2, 1, 1, 0], [0, 0, 1, 1, 2, 2]), ([2, 0, 1], [0, 1, 2]), ([0], [0]), ([1], [1]), ([2], [2]), ([0, 1, 2], [0, 1, 2]), ([2, 2, 2], [2, 2, 2]), ([0, 0, 0], [0, 0, 0]), ([1, 1, 1], [1, 1, 1])]", + "test_cases": "[([2, 0, 2, 1, 1, 0], [0, 0, 1, 1, 2, 2]), ([2, 0, 1], [0, 1, 2]), ([0], [0]), ([1], [1]), ([2], [2]), ([0, 1, 2], [0, 1, 2]), ([2, 2, 2], [2, 2, 2]), ([0, 0, 0], [0, 0, 0]), ([1, 1, 1], [1, 1, 1]), ([2, 1, 0], [0, 1, 2]), ([1, 0, 2, 1, 0, 2], [0, 0, 1, 1, 2, 2]), ([0, 2, 1, 0, 2, 1], [0, 0, 1, 1, 2, 2]), ([2, 2, 1, 0, 0, 1], [0, 0, 1, 1, 2, 2]), ([1, 2, 0, 1, 2, 0, 1], [0, 0, 1, 1, 1, 2, 2]), ([0, 1, 0, 2, 1, 2, 0], [0, 0, 0, 1, 1, 2, 2])]", "body": " result = run_sort_colors(Solution, nums)\n assert_sort_colors(result, expected)" } ] diff --git a/.templates/leetcode/json/spiral_matrix.json b/.templates/leetcode/json/spiral_matrix.json index db80ac1..355427b 100644 --- a/.templates/leetcode/json/spiral_matrix.json +++ b/.templates/leetcode/json/spiral_matrix.json @@ -52,7 +52,7 @@ "name": "test_spiral_order", "signature": "(self, matrix: list[list[int]], expected: list[int])", "parametrize": "matrix, expected", - "test_cases": "[([[1,2,3],[4,5,6],[7,8,9]], [1,2,3,6,9,8,7,4,5]), ([[1,2,3,4],[5,6,7,8],[9,10,11,12]], [1,2,3,4,8,12,11,10,9,5,6,7]), ([[1]], [1]), ([[1,2]], [1,2]), ([[1],[2]], [1,2]), ([[1,2,3]], [1,2,3]), ([[1],[2],[3]], [1,2,3])]", + "test_cases": "[([[1,2,3],[4,5,6],[7,8,9]], [1,2,3,6,9,8,7,4,5]), ([[1,2,3,4],[5,6,7,8],[9,10,11,12]], [1,2,3,4,8,12,11,10,9,5,6,7]), ([[1]], [1]), ([[1,2]], [1,2]), ([[1],[2]], [1,2]), ([[1,2,3]], [1,2,3]), ([[1],[2],[3]], [1,2,3]), ([[1,2],[3,4]], [1,2,4,3]), ([[1,2,3,4,5]], [1,2,3,4,5]), ([[1],[2],[3],[4],[5]], [1,2,3,4,5]), ([[1,2,3],[4,5,6]], [1,2,3,6,5,4]), ([[1,2],[3,4],[5,6]], [1,2,4,6,5,3]), ([[7,9,6],[2,8,6],[1,3,5]], [7,9,6,6,5,3,1,2,8]), ([[1,2,3,4],[5,6,7,8]], [1,2,3,4,8,7,6,5])]", "body": " result = run_spiral_order(Solution, matrix)\n assert_spiral_order(result, expected)" } ] diff --git a/.templates/leetcode/json/task_scheduler.json b/.templates/leetcode/json/task_scheduler.json index 908512f..a416607 100644 --- a/.templates/leetcode/json/task_scheduler.json +++ b/.templates/leetcode/json/task_scheduler.json @@ -55,7 +55,7 @@ "name": "test_least_interval", "signature": "(self, tasks: list[str], n: int, expected: int)", "parametrize": "tasks, n, expected", - "test_cases": "[(['A', 'A', 'A', 'B', 'B', 'B'], 2, 8), (['A', 'C', 'A', 'B', 'D', 'B'], 1, 6), (['A', 'A', 'A', 'B', 'B', 'B'], 3, 10), (['A'], 0, 1), (['A', 'A'], 1, 3), (['A', 'B'], 0, 2)]", + "test_cases": "[(['A', 'A', 'A', 'B', 'B', 'B'], 2, 8), (['A', 'C', 'A', 'B', 'D', 'B'], 1, 6), (['A', 'A', 'A', 'B', 'B', 'B'], 3, 10), (['A'], 0, 1), (['A', 'A'], 1, 3), (['A', 'B'], 0, 2), (['A', 'A', 'A'], 0, 3), (['A', 'B', 'C', 'D', 'E', 'F'], 2, 6), (['A', 'A', 'A', 'A', 'A', 'A', 'B', 'C', 'D', 'E', 'F', 'G'], 2, 16), (['A', 'A', 'B', 'B'], 2, 5), (['A', 'B', 'A', 'B'], 1, 4), (['A', 'A', 'A', 'A'], 3, 13)]", "body": " result = run_least_interval(Solution, tasks, n)\n assert_least_interval(result, expected)" } ] diff --git a/.templates/leetcode/json/three_sum.json b/.templates/leetcode/json/three_sum.json index e80a8d6..2f099e1 100644 --- a/.templates/leetcode/json/three_sum.json +++ b/.templates/leetcode/json/three_sum.json @@ -55,7 +55,7 @@ "name": "test_three_sum", "signature": "(self, nums: list[int], expected: list[list[int]])", "parametrize": "nums, expected", - "test_cases": "[([-1, 0, 1, 2, -1, -4], [[-1, -1, 2], [-1, 0, 1]]), ([0, 1, 1], []), ([0, 0, 0], [[0, 0, 0]]), ([-1, 0, 1], [[-1, 0, 1]]), ([1, 2, -2, -1], []), ([-2, 0, 1, 1, 2], [[-2, 0, 2], [-2, 1, 1]])]", + "test_cases": "[([-1, 0, 1, 2, -1, -4], [[-1, -1, 2], [-1, 0, 1]]), ([0, 1, 1], []), ([0, 0, 0], [[0, 0, 0]]), ([-1, 0, 1], [[-1, 0, 1]]), ([1, 2, -2, -1], []), ([-2, 0, 1, 1, 2], [[-2, 0, 2], [-2, 1, 1]]), ([1, -1, -1, 0], [[-1, 0, 1]]), ([-4, -2, -2, -2, 0, 1, 2, 2, 2, 3, 3, 4, 4, 6, 6], [[-4, -2, 6], [-4, 0, 4], [-4, 1, 3], [-4, 2, 2], [-2, -2, 4], [-2, 0, 2]]), ([3, 0, -2, -1, 1, 2], [[-2, -1, 3], [-2, 0, 2], [-1, 0, 1]]), ([0, 0, 0, 0], [[0, 0, 0]]), ([-1, -1, 2], [[-1, -1, 2]]), ([1, 1, -2], [[-2, 1, 1]])]", "body": " result = run_three_sum(Solution, nums)\n assert_three_sum(result, expected)" } ] diff --git a/.templates/leetcode/json/trapping_rain_water.json b/.templates/leetcode/json/trapping_rain_water.json index 5b44338..4a21e57 100644 --- a/.templates/leetcode/json/trapping_rain_water.json +++ b/.templates/leetcode/json/trapping_rain_water.json @@ -50,7 +50,7 @@ "name": "test_trap", "signature": "(self, height: list[int], expected: int)", "parametrize": "height, expected", - "test_cases": "[([0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1], 6), ([4, 2, 0, 3, 2, 5], 9), ([3, 0, 2, 0, 4], 7), ([0], 0), ([1], 0), ([1, 2], 0), ([2, 1], 0)]", + "test_cases": "[([0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1], 6), ([4, 2, 0, 3, 2, 5], 9), ([3, 0, 2, 0, 4], 7), ([0], 0), ([1], 0), ([1, 2], 0), ([2, 1], 0), ([3, 2, 0, 4], 4), ([5, 4, 1, 2], 1), ([2, 0, 2], 2), ([1, 0, 1], 1), ([0, 2, 0], 0), ([1, 2, 1], 0), ([5, 2, 7, 2, 6, 1, 5, 3, 2, 1], 11), ([0, 0, 0, 0], 0)]", "body": " result = run_trap(Solution, height)\n assert_trap(result, expected)" } ] diff --git a/.templates/leetcode/json/valid_palindrome.json b/.templates/leetcode/json/valid_palindrome.json index 3e264eb..4f84dc9 100644 --- a/.templates/leetcode/json/valid_palindrome.json +++ b/.templates/leetcode/json/valid_palindrome.json @@ -55,7 +55,7 @@ "name": "test_is_palindrome", "signature": "(self, s: str, expected: bool)", "parametrize": "s, expected", - "test_cases": "[(\"A man, a plan, a canal: Panama\", True), (\"race a car\", False), (\" \", True), (\"\", True), (\"a\", True), (\"Madam\", True), (\"No 'x' in Nixon\", True), (\"Mr. Owl ate my metal worm\", True)]", + "test_cases": "[(\"A man, a plan, a canal: Panama\", True), (\"race a car\", False), (\" \", True), (\"\", True), (\"a\", True), (\"Madam\", True), (\"No 'x' in Nixon\", True), (\"Mr. Owl ate my metal worm\", True), (\"Was it a car or a cat I saw?\", True), (\"Madam, I'm Adam\", True), (\"Never odd or even\", True), (\"Do geese see God?\", True), (\"Step on no pets\", True), (\"12321\", True), (\"hello\", False), (\"ab\", False)]", "body": " result = run_is_palindrome(Solution, s)\n assert_is_palindrome(result, expected)" } ] diff --git a/.templates/leetcode/json/valid_parentheses.json b/.templates/leetcode/json/valid_parentheses.json index cc3c986..554ca10 100644 --- a/.templates/leetcode/json/valid_parentheses.json +++ b/.templates/leetcode/json/valid_parentheses.json @@ -51,7 +51,7 @@ "name": "test_is_valid", "signature": "(self, s: str, expected: bool)", "parametrize": "s, expected", - "test_cases": "[('()', True), ('()[]{}', True), ('(]', False), ('([])', True), ('([)]', False), ('', True), ('(', False), (')', False), ('{[()]}', True), ('{[(])}', False)]", + "test_cases": "[('()', True), ('()[]{}', True), ('(]', False), ('([])', True), ('([)]', False), ('', True), ('(', False), (')', False), ('{[()]}', True), ('{[(])}', False), ('((', False), ('))', False), ('([{}])', True), ('([{]})', False), ('{[}]', False), ('((()))', True), ('((())', False), ('(){}[]', True), ('{[(', False), (']})', False)]", "body": " result = run_is_valid(Solution, s)\n assert_is_valid(result, expected)" } ] diff --git a/.templates/leetcode/json/validate_binary_search_tree.json b/.templates/leetcode/json/validate_binary_search_tree.json index ef141e2..b0202c1 100644 --- a/.templates/leetcode/json/validate_binary_search_tree.json +++ b/.templates/leetcode/json/validate_binary_search_tree.json @@ -52,7 +52,7 @@ "name": "test_is_valid_bst", "signature": "(self, root_list: list[int | None], expected: bool)", "parametrize": "root_list, expected", - "test_cases": "[([2, 1, 3], True), ([5, 1, 4, None, None, 3, 6], False), ([1], True), ([1, 1], False), ([10, 5, 15, None, None, 6, 20], False), ([2, 1, 3, None, None, None, 4], True)]", + "test_cases": "[([2, 1, 3], True), ([5, 1, 4, None, None, 3, 6], False), ([1], True), ([1, 1], False), ([10, 5, 15, None, None, 6, 20], False), ([2, 1, 3, None, None, None, 4], True), ([0], True), ([2147483647], True), ([-2147483648], True), ([5, 4, 6, None, None, 3, 7], False), ([10, 5, 15, None, None, 12, 20, None, None, None, None, 6, 25], True), ([3, 1, 5, 0, 2, 4, 6], True)]", "body": " result = run_is_valid_bst(Solution, root_list)\n assert_is_valid_bst(result, expected)" } ] diff --git a/.templates/leetcode/json/word_break.json b/.templates/leetcode/json/word_break.json index 1a0f5c0..28a1de4 100644 --- a/.templates/leetcode/json/word_break.json +++ b/.templates/leetcode/json/word_break.json @@ -55,7 +55,7 @@ "name": "test_word_break", "signature": "(self, s: str, word_dict: list[str], expected: bool)", "parametrize": "s, word_dict, expected", - "test_cases": "[('leetcode', ['leet', 'code'], True), ('applepenapple', ['apple', 'pen'], True), ('catsandog', ['cats', 'dog', 'sand', 'and', 'cat'], False), ('', [], True), ('a', ['a'], True), ('ab', ['a', 'b'], True), ('abcd', ['a', 'abc', 'd'], True)]", + "test_cases": "[('leetcode', ['leet', 'code'], True), ('applepenapple', ['apple', 'pen'], True), ('catsandog', ['cats', 'dog', 'sand', 'and', 'cat'], False), ('', [], True), ('a', ['a'], True), ('ab', ['a', 'b'], True), ('abcd', ['a', 'abc', 'd'], True), ('aaaaaaa', ['aaaa', 'aaa'], True), ('aaaaaaa', ['aaaa', 'aa'], False), ('cars', ['car', 'ca', 'rs'], True), ('raceacar', ['race', 'a', 'car'], True), ('abcdef', ['abc', 'def'], True), ('abcdef', ['ab', 'cd', 'ef'], True), ('goalspecial', ['go', 'goal', 'goals', 'special'], True), ('bb', ['a', 'b', 'bbb', 'bbbb'], True)]", "body": " result = run_word_break(Solution, s, word_dict)\n assert_word_break(result, expected)" } ] diff --git a/.templates/leetcode/json/word_ladder.json b/.templates/leetcode/json/word_ladder.json index 78cf3f5..216257a 100644 --- a/.templates/leetcode/json/word_ladder.json +++ b/.templates/leetcode/json/word_ladder.json @@ -52,7 +52,7 @@ "name": "test_ladder_length", "signature": "(self, begin_word: str, end_word: str, word_list: list[str], expected: int)", "parametrize": "begin_word, end_word, word_list, expected", - "test_cases": "[('hit', 'cog', ['hot', 'dot', 'dog', 'lot', 'log', 'cog'], 5), ('hit', 'cog', ['hot', 'dot', 'dog', 'lot', 'log'], 0), ('a', 'c', ['a', 'b', 'c'], 2), ('hot', 'dog', ['hot', 'dog'], 0), ('hot', 'dog', ['hot', 'hog', 'dog'], 3)]", + "test_cases": "[(\"hit\", \"cog\", [\"hot\", \"dot\", \"dog\", \"lot\", \"log\", \"cog\"], 5), (\"hit\", \"cog\", [\"hot\", \"dot\", \"dog\", \"lot\", \"log\"], 0), (\"a\", \"c\", [\"a\", \"b\", \"c\"], 2), (\"hot\", \"dog\", [\"hot\", \"dog\"], 0), (\"hot\", \"dog\", [\"hot\", \"hog\", \"dog\"], 3), (\"red\", \"tax\", [\"ted\", \"tex\", \"red\", \"tax\", \"tad\", \"den\", \"rex\", \"pee\"], 4), (\"talk\", \"tail\", [\"talk\", \"tons\", \"fall\", \"tail\", \"gale\", \"hall\", \"negs\"], 0), (\"qa\", \"sq\", [\"si\", \"go\", \"se\", \"cm\", \"so\", \"ph\", \"mt\", \"db\", \"mb\", \"sb\", \"kr\", \"ln\", \"tm\", \"le\", \"av\", \"sm\", \"ar\", \"ci\", \"ca\", \"br\", \"ti\", \"ba\", \"to\", \"ra\", \"fa\", \"yo\", \"ow\", \"sn\", \"ya\", \"cr\", \"po\", \"fe\", \"ho\", \"ma\", \"re\", \"or\", \"rn\", \"au\", \"ur\", \"rh\", \"sr\", \"tc\", \"lt\", \"lo\", \"as\", \"fr\", \"nb\", \"yb\", \"if\", \"pb\", \"ge\", \"th\", \"pm\", \"rb\", \"sh\", \"co\", \"ga\", \"li\", \"ha\", \"hz\", \"no\", \"bi\", \"di\", \"hi\", \"qa\", \"pi\", \"os\", \"uh\", \"wm\", \"an\", \"me\", \"mo\", \"na\", \"la\", \"st\", \"er\", \"sc\", \"ne\", \"mn\", \"mi\", \"am\", \"ex\", \"pt\", \"io\", \"be\", \"fm\", \"ta\", \"tb\", \"ni\", \"mr\", \"pa\", \"he\", \"lr\", \"sq\", \"ye\"], 5), (\"cet\", \"ism\", [\"kid\", \"tag\", \"pup\", \"ail\", \"tun\", \"woo\"], 0), (\"lost\", \"miss\", [\"most\", \"mist\", \"miss\", \"lost\", \"fist\", \"fish\"], 4), (\"cat\", \"dog\", [\"bat\", \"bag\", \"dag\", \"dog\", \"cat\"], 5), (\"game\", \"thee\", [\"frye\", \"heat\", \"tree\", \"thee\", \"game\", \"free\"], 0), (\"teach\", \"place\", [\"peale\", \"wilts\", \"place\", \"fetch\"], 0), (\"sail\", \"boat\", [\"bail\", \"foil\", \"coat\", \"boat\", \"sail\"], 0), (\"cold\", \"warm\", [\"cold\", \"cord\", \"word\", \"ward\", \"warm\"], 5)]", "body": " result = run_ladder_length(Solution, begin_word, end_word, word_list)\n assert_ladder_length(result, expected)" } ] diff --git a/.templates/leetcode/json/zero_one_matrix.json b/.templates/leetcode/json/zero_one_matrix.json index 81ab126..f0bac0c 100644 --- a/.templates/leetcode/json/zero_one_matrix.json +++ b/.templates/leetcode/json/zero_one_matrix.json @@ -52,7 +52,7 @@ "name": "test_update_matrix", "signature": "(self, mat: list[list[int]], expected: list[list[int]])", "parametrize": "mat, expected", - "test_cases": "[([[0, 0, 0], [0, 1, 0], [0, 0, 0]], [[0, 0, 0], [0, 1, 0], [0, 0, 0]]), ([[0, 0, 0], [0, 1, 0], [1, 1, 1]], [[0, 0, 0], [0, 1, 0], [1, 2, 1]]), ([[0]], [[0]]), ([[1, 0]], [[1, 0]])]", + "test_cases": "[([[0, 0, 0], [0, 1, 0], [0, 0, 0]], [[0, 0, 0], [0, 1, 0], [0, 0, 0]]), ([[0, 0, 0], [0, 1, 0], [1, 1, 1]], [[0, 0, 0], [0, 1, 0], [1, 2, 1]]), ([[0]], [[0]]), ([[1, 0]], [[1, 0]]), ([[1, 1], [1, 0]], [[2, 1], [1, 0]]), ([[0, 1, 0], [1, 1, 1], [0, 1, 0]], [[0, 1, 0], [1, 2, 1], [0, 1, 0]]), ([[1, 0, 1], [1, 1, 1], [1, 1, 1]], [[1, 0, 1], [2, 1, 2], [3, 2, 3]]), ([[0, 1, 0, 0], [1, 1, 1, 0], [1, 1, 1, 0]], [[0, 1, 0, 0], [1, 2, 1, 0], [2, 2, 1, 0]]), ([[1, 1, 1], [1, 1, 1], [1, 1, 0]], [[4, 3, 2], [3, 2, 1], [2, 1, 0]]), ([[0, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]], [[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5]]), ([[1, 0, 0], [1, 1, 0], [1, 1, 1]], [[1, 0, 0], [2, 1, 0], [3, 2, 1]]), ([[0, 0, 1], [0, 1, 1], [1, 1, 1]], [[0, 0, 1], [0, 1, 2], [1, 2, 3]]), ([[1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 1]], [[2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]])]", "body": " result = run_update_matrix(Solution, mat)\n assert_update_matrix(result, expected)" } ] diff --git a/leetcode/accounts_merge/test_solution.py b/leetcode/accounts_merge/test_solution.py index 5b98579..fc73296 100644 --- a/leetcode/accounts_merge/test_solution.py +++ b/leetcode/accounts_merge/test_solution.py @@ -44,7 +44,6 @@ def setup_method(self): ], ), ([["John", "john@mail.com"]], [["John", "john@mail.com"]]), - ([["John"]], [["John"]]), ( [["John", "john1@mail.com"], ["John", "john2@mail.com"], ["John", "john3@mail.com"]], [["John", "john1@mail.com"], ["John", "john2@mail.com"], ["John", "john3@mail.com"]], @@ -65,7 +64,44 @@ def setup_method(self): ], [["Alice", "alice1@mail.com", "alice2@mail.com", "alice3@mail.com", "alice@mail.com"]], ), - ([["John", "shared@mail.com"], ["Jane", "shared@mail.com"]], [["John", "shared@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"]], + ), ], ) def test_accounts_merge(self, accounts: list[list[str]], expected: list[list[str]]): diff --git a/leetcode/balanced_binary_tree/test_solution.py b/leetcode/balanced_binary_tree/test_solution.py index 08eaaa8..97000d1 100644 --- a/leetcode/balanced_binary_tree/test_solution.py +++ b/leetcode/balanced_binary_tree/test_solution.py @@ -22,6 +22,13 @@ def setup_method(self): ([1, None, 2], True), ([1, 2, 3, 4], True), ([1, 2, 2, 3, None, None, 3, 4, None, None, 4], False), + ([1, 2, 3], True), + ([1, 2, None, 3], False), + ([1, None, 2, None, 3], False), + ([1, 2, 3, 4, 5, 6, 7], True), + ([1, 2, 3, None, None, 4, None, None, 5], False), + ([5, 1, 4, None, None, 3, 6], True), + ([1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, None, None, 5, 5], True), ], ) def test_is_balanced(self, root_list: list[int | None], expected: bool): diff --git a/leetcode/best_time_to_buy_and_sell_stock/test_solution.py b/leetcode/best_time_to_buy_and_sell_stock/test_solution.py index d889ade..4ed9be5 100644 --- a/leetcode/best_time_to_buy_and_sell_stock/test_solution.py +++ b/leetcode/best_time_to_buy_and_sell_stock/test_solution.py @@ -22,6 +22,13 @@ def setup_method(self): ([2, 1], 0), ([1, 2], 1), ([3, 2, 6, 5, 0, 3], 4), + ([2, 4, 1], 2), + ([1, 5, 3, 6, 4], 5), + ([10, 1, 5, 6, 7, 1], 6), + ([6, 1, 3, 2, 4, 7], 6), + ([1, 4, 2], 3), + ([3, 3, 5, 0, 0, 3, 1, 4], 4), + ([2, 1, 2, 1, 0, 1, 2], 2), ], ) def test_max_profit(self, prices: list[int], expected: int): diff --git a/leetcode/binary_tree_right_side_view/test_solution.py b/leetcode/binary_tree_right_side_view/test_solution.py index 1da8582..2a1ca50 100644 --- a/leetcode/binary_tree_right_side_view/test_solution.py +++ b/leetcode/binary_tree_right_side_view/test_solution.py @@ -3,7 +3,7 @@ from leetcode_py.test_utils import logged_test from .helpers import assert_right_side_view, run_right_side_view -from .solution import Solution, SolutionBFS, SolutionDFS +from .solution import Solution class TestBinaryTreeRightSideView: @@ -11,7 +11,6 @@ def setup_method(self): self.solution = Solution() @logged_test - @pytest.mark.parametrize("solution_class", [Solution, SolutionBFS, SolutionDFS]) @pytest.mark.parametrize( "root_list, expected", [ @@ -22,10 +21,15 @@ def setup_method(self): ([1], [1]), ([1, 2], [1, 2]), ([1, None, 2], [1, 2]), + ([1, 2, 3], [1, 3]), + ([1, 2, None, 4], [1, 2, 4]), + ([1, 2, 3, 4, 5, 6, 7], [1, 3, 7]), + ([1, 2, 3, None, None, 4, 5], [1, 3, 5]), + ([5, 4, 6, None, None, None, 7], [5, 6, 7]), + ([1, 2, 3, 4, 5, None, None, 8], [1, 3, 5, 8]), + ([10, 5, 15, None, 6, 12, 20], [10, 15, 20]), ], ) - def test_right_side_view( - self, solution_class: type, root_list: list[int | None], expected: list[int] - ): - result = run_right_side_view(solution_class, root_list) + def test_right_side_view(self, root_list: list[int | None], expected: list[int]): + result = run_right_side_view(Solution, root_list) assert_right_side_view(result, expected) diff --git a/leetcode/climbing_stairs/test_solution.py b/leetcode/climbing_stairs/test_solution.py index 7e80934..a141b4e 100644 --- a/leetcode/climbing_stairs/test_solution.py +++ b/leetcode/climbing_stairs/test_solution.py @@ -13,7 +13,25 @@ def setup_method(self): @logged_test @pytest.mark.parametrize( "n, expected", - [(1, 1), (2, 2), (3, 3), (4, 5), (5, 8), (6, 13), (10, 89), (20, 10946), (45, 1836311903)], + [ + (1, 1), + (2, 2), + (3, 3), + (4, 5), + (5, 8), + (6, 13), + (7, 21), + (8, 34), + (9, 55), + (10, 89), + (15, 987), + (20, 10946), + (25, 121393), + (30, 1346269), + (35, 14930352), + (40, 165580141), + (45, 1836311903), + ], ) def test_climb_stairs(self, n: int, expected: int): result = run_climb_stairs(Solution, n) diff --git a/leetcode/coin_change/test_solution.py b/leetcode/coin_change/test_solution.py index a49a846..62eede4 100644 --- a/leetcode/coin_change/test_solution.py +++ b/leetcode/coin_change/test_solution.py @@ -23,6 +23,12 @@ def setup_method(self): ([1], 1, 1), ([1, 2], 2, 1), ([186, 419, 83, 408], 6249, 20), + ([1, 5, 10, 25], 30, 2), + ([2, 3, 5], 9, 3), + ([1, 4, 5], 8, 2), + ([3, 5], 1, -1), + ([1, 2, 5], 100, 20), + ([7, 11], 14, 2), ], ) def test_coin_change(self, coins: list[int], amount: int, expected: int): diff --git a/leetcode/combination_sum/test_solution.py b/leetcode/combination_sum/test_solution.py index 3bbe52b..de34df9 100644 --- a/leetcode/combination_sum/test_solution.py +++ b/leetcode/combination_sum/test_solution.py @@ -17,6 +17,15 @@ def setup_method(self): ([2, 3, 6, 7], 7, [[2, 2, 3], [7]]), ([2, 3, 5], 8, [[2, 2, 2, 2], [2, 3, 3], [3, 5]]), ([2], 1, []), + ([2, 3], 1, []), + ([3, 5], 3, [[3]]), + ([2, 4], 6, [[2, 2, 2], [2, 4]]), + ([5], 5, [[5]]), + ([2, 3, 4], 6, [[2, 2, 2], [2, 4], [3, 3]]), + ([4, 2, 8], 8, [[2, 2, 2, 2], [2, 2, 4], [4, 4], [8]]), + ([3, 4, 5], 9, [[3, 3, 3], [4, 5]]), + ([6, 3, 2], 6, [[2, 2, 2], [3, 3], [6]]), + ([2, 7], 9, [[2, 7]]), ], ) def test_combination_sum(self, candidates: list[int], target: int, expected: list[list[int]]): diff --git a/leetcode/container_with_most_water/test_solution.py b/leetcode/container_with_most_water/test_solution.py index 4ac5842..c2bf0e1 100644 --- a/leetcode/container_with_most_water/test_solution.py +++ b/leetcode/container_with_most_water/test_solution.py @@ -12,7 +12,21 @@ def setup_method(self): @logged_test @pytest.mark.parametrize( - "height, expected", [([1, 8, 6, 2, 5, 4, 8, 3, 7], 49), ([1, 1], 1), ([1, 2, 1], 2)] + "height, expected", + [ + ([1, 8, 6, 2, 5, 4, 8, 3, 7], 49), + ([1, 1], 1), + ([1, 2, 1], 2), + ([2, 1], 1), + ([1, 2, 4, 3], 4), + ([1, 3, 2, 5, 25, 24, 5], 24), + ([2, 3, 4, 5, 18, 17, 6], 17), + ([1, 2, 3, 4, 5], 6), + ([5, 4, 3, 2, 1], 6), + ([0, 2], 0), + ([3, 9, 3, 4, 7, 2, 12, 6], 45), + ([1, 0, 0, 0, 0, 0, 0, 2, 2], 8), + ], ) def test_max_area(self, height: list[int], expected: int): result = run_max_area(Solution, height) diff --git a/leetcode/contains_duplicate/test_solution.py b/leetcode/contains_duplicate/test_solution.py index 5eaa35a..e8c2c7e 100644 --- a/leetcode/contains_duplicate/test_solution.py +++ b/leetcode/contains_duplicate/test_solution.py @@ -13,7 +13,20 @@ def setup_method(self): @logged_test @pytest.mark.parametrize( "nums, expected", - [([1, 2, 3, 1], True), ([1, 2, 3, 4], False), ([1, 1, 1, 3, 3, 4, 3, 2, 4, 2], True)], + [ + ([1, 2, 3, 1], True), + ([1, 2, 3, 4], False), + ([1, 1, 1, 3, 3, 4, 3, 2, 4, 2], True), + ([1], False), + ([1, 1], True), + ([0, 0], True), + ([-1, -1], True), + ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], False), + ([10, 9, 8, 7, 6, 5, 4, 3, 2, 1], False), + ([1, 2, 3, 4, 5, 1], True), + ([-1000000000, 1000000000, -1000000000], True), + ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0], True), + ], ) def test_contains_duplicate(self, nums: list[int], expected: bool): result = run_contains_duplicate(Solution, nums) diff --git a/leetcode/course_schedule/test_solution.py b/leetcode/course_schedule/test_solution.py index 2fc24fc..35aae35 100644 --- a/leetcode/course_schedule/test_solution.py +++ b/leetcode/course_schedule/test_solution.py @@ -19,6 +19,13 @@ def setup_method(self): (1, [], True), (3, [[1, 0], [2, 1]], True), (4, [[1, 0], [2, 1], [3, 2], [1, 3]], False), + (3, [[0, 1], [0, 2], [1, 2]], True), + (4, [[0, 1], [1, 2], [2, 3], [3, 1]], False), + (6, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]], True), + (3, [[1, 0], [2, 0]], True), + (5, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]], False), + (4, [[1, 0], [2, 0], [3, 1], [3, 2]], True), + (5, [[1, 0], [2, 1], [3, 2], [4, 3], [0, 4]], False), ], ) def test_can_finish(self, num_courses: int, prerequisites: list[list[int]], expected: bool): diff --git a/leetcode/diameter_of_binary_tree/test_solution.py b/leetcode/diameter_of_binary_tree/test_solution.py index 1abc301..11468a0 100644 --- a/leetcode/diameter_of_binary_tree/test_solution.py +++ b/leetcode/diameter_of_binary_tree/test_solution.py @@ -13,7 +13,20 @@ def setup_method(self): @logged_test @pytest.mark.parametrize( "root_list, expected", - [([1, 2, 3, 4, 5], 3), ([1, 2], 1), ([], 0), ([1], 0), ([1, 2, 3], 2), ([1, None, 2], 1)], + [ + ([1, 2, 3, 4, 5], 3), + ([1, 2], 1), + ([], 0), + ([1], 0), + ([1, 2, 3], 2), + ([1, None, 2], 1), + ([1, 2, 3, 4, 5, None, None, 6, 7], 4), + ([4, 2, 6, 1, 3, 5, 7], 4), + ([1, 2, None, 3, None, 4], 3), + ([1, 2, 3, None, None, 4, 5, None, None, 6, 7], 4), + ([10, 5, 15, 3, 7, 12, 20], 4), + ([1, None, 2, None, 3, None, 4], 3), + ], ) def test_diameter_of_binary_tree(self, root_list: list[int | None], expected: int): result = run_diameter_of_binary_tree(Solution, root_list) diff --git a/leetcode/evaluate_reverse_polish_notation/test_solution.py b/leetcode/evaluate_reverse_polish_notation/test_solution.py index e422248..244730f 100644 --- a/leetcode/evaluate_reverse_polish_notation/test_solution.py +++ b/leetcode/evaluate_reverse_polish_notation/test_solution.py @@ -17,6 +17,16 @@ def setup_method(self): (["2", "1", "+", "3", "*"], 9), (["4", "13", "5", "/", "+"], 6), (["10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+"], 22), + (["3"], 3), + (["15", "7", "1", "1", "+", "-", "/", "3", "*", "2", "1", "1", "+", "+", "-"], 5), + (["2", "1", "+"], 3), + (["2", "1", "-"], 1), + (["3", "4", "*"], 12), + (["8", "2", "/"], 4), + (["5", "1", "2", "+", "4", "*", "+", "3", "-"], 14), + (["-1", "2", "+"], 1), + (["0", "3", "/"], 0), + (["18", "6", "/", "3", "/"], 1), ], ) def test_eval_rpn(self, tokens: list[str], expected: int): diff --git a/leetcode/first_bad_version/test_solution.py b/leetcode/first_bad_version/test_solution.py index 12f25a5..3ea5446 100644 --- a/leetcode/first_bad_version/test_solution.py +++ b/leetcode/first_bad_version/test_solution.py @@ -24,6 +24,11 @@ def setup_method(self): (1000, 1, 1), (1000, 999, 999), (1000, 500, 500), + (20, 15, 15), + (50, 25, 25), + (8, 3, 3), + (16, 9, 9), + (200, 150, 150), ], ) def test_first_bad_version(self, n: int, bad: int, expected: int): diff --git a/leetcode/flood_fill/test_solution.py b/leetcode/flood_fill/test_solution.py index ee4a476..c9703c3 100644 --- a/leetcode/flood_fill/test_solution.py +++ b/leetcode/flood_fill/test_solution.py @@ -18,6 +18,20 @@ def setup_method(self): ([[0, 0, 0], [0, 0, 0]], 0, 0, 0, [[0, 0, 0], [0, 0, 0]]), ([[0, 0, 0], [0, 1, 1]], 1, 1, 1, [[0, 0, 0], [0, 1, 1]]), ([[1, 1, 1], [1, 1, 0], [1, 0, 1]], 1, 1, 1, [[1, 1, 1], [1, 1, 0], [1, 0, 1]]), + ([[1]], 0, 0, 2, [[2]]), + ([[0, 1], [1, 0]], 0, 0, 3, [[3, 1], [1, 0]]), + ([[1, 1], [1, 1]], 0, 0, 2, [[2, 2], [2, 2]]), + ([[0, 1, 0], [1, 0, 1], [0, 1, 0]], 1, 1, 2, [[0, 1, 0], [1, 2, 1], [0, 1, 0]]), + ([[2, 2, 2], [2, 2, 0], [2, 0, 1]], 0, 0, 3, [[3, 3, 3], [3, 3, 0], [3, 0, 1]]), + ([[1, 0, 1], [0, 1, 0], [1, 0, 1]], 1, 1, 5, [[1, 0, 1], [0, 5, 0], [1, 0, 1]]), + ( + [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]], + 1, + 1, + 2, + [[0, 0, 0, 0], [0, 2, 2, 0], [0, 2, 2, 0], [0, 0, 0, 0]], + ), + ([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 1, 1, 0, [[1, 2, 3], [4, 0, 6], [7, 8, 9]]), ], ) def test_flood_fill( diff --git a/leetcode/implement_queue_using_stacks/test_solution.py b/leetcode/implement_queue_using_stacks/test_solution.py index 3363ac1..24520ea 100644 --- a/leetcode/implement_queue_using_stacks/test_solution.py +++ b/leetcode/implement_queue_using_stacks/test_solution.py @@ -27,6 +27,43 @@ class TestImplementQueueUsingStacks: [[], [1], [2], [3], [], [], [], [], []], [None, None, None, None, 1, 2, 3, 3, True], ), + (["MyQueue", "push", "peek", "pop"], [[], [5], [], []], [None, None, 5, 5]), + ( + ["MyQueue", "push", "push", "pop", "push", "peek"], + [[], [1], [2], [], [3], []], + [None, None, None, 1, None, 2], + ), + (["MyQueue", "empty"], [[], []], [None, True]), + ( + ["MyQueue", "push", "push", "push", "push", "pop", "pop", "pop", "pop", "empty"], + [[], [1], [2], [3], [4], [], [], [], [], []], + [None, None, None, None, None, 1, 2, 3, 4, True], + ), + ( + ["MyQueue", "push", "pop", "push", "pop", "empty"], + [[], [7], [], [8], [], []], + [None, None, 7, None, 8, True], + ), + ( + ["MyQueue", "push", "push", "peek", "peek", "pop", "peek"], + [[], [9], [8], [], [], [], []], + [None, None, None, 9, 9, 9, 8], + ), + ( + ["MyQueue", "push", "push", "push", "push", "push", "pop", "pop", "pop", "push", "peek"], + [[], [1], [2], [3], [4], [5], [], [], [], [6], []], + [None, None, None, None, None, None, 1, 2, 3, None, 4], + ), + ( + ["MyQueue", "push", "empty", "pop", "empty", "push", "empty"], + [[], [1], [], [], [], [2], []], + [None, None, False, 1, True, None, False], + ), + ( + ["MyQueue", "push", "push", "push", "pop", "push", "pop", "pop", "push", "pop"], + [[], [1], [2], [3], [], [4], [], [], [5], []], + [None, None, None, None, 1, None, 2, 3, None, 4], + ), ], ) def test_queue_operations( diff --git a/leetcode/implement_trie_prefix_tree/test_solution.py b/leetcode/implement_trie_prefix_tree/test_solution.py index 48a4c13..272e9bd 100644 --- a/leetcode/implement_trie_prefix_tree/test_solution.py +++ b/leetcode/implement_trie_prefix_tree/test_solution.py @@ -13,26 +13,93 @@ class TestImplementTriePrefixTree: "operations, inputs, expected", [ ( - ["Trie", "insert", "search", "search", "starts_with", "insert", "search"], - [[], ["apple"], ["apple"], ["app"], ["app"], ["app"], ["app"]], - [None, None, True, False, True, None, True], + ["Trie", "insert", "insert", "search", "search", "search"], + [[], ["app"], ["apple"], ["app"], ["apple"], ["appl"]], + [None, None, None, True, True, False], ), ( - ["Trie", "insert", "insert", "search", "search", "starts_with", "starts_with"], - [[], ["hello"], ["world"], ["hello"], ["hi"], ["hel"], ["wor"]], - [None, None, None, True, False, True, True], + ["Trie", "insert", "insert", "insert", "search", "search", "search"], + [[], ["cat"], ["car"], ["card"], ["cat"], ["car"], ["care"]], + [None, None, None, None, True, True, False], + ), + ( + ["Trie", "insert", "insert", "starts_with", "starts_with", "starts_with"], + [[], ["test"], ["testing"], ["test"], ["testing"], ["te"]], + [None, None, None, True, True, True], + ), + ( + ["Trie", "insert", "search", "search", "insert", "search", "search"], + [[], ["abc"], ["abc"], ["ab"], ["ab"], ["ab"], ["abc"]], + [None, None, True, False, None, True, True], + ), + ( + ["Trie", "insert", "search", "starts_with"], + [[], ["a"], ["a"], ["a"]], + [None, None, True, True], + ), + ( + ["Trie", "search", "starts_with"], + [[], ["empty"], ["empty"]], + [None, False, False], ), ( ["Trie", "insert", "insert", "search", "search", "starts_with", "starts_with"], - [[], ["a"], ["aa"], ["a"], ["aa"], ["a"], ["aa"]], + [[], ["word"], ["world"], ["word"], ["world"], ["wor"], ["wo"]], [None, None, None, True, True, True, True], ), + ( + ["Trie", "insert", "insert", "insert", "search", "search", "search", "starts_with"], + [[], ["aa"], ["aaa"], ["aaaa"], ["aa"], ["aaa"], ["aaaa"], ["a"]], + [None, None, None, None, True, True, True, True], + ), + ( + ["Trie", "insert", "search", "search", "starts_with", "starts_with"], + [[], ["hello"], ["hello"], ["hell"], ["hello"], ["hel"]], + [None, None, True, False, True, True], + ), + ( + [ + "Trie", + "insert", + "insert", + "insert", + "search", + "search", + "search", + "starts_with", + "starts_with", + ], + [[], ["she"], ["sells"], ["sea"], ["she"], ["shells"], ["sea"], ["se"], ["s"]], + [None, None, None, None, True, False, True, True, True], + ), + ( + [ + "Trie", + "insert", + "insert", + "search", + "search", + "starts_with", + "starts_with", + "starts_with", + ], + [ + [], + ["programming"], + ["program"], + ["programming"], + ["program"], + ["prog"], + ["programming"], + ["programm"], + ], + [None, None, None, True, True, True, True, True], + ), ( ["Trie", "insert", "search", "starts_with", "insert", "search", "starts_with"], - [[], ["test"], ["testing"], ["test"], ["testing"], ["testing"], ["test"]], - [None, None, False, True, None, True, True], + [[], ["z"], ["z"], ["z"], ["zzz"], ["zzz"], ["zz"]], + [None, None, True, True, None, True, True], ), - (["Trie", "search", "starts_with"], [[], ["empty"], ["empty"]], [None, False, False]), ], ) def test_trie_operations( diff --git a/leetcode/insert_interval/test_solution.py b/leetcode/insert_interval/test_solution.py index 7e83e00..a7ab73d 100644 --- a/leetcode/insert_interval/test_solution.py +++ b/leetcode/insert_interval/test_solution.py @@ -21,6 +21,13 @@ def setup_method(self): ([[1, 5]], [6, 8], [[1, 5], [6, 8]]), ([[1, 5]], [0, 0], [[0, 0], [1, 5]]), ([[3, 5], [12, 15]], [6, 6], [[3, 5], [6, 6], [12, 15]]), + ([[1, 2], [4, 5]], [3, 3], [[1, 2], [3, 3], [4, 5]]), + ([[2, 5], [6, 7], [8, 9]], [0, 1], [[0, 1], [2, 5], [6, 7], [8, 9]]), + ([[1, 3], [6, 9]], [10, 12], [[1, 3], [6, 9], [10, 12]]), + ([[1, 4], [5, 6]], [2, 3], [[1, 4], [5, 6]]), + ([[1, 2], [3, 4], [5, 6]], [0, 7], [[0, 7]]), + ([[2, 3], [5, 6]], [1, 4], [[1, 4], [5, 6]]), + ([[1, 5], [10, 15]], [6, 9], [[1, 5], [6, 9], [10, 15]]), ], ) def test_insert( diff --git a/leetcode/invert_binary_tree/test_solution.py b/leetcode/invert_binary_tree/test_solution.py index 9e8cf8e..f20e784 100644 --- a/leetcode/invert_binary_tree/test_solution.py +++ b/leetcode/invert_binary_tree/test_solution.py @@ -3,7 +3,7 @@ from leetcode_py.test_utils import logged_test from .helpers import assert_invert_tree, run_invert_tree -from .solution import Solution, SolutionBFS, SolutionDFS +from .solution import Solution class TestInvertBinaryTree: @@ -11,7 +11,6 @@ def setup_method(self): self.solution = Solution() @logged_test - @pytest.mark.parametrize("solution_class", [Solution, SolutionDFS, SolutionBFS]) @pytest.mark.parametrize( "root_list, expected_list", [ @@ -23,10 +22,15 @@ def setup_method(self): ([1, None, 2], [1, 2]), ([1, 2, 3, 4, 5], [1, 3, 2, None, None, 5, 4]), ([1, 2, 3, None, None, 4, 5], [1, 3, 2, 5, 4]), + ([1, 2, 3, 4, 5, 6, 7], [1, 3, 2, 7, 6, 5, 4]), + ([5, 3, 8, 2, 4, 7, 9], [5, 8, 3, 9, 7, 4, 2]), + ([10, 5, 15, None, 6, 12, 20], [10, 15, 5, 20, 12, 6]), + ([1, 2, None, 3], [1, None, 2, None, 3]), + ([0, -1, 1], [0, 1, -1]), + ([100, 50, 150], [100, 150, 50]), + ([1, 2, 3, None, 4, None, 5], [1, 3, 2, 5, None, 4]), ], ) - def test_invert_tree( - self, root_list: list[int | None], expected_list: list[int | None], solution_class: type - ): - result = run_invert_tree(solution_class, root_list) + def test_invert_tree(self, root_list: list[int | None], expected_list: list[int | None]): + result = run_invert_tree(Solution, root_list) assert_invert_tree(result, expected_list) diff --git a/leetcode/k_closest_points_to_origin/test_solution.py b/leetcode/k_closest_points_to_origin/test_solution.py index 3ef3ad3..df391c0 100644 --- a/leetcode/k_closest_points_to_origin/test_solution.py +++ b/leetcode/k_closest_points_to_origin/test_solution.py @@ -20,6 +20,12 @@ def setup_method(self): ([[1, 1], [1, 1], [1, 1]], 2, [[1, 1], [1, 1]]), ([[0, 0]], 1, [[0, 0]]), ([[1, 0], [2, 0], [3, 0]], 2, [[1, 0], [2, 0]]), + ([[0, 3], [4, 0]], 1, [[0, 3]]), + ([[-5, 4], [4, 6], [2, -1]], 1, [[2, -1]]), + ([[1, 1], [2, 2], [3, 3]], 1, [[1, 1]]), + ([[10, 10], [1, 1], [5, 5]], 2, [[1, 1], [5, 5]]), + ([[-1, -1], [1, 1], [-1, 1], [1, -1]], 3, [[-1, 1], [1, -1], [1, 1]]), + ([[6, 10], [-3, 3], [-2, 5], [0, 2]], 3, [[-3, 3], [0, 2], [-2, 5]]), ], ) def test_k_closest(self, points: list[list[int]], k: int, expected: list[list[int]]): diff --git a/leetcode/kth_smallest_element_in_a_bst/test_solution.py b/leetcode/kth_smallest_element_in_a_bst/test_solution.py index 9f1e4d8..be3683e 100644 --- a/leetcode/kth_smallest_element_in_a_bst/test_solution.py +++ b/leetcode/kth_smallest_element_in_a_bst/test_solution.py @@ -20,6 +20,12 @@ def setup_method(self): ([2, 1, 3], 2, 2), ([4, 2, 6, 1, 3, 5, 7], 4, 4), ([1, None, 2], 2, 2), + ([5, 3, 6, 2, 4, None, None, 1], 1, 1), + ([5, 3, 6, 2, 4, None, None, 1], 4, 4), + ([10, 5, 15, 3, 7, 12, 20], 1, 3), + ([10, 5, 15, 3, 7, 12, 20], 7, 20), + ([1, None, 2, None, 3], 3, 3), + ([3, 1, 4, None, 2], 4, 4), ], ) def test_kth_smallest(self, root_list: list[int | None], k: int, expected: int): diff --git a/leetcode/linked_list_cycle/test_solution.py b/leetcode/linked_list_cycle/test_solution.py index 2660c0e..25f3780 100644 --- a/leetcode/linked_list_cycle/test_solution.py +++ b/leetcode/linked_list_cycle/test_solution.py @@ -24,6 +24,11 @@ def setup_method(self): ([1, 2, 3, 4, 5], 4, True), ([1], 0, True), ([1, 2], 1, True), + ([1, 2, 3, 4], -1, False), + ([1, 2, 3, 4, 5, 6], 3, True), + ([10, 20, 30], 1, True), + ([100], -1, False), + ([1, 2, 3, 4, 5, 6, 7, 8], 5, True), ], ) def test_has_cycle(self, values: list[int], pos: int, expected: bool): diff --git a/leetcode/lowest_common_ancestor_of_a_binary_search_tree/test_solution.py b/leetcode/lowest_common_ancestor_of_a_binary_search_tree/test_solution.py index d92a905..fd2cede 100644 --- a/leetcode/lowest_common_ancestor_of_a_binary_search_tree/test_solution.py +++ b/leetcode/lowest_common_ancestor_of_a_binary_search_tree/test_solution.py @@ -20,6 +20,12 @@ def setup_method(self): ([2, 1], 1, 2, 2), ([6, 2, 8, 0, 4, 7, 9], 0, 4, 2), ([6, 2, 8, 0, 4, 7, 9], 7, 9, 8), + ([5, 3, 6, 2, 4, None, None, 1], 1, 4, 3), + ([10, 5, 15, 3, 7, 12, 20], 3, 7, 5), + ([1, None, 2], 1, 2, 1), + ([3, 1, 4, None, 2], 1, 2, 1), + ([20, 8, 22, 4, 12, None, None, None, None, 10, 14], 10, 14, 12), + ([50, 30, 70, 20, 40, 60, 80], 20, 40, 30), ], ) def test_lowest_common_ancestor( diff --git a/leetcode/lowest_common_ancestor_of_a_binary_tree/test_solution.py b/leetcode/lowest_common_ancestor_of_a_binary_tree/test_solution.py index 0f1d86a..3d28a96 100644 --- a/leetcode/lowest_common_ancestor_of_a_binary_tree/test_solution.py +++ b/leetcode/lowest_common_ancestor_of_a_binary_tree/test_solution.py @@ -20,6 +20,12 @@ def setup_method(self): ([2, 1], 2, 1, 2), ([3, 5, 1, 6, 2, 0, 8, None, None, 7, 4], 6, 7, 5), ([3, 5, 1, 6, 2, 0, 8, None, None, 7, 4], 0, 8, 1), + ([1, None, 2, None, 3], 2, 3, 2), + ([4, 2, 6, 1, 3, 5, 7], 1, 7, 4), + ([10, 5, 15, 3, 7, None, 18], 3, 7, 5), + ([1, 2, 3, 4, 5, 6, 7], 4, 5, 2), + ([20, 8, 22, 4, 12, None, 25], 4, 12, 8), + ([50, 30, 70, 20, 40, 60, 80], 20, 40, 30), ], ) def test_lowest_common_ancestor( diff --git a/leetcode/lru_cache/test_solution.py b/leetcode/lru_cache/test_solution.py index 5c709c9..0fcaa3d 100644 --- a/leetcode/lru_cache/test_solution.py +++ b/leetcode/lru_cache/test_solution.py @@ -3,13 +3,12 @@ from leetcode_py.test_utils import logged_test from .helpers import assert_lru_cache, run_lru_cache -from .solution import LRUCache, LRUCacheWithDoublyList +from .solution import LRUCache class TestLRUCache: @logged_test - @pytest.mark.parametrize("solution_class", [LRUCache, LRUCacheWithDoublyList]) @pytest.mark.parametrize( "operations, inputs, expected", [ @@ -28,14 +27,45 @@ class TestLRUCache: [[1], [2, 1], [2], [3, 2], [2], [3]], [None, None, 1, None, -1, 2], ), + (["LRUCache", "get"], [[1], [1]], [None, -1]), + (["LRUCache", "put", "get"], [[1], [1, 100], [1]], [None, None, 100]), + ( + ["LRUCache", "put", "put", "get", "get"], + [[2], [1, 1], [2, 2], [1], [2]], + [None, None, None, 1, 2], + ), + ( + ["LRUCache", "put", "put", "put", "get", "get", "get"], + [[2], [1, 1], [2, 2], [3, 3], [1], [2], [3]], + [None, None, None, None, -1, 2, 3], + ), + ( + ["LRUCache", "put", "get", "put", "get", "put", "get"], + [[3], [1, 1], [1], [2, 2], [2], [3, 3], [3]], + [None, None, 1, None, 2, None, 3], + ), + ( + ["LRUCache", "put", "put", "put", "put", "get", "get"], + [[3], [1, 1], [2, 2], [3, 3], [4, 4], [4], [3]], + [None, None, None, None, None, 4, 3], + ), + ( + ["LRUCache", "put", "put", "get", "put", "get", "get"], + [[2], [2, 1], [1, 1], [2], [4, 1], [1], [2]], + [None, None, None, 1, None, -1, 1], + ), + ( + ["LRUCache", "put", "put", "get", "put", "put", "get"], + [[2], [2, 1], [2, 2], [2], [1, 1], [4, 1], [2]], + [None, None, None, 2, None, None, -1], + ), + ( + ["LRUCache", "put", "put", "put", "get", "put", "get", "get", "get", "get"], + [[3], [1, 1], [2, 2], [3, 3], [2], [4, 4], [1], [3], [4], [2]], + [None, None, None, None, 2, None, -1, 3, 4, 2], + ), ], ) - def test_lru_cache( - self, - operations: list[str], - inputs: list[list[int]], - expected: list[int | None], - solution_class: type, - ): - result, _ = run_lru_cache(solution_class, operations, inputs) + def test_lru_cache(self, operations: list[str], inputs: list[list[int]], expected: list[int | None]): + result, _ = run_lru_cache(LRUCache, operations, inputs) assert_lru_cache(result, expected) diff --git a/leetcode/majority_element/test_solution.py b/leetcode/majority_element/test_solution.py index d4c439f..ef73961 100644 --- a/leetcode/majority_element/test_solution.py +++ b/leetcode/majority_element/test_solution.py @@ -23,6 +23,12 @@ def setup_method(self): ([1, 2, 3, 4, 4, 4, 4], 4), ([0, 0, 0], 0), ([-1, -1, -1, 1, 1], -1), + ([100, 100, 100, 99, 99], 100), + ([7, 7, 7, 7, 7, 8, 8], 7), + ([1, 1, 1, 1, 1, 1, 2, 2, 2], 1), + ([9, 9, 9, 9, 8, 8, 8], 9), + ([-5, -5, -5, -4, -4], -5), + ([1000, 1000, 999, 999, 1000], 1000), ], ) def test_majority_element(self, nums: list[int], expected: int): diff --git a/leetcode/maximum_depth_of_binary_tree/test_solution.py b/leetcode/maximum_depth_of_binary_tree/test_solution.py index 229701e..e86979c 100644 --- a/leetcode/maximum_depth_of_binary_tree/test_solution.py +++ b/leetcode/maximum_depth_of_binary_tree/test_solution.py @@ -22,6 +22,13 @@ def setup_method(self): ([1, 2, 3], 2), ([1, 2, 3, 4], 3), ([1, None, 2, None, 3], 3), + ([1, 2, 3, 4, 5, 6, 7], 3), + ([1, 2, None, 4, None, None, None, 8], 3), + ([5, 4, 8, 11, None, 13, 4, 7, 2, None, None, None, 1], 4), + ([1, 2, 3, None, None, 4, 5, None, None, 6], 4), + ([10], 1), + ([1, 2, 2, 3, 3, 3, 3], 3), + ([0, -1, 1, -2, -1, 0, 2], 3), ], ) def test_max_depth(self, root_list: list[int | None], expected: int): diff --git a/leetcode/maximum_profit_in_job_scheduling/test_solution.py b/leetcode/maximum_profit_in_job_scheduling/test_solution.py index 3cfe330..8e17451 100644 --- a/leetcode/maximum_profit_in_job_scheduling/test_solution.py +++ b/leetcode/maximum_profit_in_job_scheduling/test_solution.py @@ -17,7 +17,20 @@ def setup_method(self): ([1, 2, 3, 3], [3, 4, 5, 6], [50, 10, 40, 70], 120), ([1, 2, 3, 4, 6], [3, 5, 10, 6, 9], [20, 20, 100, 70, 60], 150), ([1, 1, 1], [2, 3, 4], [5, 6, 4], 6), + ([1, 2], [2, 3], [100, 200], 300), + ( + [6, 15, 7, 11, 1, 3, 16, 2], + [19, 18, 19, 16, 10, 8, 19, 8], + [2, 9, 1, 19, 5, 7, 3, 19], + 41, + ), ([1], [2], [100], 100), + ([1, 2, 3], [2, 3, 4], [1, 1, 1], 3), + ([1, 3, 6, 7, 8, 12], [4, 5, 10, 11, 12, 16], [20, 20, 100, 70, 60, 120], 240), + ([1, 4, 6], [3, 5, 7], [50, 10, 40], 100), + ([1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [10, 20, 30, 40, 50], 50), + ([5, 4, 3, 2, 1], [6, 5, 4, 3, 2], [1, 2, 3, 4, 5], 15), + ([1, 1000000000], [2, 1000000001], [1, 10000], 10001), ], ) def test_job_scheduling( diff --git a/leetcode/maximum_subarray/test_solution.py b/leetcode/maximum_subarray/test_solution.py index 1690628..ddb4d89 100644 --- a/leetcode/maximum_subarray/test_solution.py +++ b/leetcode/maximum_subarray/test_solution.py @@ -21,6 +21,14 @@ def setup_method(self): ([-2, -1], -1), ([1, 2, 3, 4, 5], 15), ([-5, -2, -8, -1], -1), + ([0], 0), + ([0, -1, 0], 0), + ([-3, -2, -1, -5], -1), + ([2, -1, 2, -1, 2], 4), + ([1, -3, 2, 1, -1], 3), + ([-2, -3, 4, -1, -2, 1, 5, -3], 7), + ([10, -5, 3, -2, 8], 14), + ([100], 100), ], ) def test_max_sub_array(self, nums: list[int], expected: int): diff --git a/leetcode/merge_intervals/test_solution.py b/leetcode/merge_intervals/test_solution.py index 045bc7f..195cced 100644 --- a/leetcode/merge_intervals/test_solution.py +++ b/leetcode/merge_intervals/test_solution.py @@ -20,6 +20,12 @@ def setup_method(self): ([[1, 3]], [[1, 3]]), ([[1, 4], [2, 3]], [[1, 4]]), ([[1, 2], [3, 4], [5, 6]], [[1, 2], [3, 4], [5, 6]]), + ([[0, 0]], [[0, 0]]), + ([[1, 10], [2, 3], [4, 5], [6, 7], [8, 9]], [[1, 10]]), + ([[1, 3], [2, 6], [8, 10], [9, 12], [15, 18]], [[1, 6], [8, 12], [15, 18]]), + ([[2, 3], [4, 5], [6, 7], [8, 9], [1, 10]], [[1, 10]]), + ([[1, 4], [0, 4]], [[0, 4]]), + ([[1, 4], [0, 0], [3, 5]], [[0, 0], [1, 5]]), ], ) def test_merge(self, intervals: list[list[int]], expected: list[list[int]]): diff --git a/leetcode/merge_k_sorted_lists/test_solution.py b/leetcode/merge_k_sorted_lists/test_solution.py index ea7d200..e9d9cfc 100644 --- a/leetcode/merge_k_sorted_lists/test_solution.py +++ b/leetcode/merge_k_sorted_lists/test_solution.py @@ -23,6 +23,12 @@ def setup_method(self): ([[-1, 0, 1], [-2, 2]], [-2, -1, 0, 1, 2]), ([[1, 1, 1], [2, 2, 2]], [1, 1, 1, 2, 2, 2]), ([[], [1], []], [1]), + ([[0, 0, 0], [1, 1, 1]], [0, 0, 0, 1, 1, 1]), + ([[10], [5], [1]], [1, 5, 10]), + ([[1, 2, 3, 4, 5]], [1, 2, 3, 4, 5]), + ([[-10, -5], [-8, -3], [-6, -1]], [-10, -8, -6, -5, -3, -1]), + ([[100]], [100]), + ([[1, 3, 5], [2, 4, 6], [7, 8, 9]], [1, 2, 3, 4, 5, 6, 7, 8, 9]), ], ) def test_merge_k_lists(self, lists_data: list[list[int]], expected_data: list[int]): diff --git a/leetcode/merge_two_sorted_lists/test_solution.py b/leetcode/merge_two_sorted_lists/test_solution.py index c0deaf5..58b2887 100644 --- a/leetcode/merge_two_sorted_lists/test_solution.py +++ b/leetcode/merge_two_sorted_lists/test_solution.py @@ -21,6 +21,13 @@ def setup_method(self): ([2], [1], [1, 2]), ([1, 3, 5], [2, 4, 6], [1, 2, 3, 4, 5, 6]), ([1, 1, 1], [2, 2, 2], [1, 1, 1, 2, 2, 2]), + ([0], [], [0]), + ([1, 2, 3], [], [1, 2, 3]), + ([5], [1, 2, 3, 4], [1, 2, 3, 4, 5]), + ([-1, 0, 1], [-2, 2, 3], [-2, -1, 0, 1, 2, 3]), + ([1, 5, 9], [2, 6, 8], [1, 2, 5, 6, 8, 9]), + ([10, 20, 30], [15, 25, 35], [10, 15, 20, 25, 30, 35]), + ([1, 1], [1, 1], [1, 1, 1, 1]), ], ) def test_merge_two_lists( diff --git a/leetcode/middle_of_the_linked_list/test_solution.py b/leetcode/middle_of_the_linked_list/test_solution.py index 5bf4440..0cdfdd0 100644 --- a/leetcode/middle_of_the_linked_list/test_solution.py +++ b/leetcode/middle_of_the_linked_list/test_solution.py @@ -21,6 +21,13 @@ def setup_method(self): ([1, 2, 3], [2, 3]), ([1, 2, 3, 4], [3, 4]), ([10, 20, 30, 40, 50, 60, 70], [40, 50, 60, 70]), + ([5, 10], [10]), + ([1, 3, 5, 7, 9], [5, 7, 9]), + ([2, 4, 6, 8, 10, 12], [8, 10, 12]), + ([100], [100]), + ([7, 14, 21], [14, 21]), + ([11, 22, 33, 44], [33, 44]), + ([1, 1, 1, 1, 1], [1, 1, 1]), ], ) def test_middle_node(self, head_list: list[int], expected_list: list[int]): diff --git a/leetcode/min_stack/test_solution.py b/leetcode/min_stack/test_solution.py index 0604301..fd75d51 100644 --- a/leetcode/min_stack/test_solution.py +++ b/leetcode/min_stack/test_solution.py @@ -27,6 +27,86 @@ class TestTestMinStack: [[], [1], [1], [2], [], [], [], [], []], [None, None, None, None, 1, None, 1, None, 1], ), + (["MinStack", "push", "getMin", "top"], [[], [0], [], []], [None, None, 0, 0]), + ( + ["MinStack", "push", "push", "getMin", "push", "getMin", "pop", "getMin"], + [[], [2], [1], [], [0], [], [], []], + [None, None, None, 1, None, 0, None, 1], + ), + ( + ["MinStack", "push", "push", "push", "top", "getMin", "pop", "pop", "top", "getMin"], + [[], [3], [1], [4], [], [], [], [], [], []], + [None, None, None, None, 4, 1, None, None, 3, 3], + ), + ( + ["MinStack", "push", "push", "getMin", "pop", "push", "getMin"], + [[], [-1], [-2], [], [], [0], []], + [None, None, None, -2, None, None, -1], + ), + ( + ["MinStack", "push", "push", "push", "push", "getMin", "pop", "pop", "getMin"], + [[], [5], [3], [7], [2], [], [], [], []], + [None, None, None, None, None, 2, None, None, 3], + ), + ( + [ + "MinStack", + "push", + "push", + "push", + "getMin", + "pop", + "getMin", + "pop", + "getMin", + "pop", + "push", + "getMin", + ], + [[], [10], [5], [15], [], [], [], [], [], [], [8], []], + [None, None, None, None, 5, None, 5, None, 10, None, None, 8], + ), + ( + [ + "MinStack", + "push", + "push", + "push", + "push", + "push", + "getMin", + "pop", + "getMin", + "pop", + "getMin", + ], + [[], [1], [2], [0], [3], [4], [], [], [], [], []], + [None, None, None, None, None, None, 0, None, 0, None, 0], + ), + ( + ["MinStack", "push", "getMin", "push", "getMin", "push", "getMin", "top"], + [[], [2147483647], [], [-2147483648], [], [0], [], []], + [None, None, 2147483647, None, -2147483648, None, -2147483648, 0], + ), + ( + [ + "MinStack", + "push", + "push", + "push", + "push", + "push", + "top", + "getMin", + "pop", + "top", + "getMin", + "pop", + "getMin", + ], + [[], [1], [1], [1], [1], [1], [], [], [], [], [], [], []], + [None, None, None, None, None, None, 1, 1, None, 1, 1, None, 1], + ), ], ) def test_min_stack(self, operations: list[str], inputs: list[list[int]], expected: list[int | None]): diff --git a/leetcode/minimum_height_trees/test_solution.py b/leetcode/minimum_height_trees/test_solution.py index d9a27c4..74cd63c 100644 --- a/leetcode/minimum_height_trees/test_solution.py +++ b/leetcode/minimum_height_trees/test_solution.py @@ -19,6 +19,13 @@ def setup_method(self): (1, [], [0]), (2, [[0, 1]], [0, 1]), (3, [[0, 1], [1, 2]], [1]), + (5, [[0, 1], [1, 2], [2, 3], [3, 4]], [2]), + (7, [[0, 1], [1, 2], [1, 3], [2, 4], [3, 5], [4, 6]], [1, 2]), + (6, [[0, 3], [1, 3], [2, 3], [4, 3], [5, 4]], [3, 4]), + (10, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]], [4, 5]), + (8, [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [6, 7]], [0, 4]), + (9, [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8]], [0, 1]), + (11, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]], [5]), ], ) def test_find_min_height_trees(self, n: int, edges: list[list[int]], expected: list[int]): diff --git a/leetcode/minimum_window_substring/test_solution.py b/leetcode/minimum_window_substring/test_solution.py index 2be62d0..a76fe7a 100644 --- a/leetcode/minimum_window_substring/test_solution.py +++ b/leetcode/minimum_window_substring/test_solution.py @@ -19,6 +19,12 @@ def setup_method(self): ("a", "aa", ""), ("ab", "b", "b"), ("abc", "cba", "abc"), + ("aa", "aa", "aa"), + ("a", "b", ""), + ("ab", "a", "a"), + ("bba", "ab", "ba"), + ("acbbaca", "aba", "baca"), + ("cabwefgewcwaefgcf", "cae", "cwae"), ], ) def test_min_window(self, s: str, t: str, expected: str): diff --git a/leetcode/number_of_islands/test_solution.py b/leetcode/number_of_islands/test_solution.py index 2428a04..2b37d2d 100644 --- a/leetcode/number_of_islands/test_solution.py +++ b/leetcode/number_of_islands/test_solution.py @@ -32,9 +32,21 @@ def setup_method(self): ], 3, ), + ([["1", "0", "1", "1", "1"], ["1", "0", "1", "0", "1"], ["1", "1", "1", "0", "1"]], 1), + ([["0", "0", "0", "0", "0"], ["0", "0", "0", "0", "0"], ["0", "0", "0", "0", "0"]], 0), + ([["1", "1", "1"], ["0", "1", "0"], ["1", "1", "1"]], 1), ([["1"]], 1), ([["0"]], 0), + ([["1", "0"], ["0", "1"]], 2), + ([["1", "1"], ["1", "1"]], 1), ([["1", "0", "1"], ["0", "1", "0"], ["1", "0", "1"]], 5), + ([["1", "1", "0"], ["0", "0", "1"], ["0", "1", "1"]], 2), + ( + [["1", "0", "0", "1"], ["0", "1", "1", "0"], ["0", "1", "1", "0"], ["1", "0", "0", "1"]], + 5, + ), + ([["0", "1", "0"], ["1", "0", "1"], ["0", "1", "0"]], 4), + ([["1", "1", "1", "1"], ["1", "0", "0", "1"], ["1", "1", "1", "1"]], 1), ], ) def test_num_islands(self, grid: list[list[str]], expected: int): diff --git a/leetcode/partition_equal_subset_sum/test_solution.py b/leetcode/partition_equal_subset_sum/test_solution.py index a04af23..e826127 100644 --- a/leetcode/partition_equal_subset_sum/test_solution.py +++ b/leetcode/partition_equal_subset_sum/test_solution.py @@ -3,13 +3,14 @@ from leetcode_py.test_utils import logged_test from .helpers import assert_can_partition, run_can_partition -from .solution import Solution, SolutionBitset +from .solution import Solution class TestPartitionEqualSubsetSum: + def setup_method(self): + self.solution = Solution() @logged_test - @pytest.mark.parametrize("solution_class", [Solution, SolutionBitset]) @pytest.mark.parametrize( "nums, expected", [ @@ -20,8 +21,16 @@ class TestPartitionEqualSubsetSum: ([2, 2, 1, 1], True), ([100], False), ([1, 2, 5], False), + ([1, 3, 5, 7], True), + ([2, 2, 3, 5], False), + ([1, 2, 3, 4, 5, 6, 7], True), + ([3, 3, 3, 4, 5], True), + ([1, 1, 1, 1], True), + ([23, 13, 11, 7, 6, 5, 5], True), + ([1, 5, 3], False), + ([4, 4, 4, 4, 4, 4], True), ], ) - def test_can_partition(self, nums: list[int], expected: bool, solution_class: type): - result = run_can_partition(solution_class, nums) + def test_can_partition(self, nums: list[int], expected: bool): + result = run_can_partition(Solution, nums) assert_can_partition(result, expected) diff --git a/leetcode/permutations/test_solution.py b/leetcode/permutations/test_solution.py index da684e9..d8d1bce 100644 --- a/leetcode/permutations/test_solution.py +++ b/leetcode/permutations/test_solution.py @@ -18,6 +18,42 @@ def setup_method(self): ([0, 1], [[0, 1], [1, 0]]), ([1], [[1]]), ([2, 1], [[2, 1], [1, 2]]), + ([0], [[0]]), + ([-1, 0], [[-1, 0], [0, -1]]), + ([1, 2], [[1, 2], [2, 1]]), + ([3, 2, 1], [[3, 2, 1], [3, 1, 2], [2, 3, 1], [2, 1, 3], [1, 3, 2], [1, 2, 3]]), + ([-1, 1], [[-1, 1], [1, -1]]), + ( + [5, 4, 3, 2], + [ + [5, 4, 3, 2], + [5, 4, 2, 3], + [5, 3, 4, 2], + [5, 3, 2, 4], + [5, 2, 4, 3], + [5, 2, 3, 4], + [4, 5, 3, 2], + [4, 5, 2, 3], + [4, 3, 5, 2], + [4, 3, 2, 5], + [4, 2, 5, 3], + [4, 2, 3, 5], + [3, 5, 4, 2], + [3, 5, 2, 4], + [3, 4, 5, 2], + [3, 4, 2, 5], + [3, 2, 5, 4], + [3, 2, 4, 5], + [2, 5, 4, 3], + [2, 5, 3, 4], + [2, 4, 5, 3], + [2, 4, 3, 5], + [2, 3, 5, 4], + [2, 3, 4, 5], + ], + ), + ([0, -1, 1], [[0, -1, 1], [0, 1, -1], [-1, 0, 1], [-1, 1, 0], [1, 0, -1], [1, -1, 0]]), + ([10, -10], [[10, -10], [-10, 10]]), ], ) def test_permute(self, nums: list[int], expected: list[list[int]]): diff --git a/leetcode/product_of_array_except_self/test_solution.py b/leetcode/product_of_array_except_self/test_solution.py index 2645aff..84013ac 100644 --- a/leetcode/product_of_array_except_self/test_solution.py +++ b/leetcode/product_of_array_except_self/test_solution.py @@ -21,6 +21,14 @@ def setup_method(self): ([5, 2], [2, 5]), ([0, 1, 2, 3], [6, 0, 0, 0]), ([1, 0, 3, 4], [0, 12, 0, 0]), + ([-1, -2, -3], [6, 3, 2]), + ([2, 2, 2], [4, 4, 4]), + ([10, 3, 5, 6, 2], [180, 600, 360, 300, 900]), + ([0, 0], [0, 0]), + ([1, 2, 0, 4], [0, 0, 8, 0]), + ([-2, 0, -3, 4], [0, 24, 0, 0]), + ([7, 1, 3], [3, 21, 7]), + ([4, 5, 1, 8, 2], [80, 64, 320, 40, 160]), ], ) def test_product_except_self(self, nums: list[int], expected: list[int]): diff --git a/leetcode/reverse_linked_list/test_solution.py b/leetcode/reverse_linked_list/test_solution.py index 38404d5..8f8198e 100644 --- a/leetcode/reverse_linked_list/test_solution.py +++ b/leetcode/reverse_linked_list/test_solution.py @@ -24,6 +24,11 @@ def setup_method(self): ([0], [0]), ([5000, -5000], [-5000, 5000]), ([1, 1, 1], [1, 1, 1]), + ([10, 20, 30, 40, 50, 60], [60, 50, 40, 30, 20, 10]), + ([-100, 0, 100], [100, 0, -100]), + ([7], [7]), + ([1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1]), + ([42, 42, 42, 42], [42, 42, 42, 42]), ], ) def test_reverse_list(self, head_list: list[int], expected_list: list[int]): diff --git a/leetcode/reverse_linked_list_ii/test_solution.py b/leetcode/reverse_linked_list_ii/test_solution.py index daecb86..5964711 100644 --- a/leetcode/reverse_linked_list_ii/test_solution.py +++ b/leetcode/reverse_linked_list_ii/test_solution.py @@ -20,6 +20,12 @@ def setup_method(self): ([1, 2, 3], 1, 3, [3, 2, 1]), ([1, 2, 3, 4, 5], 1, 5, [5, 4, 3, 2, 1]), ([1, 2, 3, 4, 5], 3, 3, [1, 2, 3, 4, 5]), + ([1, 2, 3, 4], 2, 3, [1, 3, 2, 4]), + ([1, 2, 3, 4, 5, 6], 3, 5, [1, 2, 5, 4, 3, 6]), + ([10], 1, 1, [10]), + ([1, 2, 3, 4, 5, 6, 7], 1, 7, [7, 6, 5, 4, 3, 2, 1]), + ([3, 5], 1, 1, [3, 5]), + ([7, 9, 2, 10, 1, 8, 6], 4, 6, [7, 9, 2, 8, 1, 10, 6]), ], ) def test_reverse_between( diff --git a/leetcode/search_in_rotated_sorted_array/test_solution.py b/leetcode/search_in_rotated_sorted_array/test_solution.py index c63c101..a227711 100644 --- a/leetcode/search_in_rotated_sorted_array/test_solution.py +++ b/leetcode/search_in_rotated_sorted_array/test_solution.py @@ -23,6 +23,12 @@ def setup_method(self): ([2, 1], 2, 0), ([5, 1, 3], 3, 2), ([4, 5, 6, 7, 8, 1, 2, 3], 8, 4), + ([6, 7, 0, 1, 2, 3, 4, 5], 6, 0), + ([7, 0, 1, 2, 3, 4, 5, 6], 7, 0), + ([0, 1, 2, 3, 4, 5, 6, 7], 4, 4), + ([3, 4, 5, 6, 7, 0, 1, 2], 2, 7), + ([9, 0, 2, 7, 8], 3, -1), + ([8, 9, 2, 3, 4], 9, 1), ], ) def test_search(self, nums: list[int], target: int, expected: int): diff --git a/leetcode/serialize_and_deserialize_binary_tree/test_solution.py b/leetcode/serialize_and_deserialize_binary_tree/test_solution.py index 4e523e9..8f67b6e 100644 --- a/leetcode/serialize_and_deserialize_binary_tree/test_solution.py +++ b/leetcode/serialize_and_deserialize_binary_tree/test_solution.py @@ -19,6 +19,14 @@ class TestSerializeAndDeserializeBinaryTree: ([1, None, 2]), ([1, 2, 3, 4, 5, 6, 7]), ([5, 2, 3, None, None, 2, 4, 3, 1]), + ([1, 2, 3]), + ([1, None, None]), + ([1, 2, None, 4]), + ([1, None, 2, None, 3]), + ([10, 5, 15, None, 6, 12, 20]), + ([0, -1, 1]), + ([100]), + ([1, 2, 3, 4, None, None, 7, 8]), ], ) def test_serialize_deserialize(self, root_list: list[int | None]): diff --git a/leetcode/sort_colors/test_solution.py b/leetcode/sort_colors/test_solution.py index df38daf..43f6085 100644 --- a/leetcode/sort_colors/test_solution.py +++ b/leetcode/sort_colors/test_solution.py @@ -23,6 +23,12 @@ def setup_method(self): ([2, 2, 2], [2, 2, 2]), ([0, 0, 0], [0, 0, 0]), ([1, 1, 1], [1, 1, 1]), + ([2, 1, 0], [0, 1, 2]), + ([1, 0, 2, 1, 0, 2], [0, 0, 1, 1, 2, 2]), + ([0, 2, 1, 0, 2, 1], [0, 0, 1, 1, 2, 2]), + ([2, 2, 1, 0, 0, 1], [0, 0, 1, 1, 2, 2]), + ([1, 2, 0, 1, 2, 0, 1], [0, 0, 1, 1, 1, 2, 2]), + ([0, 1, 0, 2, 1, 2, 0], [0, 0, 0, 1, 1, 2, 2]), ], ) def test_sort_colors(self, nums: list[int], expected: list[int]): diff --git a/leetcode/spiral_matrix/test_solution.py b/leetcode/spiral_matrix/test_solution.py index 6d36a02..22bda84 100644 --- a/leetcode/spiral_matrix/test_solution.py +++ b/leetcode/spiral_matrix/test_solution.py @@ -21,6 +21,13 @@ def setup_method(self): ([[1], [2]], [1, 2]), ([[1, 2, 3]], [1, 2, 3]), ([[1], [2], [3]], [1, 2, 3]), + ([[1, 2], [3, 4]], [1, 2, 4, 3]), + ([[1, 2, 3, 4, 5]], [1, 2, 3, 4, 5]), + ([[1], [2], [3], [4], [5]], [1, 2, 3, 4, 5]), + ([[1, 2, 3], [4, 5, 6]], [1, 2, 3, 6, 5, 4]), + ([[1, 2], [3, 4], [5, 6]], [1, 2, 4, 6, 5, 3]), + ([[7, 9, 6], [2, 8, 6], [1, 3, 5]], [7, 9, 6, 6, 5, 3, 1, 2, 8]), + ([[1, 2, 3, 4], [5, 6, 7, 8]], [1, 2, 3, 4, 8, 7, 6, 5]), ], ) def test_spiral_order(self, matrix: list[list[int]], expected: list[int]): diff --git a/leetcode/task_scheduler/test_solution.py b/leetcode/task_scheduler/test_solution.py index b2db53e..85794ce 100644 --- a/leetcode/task_scheduler/test_solution.py +++ b/leetcode/task_scheduler/test_solution.py @@ -3,13 +3,14 @@ from leetcode_py.test_utils import logged_test from .helpers import assert_least_interval, run_least_interval -from .solution import Solution, SolutionGreedy +from .solution import Solution class TestTaskScheduler: + def setup_method(self): + self.solution = Solution() @logged_test - @pytest.mark.parametrize("solution_class", [Solution, SolutionGreedy]) @pytest.mark.parametrize( "tasks, n, expected", [ @@ -19,8 +20,14 @@ class TestTaskScheduler: (["A"], 0, 1), (["A", "A"], 1, 3), (["A", "B"], 0, 2), + (["A", "A", "A"], 0, 3), + (["A", "B", "C", "D", "E", "F"], 2, 6), + (["A", "A", "A", "A", "A", "A", "B", "C", "D", "E", "F", "G"], 2, 16), + (["A", "A", "B", "B"], 2, 5), + (["A", "B", "A", "B"], 1, 4), + (["A", "A", "A", "A"], 3, 13), ], ) - def test_least_interval(self, tasks: list[str], n: int, expected: int, solution_class: type): - result = run_least_interval(solution_class, tasks, n) + def test_least_interval(self, tasks: list[str], n: int, expected: int): + result = run_least_interval(Solution, tasks, n) assert_least_interval(result, expected) diff --git a/leetcode/three_sum/test_solution.py b/leetcode/three_sum/test_solution.py index 9ec9f76..2bba573 100644 --- a/leetcode/three_sum/test_solution.py +++ b/leetcode/three_sum/test_solution.py @@ -20,6 +20,15 @@ def setup_method(self): ([-1, 0, 1], [[-1, 0, 1]]), ([1, 2, -2, -1], []), ([-2, 0, 1, 1, 2], [[-2, 0, 2], [-2, 1, 1]]), + ([1, -1, -1, 0], [[-1, 0, 1]]), + ( + [-4, -2, -2, -2, 0, 1, 2, 2, 2, 3, 3, 4, 4, 6, 6], + [[-4, -2, 6], [-4, 0, 4], [-4, 1, 3], [-4, 2, 2], [-2, -2, 4], [-2, 0, 2]], + ), + ([3, 0, -2, -1, 1, 2], [[-2, -1, 3], [-2, 0, 2], [-1, 0, 1]]), + ([0, 0, 0, 0], [[0, 0, 0]]), + ([-1, -1, 2], [[-1, -1, 2]]), + ([1, 1, -2], [[-2, 1, 1]]), ], ) def test_three_sum(self, nums: list[int], expected: list[list[int]]): diff --git a/leetcode/trapping_rain_water/test_solution.py b/leetcode/trapping_rain_water/test_solution.py index fb1fc4c..c35bb3f 100644 --- a/leetcode/trapping_rain_water/test_solution.py +++ b/leetcode/trapping_rain_water/test_solution.py @@ -21,6 +21,14 @@ def setup_method(self): ([1], 0), ([1, 2], 0), ([2, 1], 0), + ([3, 2, 0, 4], 4), + ([5, 4, 1, 2], 1), + ([2, 0, 2], 2), + ([1, 0, 1], 1), + ([0, 2, 0], 0), + ([1, 2, 1], 0), + ([5, 2, 7, 2, 6, 1, 5, 3, 2, 1], 11), + ([0, 0, 0, 0], 0), ], ) def test_trap(self, height: list[int], expected: int): diff --git a/leetcode/valid_palindrome/test_solution.py b/leetcode/valid_palindrome/test_solution.py index f1fedb9..83b4362 100644 --- a/leetcode/valid_palindrome/test_solution.py +++ b/leetcode/valid_palindrome/test_solution.py @@ -22,6 +22,14 @@ def setup_method(self): ("Madam", True), ("No 'x' in Nixon", True), ("Mr. Owl ate my metal worm", True), + ("Was it a car or a cat I saw?", True), + ("Madam, I'm Adam", True), + ("Never odd or even", True), + ("Do geese see God?", True), + ("Step on no pets", True), + ("12321", True), + ("hello", False), + ("ab", False), ], ) def test_is_palindrome(self, s: str, expected: bool): diff --git a/leetcode/valid_parentheses/test_solution.py b/leetcode/valid_parentheses/test_solution.py index 88b32d6..7e4c8b2 100644 --- a/leetcode/valid_parentheses/test_solution.py +++ b/leetcode/valid_parentheses/test_solution.py @@ -24,6 +24,16 @@ def setup_method(self): (")", False), ("{[()]}", True), ("{[(])}", False), + ("((", False), + ("))", False), + ("([{}])", True), + ("([{]})", False), + ("{[}]", False), + ("((()))", True), + ("((())", False), + ("(){}[]", True), + ("{[(", False), + ("]})", False), ], ) def test_is_valid(self, s: str, expected: bool): diff --git a/leetcode/validate_binary_search_tree/test_solution.py b/leetcode/validate_binary_search_tree/test_solution.py index e7af72f..8e5eca0 100644 --- a/leetcode/validate_binary_search_tree/test_solution.py +++ b/leetcode/validate_binary_search_tree/test_solution.py @@ -3,13 +3,14 @@ from leetcode_py.test_utils import logged_test from .helpers import assert_is_valid_bst, run_is_valid_bst -from .solution import Solution, SolutionBFS, SolutionDFS +from .solution import Solution class TestValidateBinarySearchTree: + def setup_method(self): + self.solution = Solution() @logged_test - @pytest.mark.parametrize("solution_class", [Solution, SolutionDFS, SolutionBFS]) @pytest.mark.parametrize( "root_list, expected", [ @@ -19,8 +20,14 @@ class TestValidateBinarySearchTree: ([1, 1], False), ([10, 5, 15, None, None, 6, 20], False), ([2, 1, 3, None, None, None, 4], True), + ([0], True), + ([2147483647], True), + ([-2147483648], True), + ([5, 4, 6, None, None, 3, 7], False), + ([10, 5, 15, None, None, 12, 20, None, None, None, None, 6, 25], True), + ([3, 1, 5, 0, 2, 4, 6], True), ], ) - def test_is_valid_bst(self, root_list: list[int | None], expected: bool, solution_class: type): - result = run_is_valid_bst(solution_class, root_list) + def test_is_valid_bst(self, root_list: list[int | None], expected: bool): + result = run_is_valid_bst(Solution, root_list) assert_is_valid_bst(result, expected) diff --git a/leetcode/word_break/test_solution.py b/leetcode/word_break/test_solution.py index fe2f52e..97a2619 100644 --- a/leetcode/word_break/test_solution.py +++ b/leetcode/word_break/test_solution.py @@ -21,6 +21,14 @@ def setup_method(self): ("a", ["a"], True), ("ab", ["a", "b"], True), ("abcd", ["a", "abc", "d"], True), + ("aaaaaaa", ["aaaa", "aaa"], True), + ("aaaaaaa", ["aaaa", "aa"], False), + ("cars", ["car", "ca", "rs"], True), + ("raceacar", ["race", "a", "car"], True), + ("abcdef", ["abc", "def"], True), + ("abcdef", ["ab", "cd", "ef"], True), + ("goalspecial", ["go", "goal", "goals", "special"], True), + ("bb", ["a", "b", "bbb", "bbbb"], True), ], ) def test_word_break(self, s: str, word_dict: list[str], expected: bool): diff --git a/leetcode/word_ladder/test_solution.py b/leetcode/word_ladder/test_solution.py index ed83464..94008a8 100644 --- a/leetcode/word_ladder/test_solution.py +++ b/leetcode/word_ladder/test_solution.py @@ -19,6 +19,117 @@ def setup_method(self): ("a", "c", ["a", "b", "c"], 2), ("hot", "dog", ["hot", "dog"], 0), ("hot", "dog", ["hot", "hog", "dog"], 3), + ("red", "tax", ["ted", "tex", "red", "tax", "tad", "den", "rex", "pee"], 4), + ("talk", "tail", ["talk", "tons", "fall", "tail", "gale", "hall", "negs"], 0), + ( + "qa", + "sq", + [ + "si", + "go", + "se", + "cm", + "so", + "ph", + "mt", + "db", + "mb", + "sb", + "kr", + "ln", + "tm", + "le", + "av", + "sm", + "ar", + "ci", + "ca", + "br", + "ti", + "ba", + "to", + "ra", + "fa", + "yo", + "ow", + "sn", + "ya", + "cr", + "po", + "fe", + "ho", + "ma", + "re", + "or", + "rn", + "au", + "ur", + "rh", + "sr", + "tc", + "lt", + "lo", + "as", + "fr", + "nb", + "yb", + "if", + "pb", + "ge", + "th", + "pm", + "rb", + "sh", + "co", + "ga", + "li", + "ha", + "hz", + "no", + "bi", + "di", + "hi", + "qa", + "pi", + "os", + "uh", + "wm", + "an", + "me", + "mo", + "na", + "la", + "st", + "er", + "sc", + "ne", + "mn", + "mi", + "am", + "ex", + "pt", + "io", + "be", + "fm", + "ta", + "tb", + "ni", + "mr", + "pa", + "he", + "lr", + "sq", + "ye", + ], + 5, + ), + ("cet", "ism", ["kid", "tag", "pup", "ail", "tun", "woo"], 0), + ("lost", "miss", ["most", "mist", "miss", "lost", "fist", "fish"], 4), + ("cat", "dog", ["bat", "bag", "dag", "dog", "cat"], 5), + ("game", "thee", ["frye", "heat", "tree", "thee", "game", "free"], 0), + ("teach", "place", ["peale", "wilts", "place", "fetch"], 0), + ("sail", "boat", ["bail", "foil", "coat", "boat", "sail"], 0), + ("cold", "warm", ["cold", "cord", "word", "ward", "warm"], 5), ], ) def test_ladder_length(self, begin_word: str, end_word: str, word_list: list[str], expected: int): diff --git a/leetcode/zero_one_matrix/test_solution.py b/leetcode/zero_one_matrix/test_solution.py index ea195cb..4129b47 100644 --- a/leetcode/zero_one_matrix/test_solution.py +++ b/leetcode/zero_one_matrix/test_solution.py @@ -18,6 +18,15 @@ def setup_method(self): ([[0, 0, 0], [0, 1, 0], [1, 1, 1]], [[0, 0, 0], [0, 1, 0], [1, 2, 1]]), ([[0]], [[0]]), ([[1, 0]], [[1, 0]]), + ([[1, 1], [1, 0]], [[2, 1], [1, 0]]), + ([[0, 1, 0], [1, 1, 1], [0, 1, 0]], [[0, 1, 0], [1, 2, 1], [0, 1, 0]]), + ([[1, 0, 1], [1, 1, 1], [1, 1, 1]], [[1, 0, 1], [2, 1, 2], [3, 2, 3]]), + ([[0, 1, 0, 0], [1, 1, 1, 0], [1, 1, 1, 0]], [[0, 1, 0, 0], [1, 2, 1, 0], [2, 2, 1, 0]]), + ([[1, 1, 1], [1, 1, 1], [1, 1, 0]], [[4, 3, 2], [3, 2, 1], [2, 1, 0]]), + ([[0, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]], [[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5]]), + ([[1, 0, 0], [1, 1, 0], [1, 1, 1]], [[1, 0, 0], [2, 1, 0], [3, 2, 1]]), + ([[0, 0, 1], [0, 1, 1], [1, 1, 1]], [[0, 0, 1], [0, 1, 2], [1, 2, 3]]), + ([[1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 1]], [[2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]), ], ) def test_update_matrix(self, mat: list[list[int]], expected: list[list[int]]): diff --git a/poetry.lock b/poetry.lock index 1ee7322..54bb124 100644 --- a/poetry.lock +++ b/poetry.lock @@ -993,50 +993,50 @@ files = [ [[package]] name = "mypy" -version = "1.17.1" +version = "1.18.1" description = "Optional static typing for Python" optional = false python-versions = ">=3.9" groups = ["dev"] files = [ - {file = "mypy-1.17.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:3fbe6d5555bf608c47203baa3e72dbc6ec9965b3d7c318aa9a4ca76f465bd972"}, - {file = "mypy-1.17.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:80ef5c058b7bce08c83cac668158cb7edea692e458d21098c7d3bce35a5d43e7"}, - {file = "mypy-1.17.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c4a580f8a70c69e4a75587bd925d298434057fe2a428faaf927ffe6e4b9a98df"}, - {file = "mypy-1.17.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:dd86bb649299f09d987a2eebb4d52d10603224500792e1bee18303bbcc1ce390"}, - {file = "mypy-1.17.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:a76906f26bd8d51ea9504966a9c25419f2e668f012e0bdf3da4ea1526c534d94"}, - {file = "mypy-1.17.1-cp310-cp310-win_amd64.whl", hash = "sha256:e79311f2d904ccb59787477b7bd5d26f3347789c06fcd7656fa500875290264b"}, - {file = "mypy-1.17.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ad37544be07c5d7fba814eb370e006df58fed8ad1ef33ed1649cb1889ba6ff58"}, - {file = "mypy-1.17.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:064e2ff508e5464b4bd807a7c1625bc5047c5022b85c70f030680e18f37273a5"}, - {file = "mypy-1.17.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:70401bbabd2fa1aa7c43bb358f54037baf0586f41e83b0ae67dd0534fc64edfd"}, - {file = "mypy-1.17.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e92bdc656b7757c438660f775f872a669b8ff374edc4d18277d86b63edba6b8b"}, - {file = "mypy-1.17.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:c1fdf4abb29ed1cb091cf432979e162c208a5ac676ce35010373ff29247bcad5"}, - {file = "mypy-1.17.1-cp311-cp311-win_amd64.whl", hash = "sha256:ff2933428516ab63f961644bc49bc4cbe42bbffb2cd3b71cc7277c07d16b1a8b"}, - {file = "mypy-1.17.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:69e83ea6553a3ba79c08c6e15dbd9bfa912ec1e493bf75489ef93beb65209aeb"}, - {file = "mypy-1.17.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1b16708a66d38abb1e6b5702f5c2c87e133289da36f6a1d15f6a5221085c6403"}, - {file = "mypy-1.17.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:89e972c0035e9e05823907ad5398c5a73b9f47a002b22359b177d40bdaee7056"}, - {file = "mypy-1.17.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:03b6d0ed2b188e35ee6d5c36b5580cffd6da23319991c49ab5556c023ccf1341"}, - {file = "mypy-1.17.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:c837b896b37cd103570d776bda106eabb8737aa6dd4f248451aecf53030cdbeb"}, - {file = "mypy-1.17.1-cp312-cp312-win_amd64.whl", hash = "sha256:665afab0963a4b39dff7c1fa563cc8b11ecff7910206db4b2e64dd1ba25aed19"}, - {file = "mypy-1.17.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:93378d3203a5c0800c6b6d850ad2f19f7a3cdf1a3701d3416dbf128805c6a6a7"}, - {file = "mypy-1.17.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:15d54056f7fe7a826d897789f53dd6377ec2ea8ba6f776dc83c2902b899fee81"}, - {file = "mypy-1.17.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:209a58fed9987eccc20f2ca94afe7257a8f46eb5df1fb69958650973230f91e6"}, - {file = "mypy-1.17.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:099b9a5da47de9e2cb5165e581f158e854d9e19d2e96b6698c0d64de911dd849"}, - {file = "mypy-1.17.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:fa6ffadfbe6994d724c5a1bb6123a7d27dd68fc9c059561cd33b664a79578e14"}, - {file = "mypy-1.17.1-cp313-cp313-win_amd64.whl", hash = "sha256:9a2b7d9180aed171f033c9f2fc6c204c1245cf60b0cb61cf2e7acc24eea78e0a"}, - {file = "mypy-1.17.1-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:15a83369400454c41ed3a118e0cc58bd8123921a602f385cb6d6ea5df050c733"}, - {file = "mypy-1.17.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:55b918670f692fc9fba55c3298d8a3beae295c5cded0a55dccdc5bbead814acd"}, - {file = "mypy-1.17.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:62761474061feef6f720149d7ba876122007ddc64adff5ba6f374fda35a018a0"}, - {file = "mypy-1.17.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c49562d3d908fd49ed0938e5423daed8d407774a479b595b143a3d7f87cdae6a"}, - {file = "mypy-1.17.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:397fba5d7616a5bc60b45c7ed204717eaddc38f826e3645402c426057ead9a91"}, - {file = "mypy-1.17.1-cp314-cp314-win_amd64.whl", hash = "sha256:9d6b20b97d373f41617bd0708fd46aa656059af57f2ef72aa8c7d6a2b73b74ed"}, - {file = "mypy-1.17.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5d1092694f166a7e56c805caaf794e0585cabdbf1df36911c414e4e9abb62ae9"}, - {file = "mypy-1.17.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:79d44f9bfb004941ebb0abe8eff6504223a9c1ac51ef967d1263c6572bbebc99"}, - {file = "mypy-1.17.1-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b01586eed696ec905e61bd2568f48740f7ac4a45b3a468e6423a03d3788a51a8"}, - {file = "mypy-1.17.1-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:43808d9476c36b927fbcd0b0255ce75efe1b68a080154a38ae68a7e62de8f0f8"}, - {file = "mypy-1.17.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:feb8cc32d319edd5859da2cc084493b3e2ce5e49a946377663cc90f6c15fb259"}, - {file = "mypy-1.17.1-cp39-cp39-win_amd64.whl", hash = "sha256:d7598cf74c3e16539d4e2f0b8d8c318e00041553d83d4861f87c7a72e95ac24d"}, - {file = "mypy-1.17.1-py3-none-any.whl", hash = "sha256:a9f52c0351c21fe24c21d8c0eb1f62967b262d6729393397b6f443c3b773c3b9"}, - {file = "mypy-1.17.1.tar.gz", hash = "sha256:25e01ec741ab5bb3eec8ba9cdb0f769230368a22c959c4937360efb89b7e9f01"}, + {file = "mypy-1.18.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:2761b6ae22a2b7d8e8607fb9b81ae90bc2e95ec033fd18fa35e807af6c657763"}, + {file = "mypy-1.18.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5b10e3ea7f2eec23b4929a3fabf84505da21034a4f4b9613cda81217e92b74f3"}, + {file = "mypy-1.18.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:261fbfced030228bc0f724d5d92f9ae69f46373bdfd0e04a533852677a11dbea"}, + {file = "mypy-1.18.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4dc6b34a1c6875e6286e27d836a35c0d04e8316beac4482d42cfea7ed2527df8"}, + {file = "mypy-1.18.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:1cabb353194d2942522546501c0ff75c4043bf3b63069cb43274491b44b773c9"}, + {file = "mypy-1.18.1-cp310-cp310-win_amd64.whl", hash = "sha256:738b171690c8e47c93569635ee8ec633d2cdb06062f510b853b5f233020569a9"}, + {file = "mypy-1.18.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6c903857b3e28fc5489e54042684a9509039ea0aedb2a619469438b544ae1961"}, + {file = "mypy-1.18.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:2a0c8392c19934c2b6c65566d3a6abdc6b51d5da7f5d04e43f0eb627d6eeee65"}, + {file = "mypy-1.18.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f85eb7efa2ec73ef63fc23b8af89c2fe5bf2a4ad985ed2d3ff28c1bb3c317c92"}, + {file = "mypy-1.18.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:82ace21edf7ba8af31c3308a61dc72df30500f4dbb26f99ac36b4b80809d7e94"}, + {file = "mypy-1.18.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:a2dfd53dfe632f1ef5d161150a4b1f2d0786746ae02950eb3ac108964ee2975a"}, + {file = "mypy-1.18.1-cp311-cp311-win_amd64.whl", hash = "sha256:320f0ad4205eefcb0e1a72428dde0ad10be73da9f92e793c36228e8ebf7298c0"}, + {file = "mypy-1.18.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:502cde8896be8e638588b90fdcb4c5d5b8c1b004dfc63fd5604a973547367bb9"}, + {file = "mypy-1.18.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:7509549b5e41be279afc1228242d0e397f1af2919a8f2877ad542b199dc4083e"}, + {file = "mypy-1.18.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5956ecaabb3a245e3f34100172abca1507be687377fe20e24d6a7557e07080e2"}, + {file = "mypy-1.18.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8750ceb014a96c9890421c83f0db53b0f3b8633e2864c6f9bc0a8e93951ed18d"}, + {file = "mypy-1.18.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:fb89ea08ff41adf59476b235293679a6eb53a7b9400f6256272fb6029bec3ce5"}, + {file = "mypy-1.18.1-cp312-cp312-win_amd64.whl", hash = "sha256:2657654d82fcd2a87e02a33e0d23001789a554059bbf34702d623dafe353eabf"}, + {file = "mypy-1.18.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:d70d2b5baf9b9a20bc9c730015615ae3243ef47fb4a58ad7b31c3e0a59b5ef1f"}, + {file = "mypy-1.18.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:b8367e33506300f07a43012fc546402f283c3f8bcff1dc338636affb710154ce"}, + {file = "mypy-1.18.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:913f668ec50c3337b89df22f973c1c8f0b29ee9e290a8b7fe01cc1ef7446d42e"}, + {file = "mypy-1.18.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1a0e70b87eb27b33209fa4792b051c6947976f6ab829daa83819df5f58330c71"}, + {file = "mypy-1.18.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:c378d946e8a60be6b6ede48c878d145546fb42aad61df998c056ec151bf6c746"}, + {file = "mypy-1.18.1-cp313-cp313-win_amd64.whl", hash = "sha256:2cd2c1e0f3a7465f22731987fff6fc427e3dcbb4ca5f7db5bbeaff2ff9a31f6d"}, + {file = "mypy-1.18.1-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:ba24603c58e34dd5b096dfad792d87b304fc6470cbb1c22fd64e7ebd17edcc61"}, + {file = "mypy-1.18.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:ed36662fb92ae4cb3cacc682ec6656208f323bbc23d4b08d091eecfc0863d4b5"}, + {file = "mypy-1.18.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:040ecc95e026f71a9ad7956fea2724466602b561e6a25c2e5584160d3833aaa8"}, + {file = "mypy-1.18.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:937e3ed86cb731276706e46e03512547e43c391a13f363e08d0fee49a7c38a0d"}, + {file = "mypy-1.18.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:1f95cc4f01c0f1701ca3b0355792bccec13ecb2ec1c469e5b85a6ef398398b1d"}, + {file = "mypy-1.18.1-cp314-cp314-win_amd64.whl", hash = "sha256:e4f16c0019d48941220ac60b893615be2f63afedaba6a0801bdcd041b96991ce"}, + {file = "mypy-1.18.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:e37763af63a8018308859bc83d9063c501a5820ec5bd4a19f0a2ac0d1c25c061"}, + {file = "mypy-1.18.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:51531b6e94f34b8bd8b01dee52bbcee80daeac45e69ec5c36e25bce51cbc46e6"}, + {file = "mypy-1.18.1-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:dbfdea20e90e9c5476cea80cfd264d8e197c6ef2c58483931db2eefb2f7adc14"}, + {file = "mypy-1.18.1-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:99f272c9b59f5826fffa439575716276d19cbf9654abc84a2ba2d77090a0ba14"}, + {file = "mypy-1.18.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:8c05a7f8c00300a52f3a4fcc95a185e99bf944d7e851ff141bae8dcf6dcfeac4"}, + {file = "mypy-1.18.1-cp39-cp39-win_amd64.whl", hash = "sha256:2fbcecbe5cf213ba294aa8c0b8c104400bf7bb64db82fb34fe32a205da4b3531"}, + {file = "mypy-1.18.1-py3-none-any.whl", hash = "sha256:b76a4de66a0ac01da1be14ecc8ae88ddea33b8380284a9e3eae39d57ebcbe26e"}, + {file = "mypy-1.18.1.tar.gz", hash = "sha256:9e988c64ad3ac5987f43f5154f884747faf62141b7f842e87465b45299eea5a9"}, ] [package.dependencies]