Compare two integer arrays with same length
Posted
by meta
on Stack Overflow
See other posts from Stack Overflow
or by meta
Published on 2010-03-08T15:12:50Z
Indexed on
2010/03/08
15:36 UTC
Read the original article
Hit count: 151
algorithm
|interview-questions
[Description] Given two integer arrays with the same length. Design an algorithm which can judge whether they're the same, the definition of "same" is that, if these two arrays are in sorted order, the elements in corresponding position should be the same.
[Example]
<1 2 3 4> = <3 1 2 4>
<1 2 3 4> != <3 4 1 1>
[Limitation] The algorithm should require constant extra space, and O(n) running time.
© Stack Overflow or respective owner