The Competitive Programming Helper (CPH) extension allows users to fetch LeetCode problem inputs and outputs directly from the command palette and verify their solutions against the fetched test cases.
Features
Fetch Test Cases: Use the CPH:Fetch Test Cases command to fetch inputs and outputs for any LeetCode problem.
Run Test Cases: Use the CPH:Run Test Cases command to check if your solution produces the correct output for the fetched inputs.
Usage
Fetching Test Cases
Open the command palette (Ctrl+Shift+P or Cmd+Shift+P).
Run the command CPH:Fetch Test Cases.
Enter the LeetCode problem slug (e.g., "two-sum").
The inputs and outputs will be saved to input.txt and output.txt respectively in your workspace folder.
Running Test Cases
Ensure your solution outputs results in the same format as output.txt.
Open the command palette (Ctrl+Shift+P or Cmd+Shift+P).
Run the command CPH:Run Test Cases.
A test_output.txt file will be created with your solution's output.
The extension will compare output.txt and test_output.txt:
If they match, you will see a message: Test cases passed successfully!
If they do not match, you will see a message: Test cases not passed successfully!
Adding More Test Cases
You can add more test cases by writing specific inputs and expected outputs in input.txt and output.txt. Run the CPH:Run Test Cases command to verify if your code produces the correct output.
Notes
Ensure your solution's output format matches the format in output.txt.
The extension supports only two programming languages which includes Python and C++.