Skip to content
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

max-product-of-3-numbers error throw #28

Merged
merged 2 commits into from
Oct 4, 2019
Merged

Conversation

TheSTL
Copy link
Member

@TheSTL TheSTL commented Oct 4, 2019

Changes:

  • Throw error if array length less than 3.

Copy link
Member

@ashokdey ashokdey left a comment

Choose a reason for hiding this comment

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

Please have a look at comment for change.

@@ -9,7 +9,7 @@

/** The following solution is O(nlogn) because of sorting */
function maxProductof3Numbers(arr) {
if (!Array.isArray(arr)) {
if (!Array.isArray(arr) || arr.length <= 2) {
Copy link
Member

Choose a reason for hiding this comment

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

Can't it be arr.length < 3 ? 😕

@TheSTL
Copy link
Member Author

TheSTL commented Oct 4, 2019

Changes are implemented.

Copy link
Member

@ashokdey ashokdey left a comment

Choose a reason for hiding this comment

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

👍

@ashokdey ashokdey merged commit 15cf252 into master Oct 4, 2019
@ashokdey ashokdey deleted the max-product-of-3-numbers branch October 4, 2019 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants