Skip to content

Fixed the problem of generating wrong id #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2020
Merged

Conversation

Qanora
Copy link
Contributor

@Qanora Qanora commented Jan 22, 2020

[description]
when i typed 1000,
I got n1030_minimum_cost_to_merge_stones.rs
[fixed]
Incorrect use tag "problem.stat.frontend_question_id" vs "problem.stat.question_id"

@mapx
Copy link

mapx commented Jan 23, 2020

Leetcode problems have both "frontend id" and "backend id". All problems in the repo are indexed with their "backend id". The framework accepts "frontend id" to generate the problem file (with backend id).

It's a feature by design, for some reason.

@@ -42,7 +42,7 @@ pub fn get_problem(frontend_question_id: u32) -> Option<Problem> {
content: resp.data.question.content,
sample_test_case: resp.data.question.sample_test_case,
difficulty: problem.difficulty.to_string(),
question_id: problem.stat.question_id,
question_id: problem.stat.frontend_question_id,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Judging by problem.stat.frontend_question_id at line 23
Generating from question_id: problem.stat.question_id at line 45

@Qanora
Copy link
Contributor Author

Qanora commented Jan 23, 2020

Leetcode problems have both "frontend id" and "backend id". All problems in the repo are indexed with their "backend id". The framework accepts "frontend id" to generate the problem file (with backend id).

It's a feature by design, for some reason.

I am not quite sure why it is a feature ( indexed by front id but generated by backend id)

@aylei
Copy link
Owner

aylei commented Jan 23, 2020

@Qanora I have not noticed that the frontend_question_id may differ from the question_id, I just assumed that they would always be same previously.

Here is my conclusion after looking at the response of leetcode API:

The frontend_question_id is the ordinal displayed in the problem list:

image

While question_id seems to be an unique identifier of an question. And seems that there is no strong relation between these two ids (the frontend_question_id of question id 1049 is 999). Because most of the tutorials and blogs refers to leetcode questions by frontend_question_id (e.g. "Solution of leetcode #1000"), I think generate the question file with frontend_question_id would be better.

@Qanora
Copy link
Contributor Author

Qanora commented Jan 23, 2020

I agree with you, so is this ready to merge? @aylei

@mapx
Copy link

mapx commented Jan 23, 2020

All existing problem files need id remapping for consistency as well, with respect to this update.

Copy link
Owner

@aylei aylei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aylei
Copy link
Owner

aylei commented Jan 23, 2020

Thanks! @Qanora

@aylei aylei merged commit 3373054 into aylei:master Jan 23, 2020
@mapx
Copy link

mapx commented Feb 15, 2020

I found frontend_question_id not as stable as question_id.

When you generated problem 1344, you got n1344_jump_game_v.rs a few days ago, but it's n1344_angle_between_hands_of_a_clock.rs now.

Confusing...

@Qanora
Copy link
Contributor Author

Qanora commented Feb 15, 2020

I found frontend_question_id not as stable as question_id.

When you generated problem 1344, you got n1344_jump_game_v.rs a few days ago, but it's n1344_angle_between_hands_of_a_clock.rs now.

Confusing...

I tried to generate problem 1344 on this commit and the latest master branch, i got p1344_angle_between_hands_of_a_clock.rs. It looks like fine.

@mapx
Copy link

mapx commented Feb 15, 2020

I tried to generate problem 1344 on this commit and the latest master branch, i got p1344_angle_between_hands_of_a_clock.rs. It looks like fine.

It's the fact that leetcode team sometimes shifts front-end id. "Jump Game V" was 1344 and is 1340. IMO, current PR has no fault. There is no easy way to deal with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants