Skip to content

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

Merged
merged 12 commits into from
Sep 22, 2019
Merged

Classics #10

merged 12 commits into from
Sep 22, 2019

Conversation

ashokdey
Copy link
Member

@ashokdey ashokdey commented Sep 8, 2019

A new folder containing a few of the classic problems like:

  • Caesar Cipher
  • Fibonacci
  • Segmented Sieve
    .
    .
    .
    etc

@ashokdey ashokdey requested a review from TheSTL September 8, 2019 18:10
@ashokdey ashokdey self-assigned this Sep 8, 2019
}

// determine the new index
const currentIndex = alphabets.indexOf(currentCharacter);
Copy link
Member

@TheSTL TheSTL Sep 8, 2019

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).

Copy link
Member Author

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.

Copy link
Member

@TheSTL TheSTL Sep 8, 2019

Choose a reason for hiding this comment

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

Copy link
Member

@TheSTL TheSTL left a 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

Copy link
Member

@TheSTL TheSTL left a 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].
Copy link
Member

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.

Copy link
Member Author

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.

@ashokdey
Copy link
Member Author

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

Deleted the outdated files, then pulled from the master 👍

@ashokdey ashokdey merged commit 4ff441b into master Sep 22, 2019
@ashokdey ashokdey deleted the classics branch September 22, 2019 19:47
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.

2 participants