开发者

Junior .NET Developer interview questions (alghoritms) [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜