很簡單的麵試問題

來源: 布衣之才 2012-12-06 12:09:49 [] [博客] [舊帖] [給我悄悄話] 本文已被閱讀: 次 (548 bytes)
本文內容已被 [ 布衣之才 ] 在 2012-12-06 12:13:52 編輯過。如有問題,請報告版主或論壇管理刪除.

這幾天我們在麵試candidate for a sr. .net developer. 我們問了這樣一個問題:

Given a sorted array of integers like:

[1, 3, 4, 7, 11, 14, 15, 19, 21].

 

Please complete the following function that searches for an integer in the array and returns the position if the number is found or -1 if not found:

 

int FindNumber(int[] array, int n)

{

    ......

}

 

No candidate has finished the function to our expection.  

看上去很簡單的問題嗎?

所有跟帖: 

binary search, is it the expectation? -胡說之- 給 胡說之 發送悄悄話 胡說之 的博客首頁 (0 bytes) () 12/06/2012 postreply 12:26:31

yes, thanks. -布衣之才- 給 布衣之才 發送悄悄話 布衣之才 的博客首頁 (82 bytes) () 12/06/2012 postreply 12:42:02

Shouldn't the array be sorted first before doing a binary search -ZhuZhuXia- 給 ZhuZhuXia 發送悄悄話 ZhuZhuXia 的博客首頁 (0 bytes) () 12/06/2012 postreply 12:53:24

no, that was not what we wanted to test. -布衣之才- 給 布衣之才 發送悄悄話 布衣之才 的博客首頁 (458 bytes) () 12/06/2012 postreply 13:11:54

回複:no, that was not what we wanted to test. -布衣之才- 給 布衣之才 發送悄悄話 布衣之才 的博客首頁 (162 bytes) () 12/06/2012 postreply 21:23:22

回複:很簡單的麵試問題 -maymayw- 給 maymayw 發送悄悄話 maymayw 的博客首頁 (99 bytes) () 12/06/2012 postreply 12:32:43

請您先登陸,再發跟帖!

發現Adblock插件

如要繼續瀏覽
請支持本站 請務必在本站關閉/移除任何Adblock

關閉Adblock後 請點擊

請參考如何關閉Adblock/Adblock plus

安裝Adblock plus用戶請點擊瀏覽器圖標
選擇“Disable on www.wenxuecity.com”

安裝Adblock用戶請點擊圖標
選擇“don't run on pages on this domain”