Skip to content

Instantly share code, notes, and snippets.

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)) {
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;
@Obre
Obre / Equi.js
Last active April 27, 2017 11:58
// 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++) {