Skip to content

add solutions in directory according to the difficulty#230

Open
samipsuwal wants to merge 1 commit intoQasimWani:mainfrom
samipsuwal:directory-according-to-difficulty
Open

add solutions in directory according to the difficulty#230
samipsuwal wants to merge 1 commit intoQasimWani:mainfrom
samipsuwal:directory-according-to-difficulty

Conversation

@samipsuwal
Copy link
Copy Markdown

modified URL to upload solutions respective to the difficulty of the solution

Copy link
Copy Markdown

@vikas-deshpande vikas-deshpande left a comment

Choose a reason for hiding this comment

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

Where is the difficulty defined?

@samipsuwal
Copy link
Copy Markdown
Author

Hi Vikas,
I looked at some of the declarations and associated the var difficulty with the question's difficulty level.
Then, I looked deeply into the leetcode.js and at line 461, I found the code checking and assigning the appropriate difficulty.
I have tested this addition of directory with 10-12 submissions. They all worked as expected.

@vikas-deshpande
Copy link
Copy Markdown

Hi Vikas, I looked at some of the declarations and associated the var difficulty with the question's difficulty level. Then, I looked deeply into the leetcode.js and at line 461, I found the code checking and assigning the appropriate difficulty. I have tested this addition of directory with 10-12 submissions. They all worked as expected.

Got it, thanks!

Comment thread scripts/leetcode.js
) => {
// To validate user, load user object from GitHub.
const URL = `https://api.github.com/repos/${hook}/contents/${directory}/${filename}`;
const URL = `https://api.github.com/repos/${hook}/contents/${difficulty}/${directory}/${filename}`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'd put a check that difficulty is assigned, and if not - I'd print out some kind of error, or log it somehow. You're working with the globally set variable, it'll help to ensure it's initialized.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can you please help to check the above comment @samipsuwal?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@NikitaShkaruba @karankap00r adding an if-else is making the code async, due to which URL is not being instantiated on time.
Adding a log isn't difficult,
However, in addition to that, a proper solution would be to wrap the if-else in an asynchronous call and continue the rest of the code of the function in the callback.
I might not be understanding something here. wdy think?

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.

4 participants