FastPrepFastPrep
Problem Brief

Find K-Level Permutation

OA
See Amazon online assessment and hiring insights

You have an array from 1 to N now you have to find a K-level permutation such that for N-K+1 segments or windows you get the difference between sum of maximum segment sum and minimum segment must be at most 1.

1Example 1

Input
N = 7, K = 4
Output
[1, 7, 3, 5, 2, 6, 4]
Explanation
N/A for now

Constraints

Limits and guarantees your solution can rely on.

no constraint were given
public int[] findKLevelPermutation(int N, int K) {
  // write your code here
}
Input

N

7

K

4

Output

[1, 7, 3, 5, 2, 6, 4]

Sign in to submit your solution.