Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d01f4f4

Browse files
committed
add problem link and discuss link
1 parent 23ae403 commit d01f4f4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

‎src/main.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,17 @@ fn parse_extra_use(code: &str) -> String {
188188
extra_use_line
189189
}
190190

191+
fn parse_problem_link(problem: &Problem) -> String {
192+
format!("https://leetcode.com/problems/{}/", problem.title_slug)
193+
}
194+
195+
fn parse_discuss_link(problem: &Problem) -> String {
196+
format!(
197+
"https://leetcode.com/problems/{}/discuss/?currentPage=1&orderBy=most_votes&query=",
198+
problem.title_slug
199+
)
200+
}
201+
191202
fn insert_return_in_code(return_type: &str, code: &str) -> String {
192203
let re = Regex::new(r"\{[ \n]+}").unwrap();
193204
match return_type {
@@ -326,7 +337,9 @@ fn deal_problem(problem: &Problem, code: &CodeDefinition, write_mod_file: bool)
326337
&insert_return_in_code(&problem.return_type, &code.default_code),
327338
)
328339
.replace("__PROBLEM_ID__", &format!("{}", problem.question_id))
329-
.replace("__EXTRA_USE__", &parse_extra_use(&code.default_code));
340+
.replace("__EXTRA_USE__", &parse_extra_use(&code.default_code))
341+
.replace("__PROBLEM_LINK__", &parse_problem_link(problem))
342+
.replace("__DISCUSS_LINK__", &parse_discuss_link(problem));
330343

331344
let mut file = fs::OpenOptions::new()
332345
.write(true)

‎template.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
pub struct Solution {}__EXTRA_USE__
77

8+
// problem: __PROBLEM_LINK__
9+
// discuss: __DISCUSS_LINK__
10+
811
// submission codes start here
912

1013
__PROBLEM_DEFAULT_CODE__

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /