Interview Question

Software Engineer Interview

-

Google

Randomize an array, ensuring no items are in the same position they were in originally.

AnswerAdd Tags

Interview Answer

1 Answer

0

What does this mean? Actually randomising an array could not guaranty that no (or any) elements wouldn't wind-up in the same position[s]. 0-element array: impossible (or N/A). 1-element array: impossible. 2-element array: happens only 50% of the time. 3-element array: happens ⅔×½ of the time (I reckon.).

Empty Set on

Add Answers or Comments

To comment on this, Sign In or Sign Up.