chenyueg / leetcode

One LeetCode problems a day, keeps layoffs away
GNU General Public License v3.0
0 stars 0 forks source link

Problem 3146 not found. #1

Closed chenyueg closed 4 months ago

chenyueg commented 4 months ago

PS D:\code\leetcode> & "C:/Program Files/Python311/python.exe" d:/code/leetcode/problem_finder.py Enter difficulty: Easy (E), Medium (M), Hard (H) [Medium] or a specific Problem ID: 3146 Problem ID 3146 not found or is a paid problem.

However, this problem is publicly accessible here: https://leetcode.com/problems/permutation-difference-between-two-strings/description/

@juyingnan

juyingnan commented 4 months ago

The issue was due to the outdated problems.json file. I did not find a perfect solution to automatically update the problems.json file when an ID was not found in the current list, since LeetCode uses Cloudflare protection.

The current solution is to show a hint to ask the user to go to: https://leetcode.com/api/problems/all/ and manually copy and paste the latest problems.json file.

The original file is a single-line but large JSON file (>2.5 MB). To make fewer changes each time this file is updated, I added a JSON formatter to convert the single-line JSON to a normal multi-line JSON format so the git diff can work for this file. The formatter will run silently (unless it detects that the JSON needs to be formatted) each time the problem finder script is executed.

Also, the simple way, the script will print: "Or, you can call Bunny to solve this problem."

juyingnan commented 4 months ago

I did not expect the JSON file to be frequently updated. So if it changes a lot by Leetcode frequently, it brings another issue: each time it is updated, the total_acs and total_submitted data will also be updated, resulting in 2 x problem_count lines changing.

Since I am not sure if these two lines (and the hidden AC rate calculated by dividing these two data points) will be used in the future, simply removing these two lines when formatting the JSON does not seem to be the best idea.

So let it be.

            "total_acs": 5759632,
            "total_submitted": 16549931,
juyingnan commented 4 months ago

如 solved