Skip to content

Commit 01f33e1

Browse files
committed
--update : change if condition
1 parent 3aba645 commit 01f33e1

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

+2-2
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) || arr.length <= 2) {
12+
if (!Array.isArray(arr) || arr.length < 3) {
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) || arr.length <= 2) {
33+
if (!Array.isArray(arr) || arr.length < 3) {
3434
throw new Error('Invalid Argument');
3535
}
3636

0 commit comments

Comments
 (0)