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
export function solution(given) { | |
var highest = [0, 0, 0]; | |
for (var i=0; i<given.length; i++) { | |
var prev = given[i]; | |
var next = !given[i + 1] ? 0 : given[i + 1]; | |
var total = prev * next; | |
if (total > highest[2]) { | |
highest = [prev, next, prev * next]; | |
} | |
} |
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
import React, { Component } from 'react'; | |
import Popper from 'popper.js'; | |
class RangeRef { | |
rect = {}; | |
constructor(rect) { | |
if (rect) { | |
this.rect = rect; | |
} |
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(height) { | |
var tree = []; | |
for (var i=0; i<5; i++) { | |
var child = "*"; | |
for(var s=0; s<i; s++) { | |
child = child + "*" | |
} | |
tree[i] = child; | |
} |
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) { | |
// write your code in JavaScript (Node.js 4.0.0) | |
var B = []; | |
for(var i = 0; i < A.length; i++){ | |
var index = B.indexOf(A[i]); | |
if(index > -1) B.splice(index, 1); | |
else B.push(A[i]); | |
} | |
return B[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
// you can write to stdout for debugging purposes, e.g. | |
// console.log('this is a debug message'); | |
function solution(A) { | |
// write your code in JavaScript (Node.js 6.4.0) | |
return A.filter((x, y, z) => z.indexOf(x) === y).length; | |
} |
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) { | |
// write your code in JavaScript (Node.js 6.4.0) | |
var str = (N >>> 0).toString(2).split(''); | |
var items = []; | |
var flag = false; | |
for (var i=0; i<str.length; i++) { | |
if (str[i] !== "0") { | |
flag = false; |
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 p, idx; | |
var leftSum = 0, rightSum = 0; | |
var totalSum = 0; | |
var lastMin, currentMin; | |
var N = A.length; | |
if (N == 2) { return Math.abs(A[0] - A[1]); } | |
if (N == 1) { return Math.abs(A[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, K) { | |
// write your code in JavaScript (Node.js 6.4.0) | |
var TMP = A; | |
for (var i=0; i<K; i++) { | |
var PART = TMP.slice(1, -1); | |
var FIRST = TMP.slice(0, 1); | |
var LAST = TMP.slice(-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) { | |
var min = 1; | |
A.sort(function(a,b){ | |
return a - b; | |
}); | |
for (var i in A) { | |
if (A[i] > -1 && A[i] === min) { | |
min++; |
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, y, d) { | |
const afterFirstJump = (85 - 10); | |
if (afterFirstJump % d == 0) { | |
return Math.floor(afterFirstJump / d); | |
} | |
return Math.floor(afterFirstJump / d + 1); | |
} |