-
Notifications
You must be signed in to change notification settings - Fork 268
Classics #10
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
Conversation
} | ||
|
||
// determine the new index | ||
const currentIndex = alphabets.indexOf(currentCharacter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to use Map to find index of currentCharacter instead of indexOf.
- With indexOf complexity will be O(n*26).
- With Map complexity will be O(n).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheSTL, any example snippet would be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove these files, master branch contain updated files :
- src/Problems/find-2-nums-adding-to-n/index.js
- src/Problems/find-2nd-max/index.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove these files, master branch contain updated files :
- src/Problems/find-2-nums-adding-to-n/index.js
- src/Problems/find-2nd-max/index.js
Output: 0 // overflows | ||
Note: | ||
Assume we are dealing with an environment which could only | ||
store integers within the 32-bit signed integer range: [−2^31, 2^31 − 1]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to solve problem for input > 2^31 -1 .
It is also possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can be done, I tried that before adding the return 0;
block. I simply posted the solution for one of the coding challenge platforms.
Deleted the outdated files, then pulled from the master 👍 |
A new folder containing a few of the classic problems like:
.
.
.
etc