jayz
BAN USER
Comments (7)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
O(n) solution would be something as follows:
for each even element a_i in a, do the following:
index=i
while index <n : index=index*2-1
swap (a_index, b_(i/2))
while index !=i : swap (a_index,a_((index-1)/2)); index=(index+1)/2
Repeat for array b(1..n/2) b(n/2+1)
Total operations: n+n/2+n/4...=O(n)
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Technically impossible to solve as the best known algorithm for in-place non square matrix transpose does not satisfy the two conditions.
- jayz February 26, 2018