lc-show
Show LeetCode problem details and generate Rust template (project)
When & Why to Use This Skill
The LeetCode Show skill streamlines the workflow for developers practicing algorithms in Rust. It automates the process of fetching LeetCode problem descriptions, generating standardized Rust code templates, and organizing them into a local project structure, allowing users to focus entirely on problem-solving and logic implementation.
Use Cases
- Algorithm Practice: Quickly set up a local Rust environment for any LeetCode problem by ID to practice data structures and algorithms efficiently.
- Technical Interview Preparation: Streamline the study process by instantly accessing problem requirements and boilerplate code without manual copy-pasting.
- Rust Language Learning: Use the generated templates to master Rust syntax and the standard library through hands-on competitive programming exercises.
- Workflow Automation: Integrate LeetCode tasks into a local development environment, enabling the use of personal IDEs and CLI tools for testing and submission.
| name | lc-show |
|---|---|
| description | Show LeetCode problem details and generate Rust template (project) |
LeetCode Show
Show problem details and generate Rust template in problems/ directory.
Usage
/lc-show <problem_id> - Show problem and generate Rust code template
Instructions
- Run
leetcode show <problem_id> 2>/dev/nullto display the problem description - Show the problem details to the user
- Run
leetcode show <problem_id> -g -l rust 2>/dev/nullto generate the Rust template - Move the generated file to
problems/directory:mv <problem_id>.<problem-name>.rs problems/ - Tell the user the file is ready at
problems/<problem_id>.<problem-name>.rs
File Format
use std::collections::HashMap; // if needed
impl Solution {
pub fn function_name(...) -> ... {
// implementation
}
}
Note: struct Solution; は含めない(LeetCode側で定義されるため)。rust-analyzer用には build.rs が lib.rs 経由で提供する。
Commands
- Test:
leetcode test problems/<file>.rs - Submit:
leetcode submit problems/<file>.rs