Achieve Internet Interview Question
Computer ScientistsCountry: United States
You are given an array A = [1, 2, 3, ..., n]:
How many sequences (S1) can you get after exact k adjacent swaps on A?
How many sequences (S2) can you get after at most k swaps on A?
An adjacent swap can be made between two elements of the Array A, A[i] and A[i+1] or A[i] and A[i-1].
A swap otherwise can be between any two elements of the array A[i] and A[j] for all 1 <= i, j <= N, i != j.
So which programming contest is this from, you twit.
- Anonymous June 20, 2014