Entries from 2019-03-13 to 1 day

OddOccurrencesInArray My 100% Solution in Javascript

Question app.codility.com My Solution (O(nlogn)) app.codility.com function solution(A) { A.sort((a, b)=>(a-b)); for (let i = 0; i < A.length; i+=2) { if (A[i] != A[i+1]) { return A[i]; } } } Online Solution (O(n)) Odd Occurrences In Array …

CyclicRotation My 100% Solution in Javascript

Question app.codility.com My Solution app.codility.com function solution(A, K) { K = K%A.length; if (K === 0) return A; let AA = A.concat(A); return AA.slice(A.length-K, A.length-K+A.length); } Note The rotation of string A is a substring …

BinaryGap My 100% Solution in Javascript

Question app.codility.com My Solution app.codility.com function solution(N) { let input = N; let count = 0; let maxCount = 0; let startCount = false; while (input > 0) { let bit = input%2; if (bit === 0) { if (startCount) count++; } else {…