Possible duplicate:
In place of matrix transposition
Recently attended a Technical Written Interview. The following question has passed.
I have an array, as they say
testArray = {a1,a2,a3,...an,b1,b2,b3,....bn,c1,c2,c3,.....,cn}
I need to sort this array as `
testArray = {a1,b1,c1,a2,b2,c2,a3,b3,c3,.....,an,bn,cn}
Limitation: I must not use additional memory, I must not use the built-in function. Must write the complete code, it can be in any language and can also use any data structure.
eg:
Input: {1,2,3,4,5,6,7,8,9}, n = 3 Output: {1,4,7,2,5,8,3,6,9}
I could not get any solution within the constraint, can anyone provide a solution or suggestion?