Junior .NET Developer interview questions (alghoritms) [closed]
1) Given two arrays, A and B. Array A consists of a sequence (ex. [1,2,3,4,5,6]) a开发者_如何学Pythonnd array B consists of a sequence (ex. [2,4,3,1,_, 6]). Q: Find the missing element in the array B, no more than one pass of iteration. You can use an array A.
2) Given one array (ex. [2,5,4,1,3,6). Q: Sort this array, no more than one pass of iteration.
I failed :(
1) Use a frequency table. Example:
- create a dictionary
- add all elements from array A in your list, value 0.
- Iterate all elements from array B, dict[B]++
- Element with value 0 is the right one.
2) Iterate the table A once and put the element at the right place in table B.
精彩评论