Problem · Array

Find K-Level Permutation

Learn this problem
HardAmazonOA
See Amazon hiring insights

Problem statement

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.

Function

findKLevelPermutation(N: int, K: int) → int[]

Examples

Example 1

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

Constraints

no constraint were given

More Amazon problems

drafts saved locally
public int[] findKLevelPermutation(int N, int K) {
  // write your code here
}
N7
K4
expected[1, 7, 3, 5, 2, 6, 4]
checking account