This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function solution(A) { | |
| if (A.length < 3) return 0; | |
| A.sort(function(a, b) { | |
| return a - b; | |
| }); | |
| for (var i = 0; i < A.length - 2; i++) { | |
| if (A[i] + A[i + 1] > A[i + 2]) return 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function solution(A) { | |
| if (A.length == 0) return 0; | |
| if (A.length == 1) return 1; | |
| var B = []; | |
| var count = 0; | |
| for (var i = 0; i < A.length; i++) { | |
| if (typeof B[A[i]] === "undefined") { | |
| B[A[i]] = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function solution(A) { | |
| A.sort(function(a, b) { | |
| return a - b; | |
| }); | |
| var max1 = A[A.length - 1] * A[A.length - 2] * A[A.length - 3]; | |
| var max2 = A[A.length - 1] * A[0] * A[1]; | |
| return max1 > max2 ? max1 : max2; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function solution(A) { | |
| var zero = 0; | |
| var count = 0; | |
| for (var i = 0; i < A.length; i++) { | |
| if (A[i] == 0) zero++; | |
| else { | |
| count += 1 * zero; | |
| if (count > 1000000000) return -1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function solution(A, B, K) { | |
| if (A == B) return A % K == 0 ? 1 : 0; | |
| if (K == 1) return B - A + 1; | |
| var count = 0; | |
| var start = 0; | |
| for (var i = A; i <= B; i++) { | |
| if (i % K == 0) { | |
| count++; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function solution(N, A) { | |
| var B = new Array(N); | |
| B.fill(0, 0, N); | |
| var max = 0; | |
| for (let i = 0; i < A.length; i++) { | |
| if (A[i] == N + 1) { | |
| if(A[i+1] == N+1){ | |
| continue; | |
| } else{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function solution(A) { | |
| var N = A.length; | |
| if (N == 1) | |
| if (A[0] == 1) return 1; | |
| else return 0; | |
| var B = []; | |
| for (var i = 0; i < N; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function solution(X, A) { | |
| if (A.length < X) return -1; | |
| if (A.length == 1) return 0; | |
| var B = new Array(X); | |
| var max = -1; | |
| for (var i = 0; i < A.length; i++) { | |
| if (typeof B[A[i] - 1] === "undefined") B[A[i] - 1] = i; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function solution(A) { | |
| var min = 99999999999; | |
| var total = 0; | |
| for (var i = 0; i < A.length; i++) { | |
| total += A[i]; | |
| } | |
| var sum = 0; | |
| for (var j = 0; j < A.length - 1; j++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function solution(A) { | |
| if (A.length == 0) return 1; | |
| var min = 100000; | |
| var max = 0; | |
| var B = []; | |
| for (var i = 0; i < A.length; i++) { | |
| B[A[i]] = 0; | |
| if (A[i] > max) max = A[i]; | |
| if (A[i] < min) min = A[i]; |