aylei / leetcode-rust

my leetcode solutions in rust
Apache License 2.0
723 stars 141 forks source link

Fixed the problem of generating wrong id #17

Closed Qanora closed 4 years ago

Qanora commented 4 years ago

[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 commented 4 years ago

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.

Qanora commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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

mapx commented 4 years ago

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

aylei commented 4 years ago

Thanks! @Qanora

mapx commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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.