Interact with LeetCode in your development environment.
leetcode_cli info --id 32gives:
32 Hard: Longest Valid Parentheses
Given a string containing just the characters '(' and ')',
return the length of the longest valid (well-formed) parentheses substring.
Example 1:
Input: s = "(()" Output: 2 Explanation: The longest valid parentheses substring is "()".
Example 2:
Input: s = ")()())" Output: 4 Explanation: The longest valid parentheses substring is "()()".
Example 3:
Input: s = "" Output: 0
Constraints:
0 <= s.length <= 3 * 104
s[i] is '(', or ')'.
- Automatic token generation / refresh
- Search problems
- Automatically create test cases based on the problem description
- Download problems in any programming language
- Submit solution(s) for any given problem
run the following command to install leetcode_cli:
git clone https://github.com/dfayd0/leetcode-cli
cd leetcode_cli
cargo install --path .The leetcode_cli tool uses a configuration file to store necessary settings.
The configuration file is located at:
~/.config/leetcode-cli/config.tomland should look like this:
leetcode_token='YOUR_TOKEN_HERE' # (In single quote!) obtained from the cookie section below
default_language="Rust" # could be any language supported by leetcode, re-prompted if not found for a given problem
leetcode_dir_path="~/leetcode" # where to store the downloaded problemsTo obtain your LeetCode token, follow these steps:
Login to LeetCode and obtain the csrftoken from the cookie value.
- After logging in, right-click on the page and press Inspect.
- Refresh the page.
- Look for a network request to https://leetcode.com and select it.
- Look under Request Headers for the "Cookie:" attribute.
- right-click on the cookie value and select Copy Value.
- Paste the values into the config.toml file, in the quotes of leetcode_token entry
For more details on available commands, run:
leetcode_cli --helpFor a specific command, run:
leetcode_cli <command> --helpContributions are welcome! Feel free to open issues or submit pull requests to improve the tool.