Interesting Array | Coursera

You are given a sequence A1,A2,…,AN and an integer K.
You may perform any number of operations of the following type (in any order): choose a valid integer i and swap Ai with Ai+K. Can you sort the sequence this way?

Example Input
2
4 1
1 4 2 3
4 2
1 4 2 3
Example Output
yes
no

Comments (2)
No comments yet.