algorithm - Compare two integer arrays with same length -


[description] Looking at two integer arrays with the same length. Design an algorithm that can decide if they are the same. The definition of "identical" is that, if these two arrays are in sequential order, then in this situation the element should be the same.

  [example] <1 2 3 4> = & lt; 3 1 2 4 & gt; & Lt; 1 2 3 4> ! = & Lt; 3 4 1 1> [Boundary] Algorithm requires continuous extra space, and the time required to run O (N) is required. 

(Perhaps an interview is too complex for a question.)

(You To check the minimum, maximum, yoga, sumsq etc. can be used like o (n) first.)

Use the two-arrays to sort O (N) complexity of time , O (1) space

Then compare them using the normal algorithm. O (n) complexity of time, O (1) space

(Max and subtract; Minimum) array of arrays (n k ) with a finite)


Comments

Popular posts from this blog

bytearray - Removing trailing nulls from byte array in C# -

linux - Authenticating GTK app to run with root permissions -

WPF TextBlock Overflow Text to the Left -