This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(N) { | |
if (N < 1) { | |
return 0; | |
} | |
var start = 0; | |
var gap = 0; | |
var count = 0; | |
for (i = 0; i < 31; i++) { | |
if (N & (1 << i)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(A, K) { | |
if(A !== undefined && A.length > 0) | |
{ | |
for(let i =0; i < K; i++){ | |
A.unshift(A.pop()); | |
//unshift add element/s to begin of array and returns length of new array | |
//pop removes last element and returns that element (changes length of array) | |
} | |
} | |
return A; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 70%, bad performance | |
function solution(A) { | |
var leftSide | |
var rightSide | |
for (i = 0, arLen = A.length; i < arLen; i++) { | |
leftSide = 0; | |
rightSide = 0; | |
for (j = 0; j < i; j++) { |
NewerOlder