Codility
Last updated
Last updated
— description: Những điểu cần biết về Codility —
Problem: Peaks
PT:
l = arr.length;
getFactors l => [f1, ….f2]
peaks array => [false, true, ….true, false];
for each factor f1 (f1 > 1) => we have l / f1 blocks we can skip 1
we have l / f1 blocks =>
check if each block has a peak
how to check for a slice (i, j) contains a block ?
loop i => j if peaks[k] = true => O(n)
use memorize to get O(i)