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

Minor fixes #9

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
ashokdey merged 5 commits into master from fix-sum-upto-N
Sep 8, 2019
Merged

Minor fixes #9

ashokdey merged 5 commits into master from fix-sum-upto-N
Sep 8, 2019

Conversation

Copy link
Member

@ashokdey ashokdey commented Sep 8, 2019

Changes:

  • Fix in the naming of variables
  • Better comments
  • returning null instead of false

@ashokdey ashokdey added the enhancement New feature or request label Sep 8, 2019

function findSecondMax(arr) {
let max = arr[0];
let max2 = 0;
Copy link
Member

@TheSTL TheSTL Sep 8, 2019
edited
Loading

Choose a reason for hiding this comment

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

Initialize max2 = -1.
If there are no Second Max then function should return -1.
Input : [1,1,1]
Output : -1

Copy link
Member Author

@ashokdey ashokdey Sep 8, 2019

Choose a reason for hiding this comment

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

Oh yes, I find something better

let max2 = Number.MIN_SAFE_INTEGER;

TheSTL reacted with thumbs up emoji
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.

find-2nd-max
Changes required:

  • Initialize Max2 = -1;

}

return nums.length ? nums : false;
return pair.length ? pair : null;
Copy link
Member

@TheSTL TheSTL Sep 8, 2019
edited
Loading

Choose a reason for hiding this comment

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

return false if no pair found

ashokdey reacted with thumbs up emoji
@ashokdey ashokdey merged commit 181b1a6 into master Sep 8, 2019
@ashokdey ashokdey deleted the fix-sum-upto-N branch September 8, 2019 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@TheSTL TheSTL TheSTL approved these changes

Labels
enhancement New feature or request
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants

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