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

Commit 3aba645

Browse files
committed
--fix : throw error for invalid argument
1 parent fb7e5a9 commit 3aba645

File tree

1 file changed

+2
-2
lines changed
  • src/_Problems_/max-product-of-3-numbers

1 file changed

+2
-2
lines changed

‎src/_Problems_/max-product-of-3-numbers/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
/** The following solution is O(nlogn) because of sorting */
1111
function maxProductof3Numbers(arr) {
12-
if (!Array.isArray(arr)) {
12+
if (!Array.isArray(arr)||arr.length<=2) {
1313
throw new Error('Invalid Argument');
1414
}
1515

@@ -30,7 +30,7 @@ function maxProductof3Numbers(arr) {
3030

3131
/** The following solution is O(n) */
3232
function maxProductof3NumbersII(arr) {
33-
if (!Array.isArray(arr)) {
33+
if (!Array.isArray(arr)||arr.length<=2) {
3434
throw new Error('Invalid Argument');
3535
}
3636

0 commit comments

Comments
(0)

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