Difficulties in finding the best solution

Revision en3, by Usu, 2019-02-17 22:19:24

Hi! Is anybody who can give me a solution for this? We have an array with n elements and a number k. We are asked to calculate in how many continuous strings of size exactly k (k is even), the element at the i-th position is in the second half if we sort that continuous string (all values are different). We want to calculate this value for every single position*. Example: n=6, k=4, the array: 1 4 2 5 9 3, the output will be like this: 0 1 0 3 2 0


  Rev. Lang. By When Δ Comment
en3 English Usu 2019-02-17 22:19:24 60
en2 English Usu 2019-02-17 22:16:29 9 Tiny change: 'is in the first half if w' -> 'is in the second half if w'
en1 English Usu 2019-02-17 22:01:04 432 Initial revision (published)