Interview Question

Coop-Software Developer Interview

-Waterloo, ON

BlackBerry

If given an infinite amount of memory, whats the fastest way to reverse an array?

AnswerAdd Tags

Interview Answers

3 Answers

7

Allocate an array of equal size and write the last index of original array to 0th index of 1st array .. (n-1)th to 1st index and so on

Engineer on

0

Use a temp variable and do swap for half of the array

Anonymous on

0

Split the array in half, reverse them, split the two in half, reverse them, etc. until you cannot reverse anymore.

Anonymous on

Add Answers or Comments

To comment on this, Sign In or Sign Up.