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

update difficulties for questions #177

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
seanprashad merged 1 commit into seanprashad:master from leo-step:update-difficulties
Jul 23, 2022

Conversation

Copy link
Contributor

@leo-step leo-step commented Jul 22, 2022
edited
Loading

Hi Sean,

I looked over the difficulties of the questions you have listed and found two that need updating.

Maximum Subarray: Easy -> Medium
Peak Index in a Mountain Array: Easy -> Medium

Everything else looks up to date. Should fix #174.

Here is the short python script I ran if it's helpful.

Thanks!

import requests
from urllib.parse import urlparse
from questions import questions
query = '''query questionData($titleSlug: String!) {
 question(titleSlug: $titleSlug) {
 difficulty
 }
}
'''
for question in questions:
 p = urlparse(question["url"])
 title_slug = p.path.rstrip('/').split('/')[-1]
 our_difficulty = question["difficulty"]
 variables = {"titleSlug": title_slug}
 response = requests.post("https://leetcode.com/graphql",
 json={"query": query, "variables": variables}
 )
 their_difficulty = response.json()["data"]["question"]["difficulty"]
 if their_difficulty != our_difficulty:
 print(f'{question["name"]}: {our_difficulty} -> {their_difficulty}')

seanprashad reacted with heart emoji
@seanprashad seanprashad merged commit fb8b26e into seanprashad:master Jul 23, 2022
Copy link
Owner

seanprashad commented Jul 23, 2022
edited
Loading

A very big thank you for submitting this PR @leo-step - I really appreciate it! Leetcode does update a question's difficulty every so often, but I didn't realize they have a GraphQL endpoint. If you'd be open to it, I'd love for you to submit a separate PR to get credit for your Python script - maybe we could add some lightweight docs on how to use it as well!

Update: I've opened #179 for this!

Copy link
Contributor Author

Awesome, I'll see what I can do about it.

Thanks for putting this site together by the way. I've been using it for just over two months now, and it's been really helpful. Thought I could work on a couple improvements while I'm at it.

@leo-step leo-step mentioned this pull request Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Difficulty Level Not Match

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