전체 글
-
5-1.countDivCodility/Javascript 2017. 4. 6. 21:35
Task descriptionWrite a function:function solution(A, B, K);that, given three integers A, B and K, returns the number of integers within the range [A..B] that are divisible by K, i.e.:{ i : A ≤ i ≤ B, i mod K = 0 }For example, for A = 6, B = 11 and K = 2, your function should return 3, because there are three numbers divisible by 2 within the range [6..11], namely 6, 8 and 10.Assume that:A and B..
-
4-4.MaxCountersCodility/Javascript 2017. 4. 6. 13:59
Task descriptionYou are given N counters, initially set to 0, and you have two possible operations on them:increase(X) − counter X is increased by 1,max counter − all counters are set to the maximum value of any counter.A non-empty zero-indexed array A of M integers is given. This array represents consecutive operations:if A[K] = X, such that 1 ≤ X ≤ N, then operation K is increase(X),if A[K] = ..
-
4-3.FrogRiverOneCodility/Javascript 2017. 4. 6. 12:16
Task descriptionA small frog wants to get to the other side of a river. The frog is initially located on one bank of the river (position 0) and wants to get to the opposite bank (position X+1). Leaves fall from a tree onto the surface of the river.You are given a zero-indexed array A consisting of N integers representing the falling leaves. A[K] represents the position where one leaf falls at ti..
-
4-2.PermCheckCodility/Javascript 2017. 4. 6. 11:40
Task descriptionA non-empty zero-indexed array A consisting of N integers is given.A permutation is a sequence containing each element from 1 to N once, and only once.For example, array A such that: A[0] = 4 A[1] = 1 A[2] = 3 A[3] = 2is a permutation, but array A such that: A[0] = 4 A[1] = 1 A[2] = 3is not a permutation, because value 2 is missing.The goal is to check whether array A is a permut..
-
4-1.MissingIntegerCodility/Javascript 2017. 4. 6. 11:07
Task descriptionWrite a function:function solution(A);that, given a non-empty zero-indexed array A of N integers, returns the minimal positive integer (greater than 0) that does not occur in A.For example, given: A[0] = 1 A[1] = 3 A[2] = 6 A[3] = 4 A[4] = 1 A[5] = 2the function should return 5.Assume that:N is an integer within the range [1..100,000];each element of array A is an integer within ..
-
3-3.TapeEquilibriumCodility/Javascript 2017. 4. 5. 15:46
A non-empty zero-indexed array A consisting of N integers is given. Array A represents numbers on a tape. Any integer P, such that 0 < P < N, splits this tape into two non-empty parts: A[0], A[1], ..., A[P − 1] and A[P], A[P + 1], ..., A[N − 1]. The difference between the two parts is the value of: |(A[0] + A[1] + ... + A[P − 1]) − (A[P] + A[P + 1] + ... + A[N − 1])| In other words, it is the ab..