A non-empty array A consisting of N integers is given. The consecutive elements of array A represent consecutive cars on a road.
Array A contains only 0s and/or 1s:
- 0 represents a car traveling east,
- 1 represents a car traveling west.
The goal is to count passing cars. We say that a pair of cars (P, Q), where 0 ≤ P < Q < N, is passing when P is traveling to the east and Q is traveling to the west.
For example, consider array A such that:
A[0] = 0 A[1] = 1 A[2] = 0 A[3] = 1 A[4] = 1We have five pairs of passing cars: (0, 1), (0, 3), (0, 4), (2, 3), (2, 4).
Write a function:
function solution(A);
that, given a non-empty array A of N integers, returns the number of pairs of passing cars.
The function should return −1 if the number of pairs of passing cars exceeds 1,000,000,000.
For example, given:
A[0] = 0 A[1] = 1 A[2] = 0 A[3] = 1 A[4] = 1the function should return 5, as explained above.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [1..100,000];
- each element of array A is an integer that can have one of the following values: 0, 1.
// 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 8.9.4)
tempMap = {}
for (i in A) {
if (A[i] === 0) {
tempMap[i] = 1
} else {
tempMap.replaceAll((k, v) -> v + 1);
}
}
}
// 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 8.9.4)
tempMap = {}
for (i in A) {
if (A[i] === 0) {
tempMap[i] = 1
} else {
tempMap.replaceAll((k, v) -> v + 1);
}
}
console.log(tempMap)
}
solution.js:13 tempMap.replaceAll((k, v) -> v + 1); ^ SyntaxError: Unexpected token > at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:392:29) at Promise.resolve.then (/tmp/exec.js:426:34) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
// 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 8.9.4)
tempMap = {}
for (i in A) {
if (A[i] === 0) {
tempMap[i] = 1
} else {
tempMap.replaceAll((k, v) => v + 1);
}
}
console.log(tempMap)
}
TypeError: tempMap.replaceAll is not a function at solution (solution.js:13:21) at solutionWrapper (/tmp/exec.js:402:28) at Promise.resolve.then (/tmp/exec.js:428:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
// 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 8.9.4)
// tempMap = {}
for (i in A) {
if (A[i] === 0) {
tempMap[i] = 1
} else {
tempMap.replaceAll((k, v) => v + 1);
}
}
console.log(tempMap)
}
// 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 8.9.4)
// tempMap = {}
tempArr = []
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
tempArr
}
}
console.log(tempMap)
}
// 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 8.9.4)
// tempMap = {}
tempArr = []
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
tempArr = tempArr.map((val) => {})
}
}
console.log(tempMap)
}
// 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 8.9.4)
// tempMap = {}
tempArr = []
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
tempArr = tempArr.map((val) => { return val++ })
}
}
console.log(tempArr)
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 1, 1 ]
// 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 8.9.4)
// tempMap = {}
tempArr = []
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
tempArr.map((val) => { return val++ })
}
}
console.log(tempArr)
}
// 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 8.9.4)
// tempMap = {}
tempArr = []
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
tempArr.map((val) => { return val++ })
}
}
console.log(tempArr)
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 1, 1 ]
// 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 8.9.4)
// tempMap = {}
tempArr = []
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
tempArr.map((val) => { return val + 1 })
}
}
console.log(tempArr)
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 1, 1 ]
// 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 8.9.4)
// tempMap = {}
tempArr = []
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
tempArr.map(
}
}
console.log(tempArr)
}
// 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 8.9.4)
// tempMap = {}
tempArr = []
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
tempArr.map(function increment)
}
}
console.log(tempArr)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function increment(num) {
return num++
}
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
tempArr.map(function increment)
}
}
console.log(tempArr)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function increment(num) {
return num++
}
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
tempArr.map(increment)
}
}
console.log(tempArr)
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 1, 1 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function increment(num) {
return num++
}
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
return tempArr.map(increment)
}
}
console.log(tempArr)
}
Invalid result type, integer expected, 'object' found
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function increment(num) {
return num++
}
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
tempArr = tempArr.map(increment)
}
}
console.log(tempArr)
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 1, 1 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function increment(num) {
return num++
}
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
let newTempAr = tempArr.map(increment)
}
}
console.log(tempArr)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function increment(num) {
return num++
}
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
let newTempArr = tempArr.map(increment)
}
}
console.log(newTempArr)
}
ReferenceError: newTempArr is not defined at solution (solution.js:24:17) at solutionWrapper (/tmp/exec.js:402:28) at Promise.resolve.then (/tmp/exec.js:428:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function increment(num) {
return num++
}
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
newTempArr = tempArr.map(increment)
}
}
console.log(newTempArr)
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 1, 1 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
newTempArr = tempArr.map(increment)
}
}
console.log(newTempArr)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
newTempArr = tempArr.map(x => x + 1)
}
}
console.log(newTempArr)
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 2, 2 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
temp = tempArr.map(x => x + 1)
}
}
console.log(newTempArr)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (i in A) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
tempArr = tempArr.map(x => x + 1)
}
}
console.log(tempArr)
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 4, 3 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
tempArr = tempArr.map(x => x + 1)
}
}
console.log(tempArr)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i = 0; i < A.length; i++) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else {
// tempMap.replaceAll((k, v) => v + 1);
tempArr = tempArr.map(x => x + 1)
}
}
console.log(tempArr)
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 4, 3 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i = 0; i < A.length; i++) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else if (A[i] === 1) {
// tempMap.replaceAll((k, v) => v + 1);
tempArr = tempArr.map(x => x + 1)
}
}
console.log(tempArr)
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 4, 3 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i = 0; i < A.length; i++) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else if (A[i] === 1) {
// tempMap.replaceAll((k, v) => v + 1);
tempArr = tempArr.map(x => x + 1)
}
}
console.log(tempArr)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i = 0; i < A.length; i++) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(1)
} else if (A[i] === 1) {
// tempMap.replaceAll((k, v) => v + 1);
tempArr = tempArr.map(x => x + 1)
}
console.log(tempArr)
}
console.log(tempArr)
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 1 ] [ 2 ] [ 2, 1 ] [ 3, 2 ] [ 4, 3 ] [ 4, 3 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i = 0; i < A.length; i++) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(0)
} else if (A[i] === 1) {
// tempMap.replaceAll((k, v) => v + 1);
tempArr = tempArr.map(x => x + 1)
}
console.log(tempArr)
}
console.log(tempArr)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i = 0; i < A.length; i++) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(0)
} else if (A[i] === 1) {
// tempMap.replaceAll((k, v) => v + 1);
tempArr = tempArr.map(x => x + 1)
}
console.log(tempArr)
}
console.log(tempArr)
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 0 ] [ 1 ] [ 1, 0 ] [ 2, 1 ] [ 3, 2 ] [ 3, 2 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i = 0; i < A.length; i++) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(0)
} else if (A[i] === 1) {
// tempMap.replaceAll((k, v) => v + 1);
tempArr = tempArr.map(x => x + 1)
}
// console.log(tempArr)
}
console.log(tempArr)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i = 0; i < A.length; i++) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(0)
} else if (A[i] === 1) {
// tempMap.replaceAll((k, v) => v + 1);
tempArr = tempArr.map(x => x + 1)
}
// console.log(tempArr)
}
console.log(tempArr.reduce((a,b) => a + b))
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
5
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i = 0; i < A.length; i++) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(0)
} else if (A[i] === 1) {
// tempMap.replaceAll((k, v) => v + 1);
tempArr = tempArr.map(x => x + 1)
}
// console.log(tempArr)
}
return tempArr.reduce((a,b) => a + b)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i = 0; i < A.length; i++) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(0)
} else if (A[i] === 1) {
// tempMap.replaceAll((k, v) => v + 1);
tempArr = tempArr.map(x => x + 1)
}
// console.log(tempArr)
}
return tempArr.reduce((a,b) => a + b)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i = 0; i < A.length; i++) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(0)
} else if (A[i] === 1) {
// tempMap.replaceAll((k, v) => v + 1);
if (tempArr.length > 0) {
}
tempArr = tempArr.map(x => x + 1)
}
// console.log(tempArr)
}
return tempArr.reduce((a,b) => a + b)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i = 0; i < A.length; i++) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(0)
} else if (A[i] === 1) {
// tempMap.replaceAll((k, v) => v + 1);
if (tempArr.length > 0) {
tempArr = tempArr.map(x => x + 1)
}
}
// console.log(tempArr)
}
return tempArr.reduce((a,b) => a + b)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i = 0; i < A.length; i++) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(0)
} else if (A[i] === 1) {
// tempMap.replaceAll((k, v) => v + 1);
if (tempArr.length > 0) {
tempArr = tempArr.map(x => x + 1)
}
}
// console.log(tempArr)
}
return tempArr.reduce((a,b) => a + b)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i = 0; i < A.length; i++) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(0)
} else if (A[i] === 1) {
// tempMap.replaceAll((k, v) => v + 1);
if (tempArr.length > 0) {
tempArr = tempArr.map(x => x + 1)
}
}
// console.log(tempArr)
}
return tempArr.reduce((a,b) => a + b)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
// function increment(num) {
// return num++
// }
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
// tempMap = {}
tempArr = []
let newTempArr;
for (let i = 0; i < A.length; i++) {
if (A[i] === 0) {
// tempMap[i] = 1
tempArr.push(0)
} else if (A[i] === 1) {
// tempMap.replaceAll((k, v) => v + 1);
if (tempArr.length > 0) {
tempArr = tempArr.map(x => x + 1)
}
}
// console.log(tempArr)
}
return tempArr.reduce((a,b) => a + b)
}
The following issues have been detected: runtime errors, timeout errors.
For example, for the input [1] the solution terminated unexpectedly.
TypeError: Reduce of empty array with no initial value at Array.reduce (<anonymous>) at solution (solution.js:28:20) at solutionWrapper (/tmp/exec.js:402:28) at Promise.resolve.then (/tmp/exec.js:428:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
TypeError: Reduce of empty array with no initial value at Array.reduce (<anonymous>) at solution (solution.js:28:20) at solutionWrapper (/tmp/exec.js:402:28) at Promise.resolve.then (/tmp/exec.js:428:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
0..01..1, length = ~100,000
Killed. Hard limit reached: 6.000 sec.
0101..01, length = ~100,000
Killed. Hard limit reached: 6.000 sec.
large test with all 1s/0s, length = ~100,000
tested program terminated with exit code 1
TypeError: Reduce of empty array with no initial value at Array.reduce (<anonymous>) at solution (solution.js:28:20) at solutionWrapper (/tmp/exec.js:402:28) at Promise.resolve.then (/tmp/exec.js:428:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3