Pergunta de entrevista da empresa Toptal

An integer X and a non-empty zero-indexed array A consisting of N integers are given. We are interested in which elements of A are qual to X and which are different from X. The goal is to split array A into two parts, such that the number of elements equal to X in the first part is the same as the number of elements different from X in the other part. More formally, we are looking for an index K such that: 0 ≤ K < N and the number of elements equal to X in A[0..K−1] is the same as the number of elements different from X in A[K..N−1]. For K = 0, A[0..K−1] does not contain any elements.

Respostas da entrevista

Sigiloso

19 de dez. de 2017

do u remeber or recoomend any website where to practice codility solutions from

Sigiloso

28 de jan. de 2020

function solution(x, A) { let eqlA = [] let notEqlA = [] for(let i = 0; i 0 && eqlA.length === notEqlA.length ) { return i; } } }