An array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first place. For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9, 7] (elements are shifted right by one index and 6 is moved to the first place).
The goal is to rotate array A K times; that is, each element of A will be shifted to the right K times.
Write a function:
function solution(A, K);
that, given an array A consisting of N integers and an integer K, returns the array A rotated K times.
For example, given
A = [3, 8, 9, 7, 6] K = 3the function should return [9, 7, 6, 3, 8]. Three rotations were made:
[3, 8, 9, 7, 6] -> [6, 3, 8, 9, 7] [6, 3, 8, 9, 7] -> [7, 6, 3, 8, 9] [7, 6, 3, 8, 9] -> [9, 7, 6, 3, 8]For another example, given
A = [0, 0, 0] K = 1the function should return [0, 0, 0]
Given
A = [1, 2, 3, 4] K = 4the function should return [1, 2, 3, 4]
Assume that:
- N and K are integers within the range [0..100];
- each element of array A is an integer within the range [−1,000..1,000].
In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment.
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log([..Array(100).keys()])
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], 100]
solution.js:6 console.log([..Array(100).keys()]) ^ SyntaxError: Unexpected token . at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:401:29) at Promise.resolve.then (/tmp/exec.js:435: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
solution.js:6 console.log([..Array(100).keys()]) ^ SyntaxError: Unexpected token . at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:401:29) at Promise.resolve.then (/tmp/exec.js:435: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
solution.js:6 console.log([..Array(100).keys()]) ^ SyntaxError: Unexpected token . at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:401:29) at Promise.resolve.then (/tmp/exec.js:435: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
solution.js:6 console.log([..Array(100).keys()]) ^ SyntaxError: Unexpected token . at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:401:29) at Promise.resolve.then (/tmp/exec.js:435: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
solution.js:6 console.log([..Array(100).keys()]) ^ SyntaxError: Unexpected token . at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:401:29) at Promise.resolve.then (/tmp/exec.js:435: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
solution.js:6 console.log([..Array(100).keys()]) ^ SyntaxError: Unexpected token . at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:401:29) at Promise.resolve.then (/tmp/exec.js:435: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
solution.js:6 console.log([..Array(100).keys()]) ^ SyntaxError: Unexpected token . at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:401:29) at Promise.resolve.then (/tmp/exec.js:435: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
solution.js:6 console.log([..Array(100).keys()]) ^ SyntaxError: Unexpected token . at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:401:29) at Promise.resolve.then (/tmp/exec.js:435: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, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log([..Array(100).keys()])
for (const x of Array(100).keys()) {
console.log(x)
}
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], 100]
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log([..Array(100).keys()])
for (const x of Array(100).keys()) {
console.log(x,)
}
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], 100]
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log([..Array(100).keys()])
let array = []
for (const x of Array(100).keys()) {
array.append(x)
}
console.log(array)
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], 100]
TypeError: array.append is not a function at solution (solution.js:9:15) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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: array.append is not a function at solution (solution.js:9:15) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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: array.append is not a function at solution (solution.js:9:15) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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: array.append is not a function at solution (solution.js:9:15) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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: array.append is not a function at solution (solution.js:9:15) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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: array.append is not a function at solution (solution.js:9:15) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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: array.append is not a function at solution (solution.js:9:15) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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: array.append is not a function at solution (solution.js:9:15) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log([..Array(100).keys()])
let array = []
for (const x of Array(100).keys()) {
array.p(x)
}
console.log(array)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log([..Array(100).keys()])
let array = []
for (const x of Array(100).keys()) {
array.push(x)
}
console.log(array)
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], 100]
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
Invalid result type, Array expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log([..Array(100).keys()])
let array = []
for (const x of Array(100).keys()) {
array.push(x)
}
console.log(array)
return 0
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log([..Array(100).keys()])
let array = []
for (const x of Array(100).keys()) {
array.push(x)
}
console.log(array)
return [0]
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log([..Array(100).keys()])
let array = []
for (const x of Array(100).keys()) {
array.push(x)
}
console.log(array)
return [0]
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], 100]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
function result: [0]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
function result: [0]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
function result: [0]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
function result: [0]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
function result: [0]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log([..Array(100).keys()])
let array = []
for (const x of Array(100).keys()) {
array.push(x)
}
console.log(array)
return array
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], 100]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
function result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
function result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
function result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
function result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
function result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log([..Array(100).keys()])
let array = []
for (const x of Array(100).keys()) {
array.push(x)
}
console.log(array)
return array
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
let i = 0;
let shiftedArray = A
while (i < K) {
}
}
function moveArray1(A) {
let last = A.pop();
return A.unshift(last)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
let i = 0;
let shiftedArray = A;
while (i < K) {
}
}
function moveArray1(A) {
let last = A.pop();
return A.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray =
}
}
function moveArray1(A) {
let last = A.pop();
return A.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArra
}
function moveArray1(A) {
let last = A.pop();
return A.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(A) {
let last = A.pop();
return A.unshift(last);
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 100]
TypeError: A.pop is not a function at moveArray1 (solution.js:16:18) at solution (solution.js:9:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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
Invalid result type, Array expected, 'number' found
TypeError: A.pop is not a function at moveArray1 (solution.js:16:18) at solution (solution.js:9:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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: A.pop is not a function at moveArray1 (solution.js:16:18) at solution (solution.js:9:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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
function result: [1, 2, 3]
TypeError: A.pop is not a function at moveArray1 (solution.js:16:18) at solution (solution.js:9:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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: A.pop is not a function at moveArray1 (solution.js:16:18) at solution (solution.js:9:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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: A.pop is not a function at moveArray1 (solution.js:16:18) at solution (solution.js:9:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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, K) {
// write your code in JavaScript (Node.js 8.9.4)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(A) {
let last = A.pop();
return A.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(K)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(A) {
let last = A.pop();
return A.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(K)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(A) {
let last = A.pop();
return A.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(K)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(A) {
let last = A.pop();
return A.unshift(last);
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 100]
TypeError: A.pop is not a function at moveArray1 (solution.js:18:18) at solution (solution.js:11:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 3, 8, 9, 7, 6 ] 3
Invalid result type, Array expected, 'number' foundstdout:
[ 0, 0, 0 ] 1
TypeError: A.pop is not a function at moveArray1 (solution.js:18:18) at solution (solution.js:11:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1, 2, 3, 4 ] 4
TypeError: A.pop is not a function at moveArray1 (solution.js:18:18) at solution (solution.js:11:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 0, 0, 0 ] 4
function result: [1, 2, 3]
[ 1, 2, 3 ] 0
TypeError: A.pop is not a function at moveArray1 (solution.js:18:18) at solution (solution.js:11:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1 ] 4
TypeError: A.pop is not a function at moveArray1 (solution.js:18:18) at solution (solution.js:11:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ -1000, 0, 1000 ] 7
TypeError: A.pop is not a function at moveArray1 (solution.js:18:18) at solution (solution.js:11:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ] 100
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(typef )
console.log(K)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(A) {
let last = A.pop();
return A.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(typeof A)
console.log(K)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(A) {
let last = A.pop();
return A.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(typeof A)
console.log(K)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(A) {
let last = A.pop();
return A.unshift(last);
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 100]
TypeError: A.pop is not a function at moveArray1 (solution.js:19:18) at solution (solution.js:12:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 3, 8, 9, 7, 6 ] object 3
Invalid result type, Array expected, 'number' foundstdout:
[ 0, 0, 0 ] object 1
TypeError: A.pop is not a function at moveArray1 (solution.js:19:18) at solution (solution.js:12:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1, 2, 3, 4 ] object 4
TypeError: A.pop is not a function at moveArray1 (solution.js:19:18) at solution (solution.js:12:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 0, 0, 0 ] object 4
function result: [1, 2, 3]
[ 1, 2, 3 ] object 0
TypeError: A.pop is not a function at moveArray1 (solution.js:19:18) at solution (solution.js:12:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1 ] object 4
TypeError: A.pop is not a function at moveArray1 (solution.js:19:18) at solution (solution.js:12:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ -1000, 0, 1000 ] object 7
TypeError: A.pop is not a function at moveArray1 (solution.js:19:18) at solution (solution.js:12:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ] object 100
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(A)
console.log(K)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(A) {
let last = A.pop();
return A.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(A) {
let last = A.pop();
return A.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(A) {
let last = A.pop();
return A.unshift(last);
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 100]
TypeError: A.pop is not a function at moveArray1 (solution.js:19:18) at solution (solution.js:12:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 3, 8, 9, 7, 6 ] true 3
Invalid result type, Array expected, 'number' foundstdout:
[ 0, 0, 0 ] true 1
TypeError: A.pop is not a function at moveArray1 (solution.js:19:18) at solution (solution.js:12:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1, 2, 3, 4 ] true 4
TypeError: A.pop is not a function at moveArray1 (solution.js:19:18) at solution (solution.js:12:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 0, 0, 0 ] true 4
function result: [1, 2, 3]
[ 1, 2, 3 ] true 0
TypeError: A.pop is not a function at moveArray1 (solution.js:19:18) at solution (solution.js:12:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1 ] true 4
TypeError: A.pop is not a function at moveArray1 (solution.js:19:18) at solution (solution.js:12:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ -1000, 0, 1000 ] true 7
TypeError: A.pop is not a function at moveArray1 (solution.js:19:18) at solution (solution.js:12:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ] true 100
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(a) {
let last = A.pop();
return A.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
let last = movingArray.pop();
return A.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
let last = movingArray.pop();
return movingArray.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
let last = movingArray.pop();
return movingArray.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
let last = movingArray.pop();
return movingArray.unshift(last);
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 100]
TypeError: movingArray.pop is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 3, 8, 9, 7, 6 ] true 3 [ 3, 8, 9, 7, 6 ]
Invalid result type, Array expected, 'number' foundstdout:
[ 0, 0, 0 ] true 1 [ 0, 0, 0 ]
TypeError: movingArray.pop is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1, 2, 3, 4 ] true 4 [ 1, 2, 3, 4 ]
TypeError: movingArray.pop is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 0, 0, 0 ] true 4 [ 0, 0, 0 ]
function result: [1, 2, 3]
[ 1, 2, 3 ] true 0 [ 1, 2, 3 ]
TypeError: movingArray.pop is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1 ] true 4 [ 1 ]
TypeError: movingArray.pop is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ -1000, 0, 1000 ] true 7 [ -1000, 0, 1000 ]
TypeError: movingArray.pop is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ] true 100 [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
let last = movingArray.pop();
return movingArray.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
let last = movingArray.pop();
return movingArray.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
let last = movingArray.pop();
return movingArray.unshift(last);
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
TypeError: movingArray.pop is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 3, 8, 9, 7, 6 ] true 3 [ 3, 8, 9, 7, 6 ]
Invalid result type, Array expected, 'number' foundstdout:
[ 0, 0, 0 ] true 1 [ 0, 0, 0 ]
TypeError: movingArray.pop is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1, 2, 3, 4 ] true 4 [ 1, 2, 3, 4 ]
TypeError: movingArray.pop is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 0, 0, 0 ] true 4 [ 0, 0, 0 ]
function result: [1, 2, 3]
[ 1, 2, 3 ] true 0 [ 1, 2, 3 ]
TypeError: movingArray.pop is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1 ] true 4 [ 1 ]
TypeError: movingArray.pop is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ -1000, 0, 1000 ] true 7 [ -1000, 0, 1000 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
let last = movingArray.slice();
return movingArray.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
let last = movingArray.slice(movingArray.length, );
return movingArray.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
let last = movingArray.slice(movingArray.length -1, movingArray.length);
return movingArray.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
let last = movingArray.slice(movingArray.length -1, movingArray.length)[0];
return movingArray.unshift(last);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
let last = movingArray.slice(movingArray.length -1, movingArray.length)[0];
return movingArray.unshift(last);
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
TypeError: movingArray.slice is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 3, 8, 9, 7, 6 ] true 3 [ 3, 8, 9, 7, 6 ]
Invalid result type, Array expected, 'number' foundstdout:
[ 0, 0, 0 ] true 1 [ 0, 0, 0 ]
TypeError: movingArray.slice is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1, 2, 3, 4 ] true 4 [ 1, 2, 3, 4 ]
TypeError: movingArray.slice is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 0, 0, 0 ] true 4 [ 0, 0, 0 ]
function result: [1, 2, 3]
[ 1, 2, 3 ] true 0 [ 1, 2, 3 ]
TypeError: movingArray.slice is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1 ] true 4 [ 1 ]
TypeError: movingArray.slice is not a function at moveArray1 (solution.js:20:28) at solution (solution.js:13:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ -1000, 0, 1000 ] true 7 [ -1000, 0, 1000 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
let last = movingArray.slice(movingArray.length -1, movingArray.length)[0];
return movingArray.unshift(last);
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
let last = shiftedArray.slice(shiftedArray.length -1, shiftedArray.length)[0];
return movingArray.unshift(last);
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
let last = shiftedArray.slice(shiftedArray.length -1, shiftedArray.length)[0];
return shiftedArray.unshift(last);
shiftedArray = moveArray1(shiftedArray);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
let last = shiftedArray.slice(shiftedArray.length -1, shiftedArray.length)[0];
shiftedArray = shiftedArray.unshift(last);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
let last = shiftedArray.slice(shiftedArray.length -1, shiftedArray.length)[0];
shiftedArray = shiftedArray.unshift(last);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
TypeError: shiftedArray.slice is not a function at solution (solution.js:13:33) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 3, 8, 9, 7, 6 ] true 3 [ 3, 8, 9, 7, 6 ]
Invalid result type, Array expected, 'number' foundstdout:
[ 0, 0, 0 ] true 1 [ 0, 0, 0 ]
TypeError: shiftedArray.slice is not a function at solution (solution.js:13:33) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1, 2, 3, 4 ] true 4 [ 1, 2, 3, 4 ]
TypeError: shiftedArray.slice is not a function at solution (solution.js:13:33) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 0, 0, 0 ] true 4 [ 0, 0, 0 ]
function result: [1, 2, 3]
[ 1, 2, 3 ] true 0 [ 1, 2, 3 ]
TypeError: shiftedArray.slice is not a function at solution (solution.js:13:33) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1 ] true 4 [ 1 ]
TypeError: shiftedArray.slice is not a function at solution (solution.js:13:33) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ -1000, 0, 1000 ] true 7 [ -1000, 0, 1000 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = ne A;
console.log(shiftedArray)
while (i < K) {
let last = shiftedArray.slice(shiftedArray.length -1, shiftedArray.length)[0];
shiftedArray = shiftedArray.unshift(last);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = new A;
console.log(shiftedArray)
while (i < K) {
let last = shiftedArray.slice(shiftedArray.length -1, shiftedArray.length)[0];
shiftedArray = shiftedArray.unshift(last);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
TypeError: A is not a constructor at solution (solution.js:10:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 3, 8, 9, 7, 6 ] true 3
TypeError: A is not a constructor at solution (solution.js:10:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 0, 0, 0 ] true 1
TypeError: A is not a constructor at solution (solution.js:10:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1, 2, 3, 4 ] true 4
TypeError: A is not a constructor at solution (solution.js:10:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 0, 0, 0 ] true 4
TypeError: A is not a constructor at solution (solution.js:10:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1, 2, 3 ] true 0
TypeError: A is not a constructor at solution (solution.js:10:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1 ] true 4
TypeError: A is not a constructor at solution (solution.js:10:24) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ -1000, 0, 1000 ] true 7
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
let last = shiftedArray.slice(shiftedArray.length -1, shiftedArray.length)[0];
shiftedArray = shiftedArray.unshift(last);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
let last = shiftedArray.slice(shiftedArray.length -1, shiftedArray.length)[0];
shiftedArray = shiftedArray.unshift(last);
i += 1
}
return shiftedArray
}
function moveArray1(movingArray) {
}
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
TypeError: shiftedArray.slice is not a function at solution (solution.js:13:33) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 3, 8, 9, 7, 6 ] true 3 [ 3, 8, 9, 7, 6 ]
Invalid result type, Array expected, 'number' foundstdout:
[ 0, 0, 0 ] true 1 [ 0, 0, 0 ]
TypeError: shiftedArray.slice is not a function at solution (solution.js:13:33) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1, 2, 3, 4 ] true 4 [ 1, 2, 3, 4 ]
TypeError: shiftedArray.slice is not a function at solution (solution.js:13:33) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 0, 0, 0 ] true 4 [ 0, 0, 0 ]
function result: [1, 2, 3]
[ 1, 2, 3 ] true 0 [ 1, 2, 3 ]
TypeError: shiftedArray.slice is not a function at solution (solution.js:13:33) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1 ] true 4 [ 1 ]
TypeError: shiftedArray.slice is not a function at solution (solution.js:13:33) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ -1000, 0, 1000 ] true 7 [ -1000, 0, 1000 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
let last = shiftedArray.slice(shiftedArray.length -1, shiftedArray.length)[0];
shiftedArray = shiftedArray.unshift(last);
i += 1
}
return shiftedArray
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
let last = shiftedArray[shiftedArray.length)[0];
shiftedArray = shiftedArray.unshift(last);
i += 1
}
return shiftedArray
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
let last = shiftedArray[shiftedArray.length];
shiftedArray = shiftedArray.unshift(last);
i += 1
}
return shiftedArray
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
let last = shiftedArray[shiftedArray.length];
shiftedArray = shiftedArray.unshift(last);
i += 1
}
return shiftedArray
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
while (i < K) {
let last = shiftedArray[shiftedArray.length];
shiftedArray = shiftedArray.unshift(last);
i += 1
}
return shiftedArray
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
if (A.length) {
while (i < K) {
let last = shiftedArray[shiftedArray.length];
shiftedArray = shiftedArray.unshift(last);
i += 1
}
return shiftedArray
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
if (A.length) {
while (i < K) {
let last = shiftedArray[shiftedArray.length];
shiftedArray = shiftedArray.unshift(last);
i += 1
}
}
return shiftedArray
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
if (A.length) {
while (i < K) {
let last = shiftedArray[shiftedArray.length];
shiftedArray = shiftedArray.unshift(last);
i += 1
}
}
return shiftedArray
}
[[], 4]
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
TypeError: shiftedArray.unshift is not a function at solution (solution.js:15:41) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 3, 8, 9, 7, 6 ] true 3 [ 3, 8, 9, 7, 6 ]
Invalid result type, Array expected, 'number' foundstdout:
[ 0, 0, 0 ] true 1 [ 0, 0, 0 ]
TypeError: shiftedArray.unshift is not a function at solution (solution.js:15:41) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1, 2, 3, 4 ] true 4 [ 1, 2, 3, 4 ]
function result: []
[] true 4 []
TypeError: shiftedArray.unshift is not a function at solution (solution.js:15:41) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 0, 0, 0 ] true 4 [ 0, 0, 0 ]
function result: [1, 2, 3]
[ 1, 2, 3 ] true 0 [ 1, 2, 3 ]
TypeError: shiftedArray.unshift is not a function at solution (solution.js:15:41) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ 1 ] true 4 [ 1 ]
TypeError: shiftedArray.unshift is not a function at solution (solution.js:15:41) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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:3stdout:
[ -1000, 0, 1000 ] true 7 [ -1000, 0, 1000 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
console.log(A)
console.log(Array.isArray(A))
console.log(K)
let i = 0;
let shiftedArray = A;
console.log(shiftedArray)
if (A.length) {
while (i < K) {
let last = shiftedArray[shiftedArray.length];
shiftedArray = shiftedArray.concat(last);
i += 1
}
}
return shiftedArray
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log(A)
// console.log(Array.isArray(A))
// console.log(K)
// let i = 0;
// let shiftedArray = A;
// console.log(shiftedArray)
// if (A.length) {
// while (i < K) {
// let last = shiftedArray[shiftedArray.length];
// shiftedArray = shiftedArray.concat(last);
// i += 1
// }
// }
return shiftedArray
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log(A)
// console.log(Array.isArray(A))
// console.log(K)
// let i = 0;
// let shiftedArray = A;
// console.log(shiftedArray)
// if (A.length) {
// while (i < K) {
// let last = shiftedArray[shiftedArray.length];
// shiftedArray = shiftedArray.concat(last);
// i += 1
// }
// }
// return shiftedArray
K = K % A.length;
let start
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log(A)
// console.log(Array.isArray(A))
// console.log(K)
// let i = 0;
// let shiftedArray = A;
// console.log(shiftedArray)
// if (A.length) {
// while (i < K) {
// let last = shiftedArray[shiftedArray.length];
// shiftedArray = shiftedArray.concat(last);
// i += 1
// }
// }
// return shiftedArray
K = K % A.length;
let cutStart = A.length - K;
if ()
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log(A)
// console.log(Array.isArray(A))
// console.log(K)
// let i = 0;
// let shiftedArray = A;
// console.log(shiftedArray)
// if (A.length) {
// while (i < K) {
// let last = shiftedArray[shiftedArray.length];
// shiftedArray = shiftedArray.concat(last);
// i += 1
// }
// }
// return shiftedArray
K = K % A.length;
let cutStart = A.length - K;
if (A.length === 0 || K <= 0) {
return A;
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log(A)
// console.log(Array.isArray(A))
// console.log(K)
// let i = 0;
// let shiftedArray = A;
// console.log(shiftedArray)
// if (A.length) {
// while (i < K) {
// let last = shiftedArray[shiftedArray.length];
// shiftedArray = shiftedArray.concat(last);
// i += 1
// }
// }
// return shiftedArray
K = K % A.length;
if (A.length === 0 || K <= 0) {
return A;
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log(A)
// console.log(Array.isArray(A))
// console.log(K)
// let i = 0;
// let shiftedArray = A;
// console.log(shiftedArray)
// if (A.length) {
// while (i < K) {
// let last = shiftedArray[shiftedArray.length];
// shiftedArray = shiftedArray.concat(last);
// i += 1
// }
// }
// return shiftedArray
K = K % A.length;
if (A.length === 0 || K <= 0) {
return A;
}
let cutStart = A.length - K;
return [...A.slice(cutStart, )]
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log(A)
// console.log(Array.isArray(A))
// console.log(K)
// let i = 0;
// let shiftedArray = A;
// console.log(shiftedArray)
// if (A.length) {
// while (i < K) {
// let last = shiftedArray[shiftedArray.length];
// shiftedArray = shiftedArray.concat(last);
// i += 1
// }
// }
// return shiftedArray
K = K % A.length;
if (A.length === 0 || K <= 0) {
return A;
}
let cutStart = A.length - K;
return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log(A)
// console.log(Array.isArray(A))
// console.log(K)
// let i = 0;
// let shiftedArray = A;
// console.log(shiftedArray)
// if (A.length) {
// while (i < K) {
// let last = shiftedArray[shiftedArray.length];
// shiftedArray = shiftedArray.concat(last);
// i += 1
// }
// }
// return shiftedArray
K = K % A.length;
if (A.length === 0 || K <= 0) {
return A;
}
let cutStart = A.length - K;
return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
[[], 4]
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
function result: []
function result: [0, 0, 0]
function result: [1, 2, 3]
function result: [1]
function result: [1000, -1000, 0]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log(A)
// console.log(Array.isArray(A))
// console.log(K)
// let i = 0;
// let shiftedArray = A;
// console.log(shiftedArray)
// if (A.length) {
// while (i < K) {
// let last = shiftedArray[shiftedArray.length];
// shiftedArray = shiftedArray.concat(last);
// i += 1
// }
// }
// return shiftedArray
K = K % A.length;
if (A.length === 0 || K <= 0) {
return A;
}
A.pop()
let cutStart = A.length - K;
return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
[[], 4]
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
function result: []
function result: [0, 0]
function result: [1, 2, 3]
function result: [1]
function result: [0, -1000]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
K = K % A.length;
if (A.length === 0 || K <= 0) {
return A;
}
A.pop()
let cutStart = A.length - K;
return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log(A)
// console.log(Array.isArray(A))
// console.log(K)
// let i = 0;
// if (A.length) {
// while (i < K) {
// let last = shiftedArray[shiftedArray.length];
// shiftedArray = shiftedArray.concat(last);
// i += 1
// }
// }
// return shiftedArray
K = K % A.length;
if (A.length === 0 || K <= 0) {
return A;
}
A.pop()
let cutStart = A.length - K;
return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log(A)
// console.log(Array.isArray(A))
// console.log(K)
// let i = 0;
// if (A.length) {
// while (i < K) {
// let last = shiftedArray.pop[shiftedArray.length];
// shiftedArray = shiftedArray.concat(last);
// i += 1
// }
// }
// return shiftedArray
K = K % A.length;
if (A.length === 0 || K <= 0) {
return A;
}
A.pop()
let cutStart = A.length - K;
return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log(A)
// console.log(Array.isArray(A))
// console.log(K)
let i = 0;
if (A.length) {
while (i < K) {
let last = shiftedArray.pop()[shiftedArray.length];
shiftedArray = shiftedArray.concat(last);
i += 1
}
}
return shiftedArray
K = K % A.length;
if (A.length === 0 || K <= 0) {
return A;
}
A.pop()
let cutStart = A.length - K;
return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log(A)
// console.log(Array.isArray(A))
// console.log(K)
let i = 0;
if (A.length) {
while (i < K) {
let last = A.pop();
A = A.unshift(last);
i += 1
}
}
return shiftedArray
K = K % A.length;
if (A.length === 0 || K <= 0) {
return A;
}
A.pop()
let cutStart = A.length - K;
return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log(A)
// console.log(Array.isArray(A))
// console.log(K)
let i = 0;
if (A.length) {
while (i < K) {
let last = A.pop();
A = A.unshift(last);
i += 1
}
}
return A
// K = K % A.length;
// if (A.length === 0 || K <= 0) {
// return A;
// }
// A.pop()
// let cutStart = A.length - K;
// return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// console.log(A)
// console.log(Array.isArray(A))
// console.log(K)
let i = 0;
if (A.length) {
while (i < K) {
let last = A.pop();
A = A.unshift(last);
i += 1
}
}
return A
// K = K % A.length;
// if (A.length === 0 || K <= 0) {
// return A;
// }
// A.pop()
// let cutStart = A.length - K;
// return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
[[], 4]
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
TypeError: A.pop is not a function at solution (solution.js:12:26) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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
Invalid result type, Array expected, 'number' found
TypeError: A.pop is not a function at solution (solution.js:12:26) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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
function result: []
TypeError: A.pop is not a function at solution (solution.js:12:26) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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
function result: [1, 2, 3]
TypeError: A.pop is not a function at solution (solution.js:12:26) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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: A.pop is not a function at solution (solution.js:12:26) at solutionWrapper (/tmp/exec.js:411:28) at Promise.resolve.then (/tmp/exec.js:437: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, K) {
// write your code in JavaScript (Node.js 8.9.4)
// K = K % A.length;
// if (A.length === 0 || K <= 0) {
// return A;
// }
// A.pop()
// let cutStart = A.length - K;
// return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
K = K % A.length;
if (A.length === 0 || K <= 0) {
return A;
}
A.pop()
let cutStart = A.length - K;
return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
[[], 4]
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
function result: []
function result: [0, 0]
function result: [1, 2, 3]
function result: [1]
function result: [0, -1000]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
K = K % A.length;
if (A.length === 0 || K <= 0) {
return A;
}
let cutStart = A.length - K;
return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
[[], 4]
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
function result: []
function result: [0, 0, 0]
function result: [1, 2, 3]
function result: [1]
function result: [1000, -1000, 0]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
K = K % A.length;
if (A.length === 0 || K <= 0) {
return A;
}
let cutStart = A.length - K;
return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
K = K % A.length;
if (A.length === 0 || K <= 0) {
return A;
}
let cutStart = A.length - K;
return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
[[], 4]
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 100]
function result: []
function result: [0, 0, 0]
function result: [1, 2, 3]
function result: [1]
function result: [1000, -1000, 0]
function result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
K = K % A.length;
if (A.length === 0 || K <= 0) {
return A;
}
let cutStart = A.length - K;
return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
[[], 4]
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 100]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 87]
function result: []
function result: [0, 0, 0]
function result: [1, 2, 3]
function result: [1]
function result: [1000, -1000, 0]
function result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
function result: [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
// K = K % A.length;
// if (A.length === 0 || K <= 0) {
// return A;
// }
// let cutStart = A.length - K;
// return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
let i = 0;
if (A.length >= 1) {
}
// K = K % A.length;
// if (A.length === 0 || K <= 0) {
// return A;
// }
// let cutStart = A.length - K;
// return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
let i = 0;
if (A.length >= 1) {
while (i < K) {
let last = A.pop()
}
}
// K = K % A.length;
// if (A.length === 0 || K <= 0) {
// return A;
// }
// let cutStart = A.length - K;
// return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
let i = 0;
if (A.length >= 1) {
while (i < K) {
let last = A.pop();
A.unshift(last);
i += 1;
}
}
// K = K % A.length;
// if (A.length === 0 || K <= 0) {
// return A;
// }
// let cutStart = A.length - K;
// return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
let i = 0;
if (A.length >= 1) {
while (i < K) {
let last = A.pop();
A.unshift(last);
i += 1;
}
}
return A
// K = K % A.length;
// if (A.length === 0 || K <= 0) {
// return A;
// }
// let cutStart = A.length - K;
// return [...A.slice(cutStart, A.length), ...A.slice(0, cutStart)]
}
[[], 4]
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 100]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 87]
function result: []
function result: [0, 0, 0]
function result: [1, 2, 3]
function result: [1]
function result: [1000, -1000, 0]
function result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
function result: [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
let i = 0;
if (A.length >= 1) {
while (i < K) {
let last = A.pop();
A.unshift(last);
i += 1;
}
}
return A;
}
[[], 4]
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 100]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 87]
function result: []
function result: [0, 0, 0]
function result: [1, 2, 3]
function result: [1]
function result: [1000, -1000, 0]
function result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
function result: [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
let i = 0;
if (A.length >= 1) {
while (i < K) {
let last = A.pop();
A.unshift(last);
i += 1;
}
}
return A;
}
[[], 4]
[[0, 0, 0], 4]
[[1, 2, 3], 0]
[[1], 4]
[[-1000, 0, 1000], 7]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 100]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 87]
function result: []
function result: [0, 0, 0]
function result: [1, 2, 3]
function result: [1]
function result: [1000, -1000, 0]
function result: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
function result: [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
// write your code in JavaScript (Node.js 8.9.4)
let i = 0;
if (A.length >= 1) {
while (i < K) {
let last = A.pop();
A.unshift(last);
i += 1;
}
}
return A;
}
The solution obtained perfect score.