標題
※ 引述《bleed1979 (十三)》之銘言:
: 問題:
: 假設你有兩顆蛋,然後有一棟100層樓高的大樓。
: 而蛋的特性有的可能很堅固,堅固到從一百層樓跌下都沒事,
: 有的可能很脆弱,一樓就可以摔破。
: 現在你只知道這這兩顆蛋是完全相同的,
: 你想要知道蛋最高從哪一層樓摔下來不會摔破。
: 問題是:你要摔幾次才能計算出來?
: (如果你低於高度摔下蛋,蛋就沒事,如果高於那個樓層,蛋就完蛋)
: 在這過程你可以摔破蛋。
答案前面都有了
這邊補充一下, 這題有很多變形, 主要解題技巧是 load balance
想辦法減輕 worst case 工作量, 將它攤到其他地方
變形有
Ref: https://class.coursera.org/algs4partI-004/
by Robert Sedgewick
Interview Questions: Analysis of Algorithms
Egg drop. Suppose that you have an N-story building and plenty of eggs. An
egg breaks if it is dropped from floor T or higher and does not break
otherwise. Your goal is to devise a strategy to determine the value of T
given the following limitations on the number of eggs and tosses:
Version 0: 1 egg, <= T tosses. (<= 是小於等於)
Version 1: ~1 lg N eggs and ~ 1 lg N tosses
Version 2: ~lg T eggs and ~ 2 lg T tosses
Version 3: 2 eggs and ~ 2 sqrt(N) tosses <= 原 po 的題目落在這
Version 4: 2 eggs and <= c sqrt(T) tosses for some fixed constant c
有些題目可以做到更好--
※ 發信站: 批踢踢實業坊(pttweb.tw), 來自: 1.171.48.246
※ 文章網址: https://pttweb.tw/Soft_Job/M.1397327883.A.6EA
Re: [討論] Google面試問題
(13/31篇)看板Soft_Job軟工板作者aknow (嘎嘎)推文2則 (2推 0噓 0→)※ 引述《bleed1979 (十三)》之銘言:
: 問題:
: 假設你有兩顆蛋,然後有一棟100層樓高的大樓。
: 而蛋的特性有的可能很堅固,堅固到從一百層樓跌下都沒事,
: 有的可能很脆弱,一樓就可以摔破。
: 現在你只知道這這兩顆蛋是完全相同的,
: 你想要知道蛋最高從哪一層樓摔下來不會摔破。
: 問題是:你要摔幾次才能計算出來?
: (如果你低於高度摔下蛋,蛋就沒事,如果高於那個樓層,蛋就完蛋)
: 在這過程你可以摔破蛋。
答案前面都有了
這邊補充一下, 這題有很多變形, 主要解題技巧是 load balance
想辦法減輕 worst case 工作量, 將它攤到其他地方
變形有
Ref: https://class.coursera.org/algs4partI-004/
by Robert Sedgewick
Interview Questions: Analysis of Algorithms
Egg drop. Suppose that you have an N-story building and plenty of eggs. An
egg breaks if it is dropped from floor T or higher and does not break
otherwise. Your goal is to devise a strategy to determine the value of T
given the following limitations on the number of eggs and tosses:
Version 0: 1 egg, <= T tosses. (<= 是小於等於)
Version 1: ~1 lg N eggs and ~ 1 lg N tosses
Version 2: ~lg T eggs and ~ 2 lg T tosses
Version 3: 2 eggs and ~ 2 sqrt(N) tosses <= 原 po 的題目落在這
Version 4: 2 eggs and <= c sqrt(T) tosses for some fixed constant c
有些題目可以做到更好--
※ 發信站: 批踢踢實業坊(pttweb.tw), 來自: 1.171.48.246
※ 文章網址: https://pttweb.tw/Soft_Job/M.1397327883.A.6EA
同標題文章
- 18[討論] Google面試問題
- 8Fw: [討論] Google面試問題
- 17Fw: [討論] Google面試問題
- 1Re: [討論] Google面試問題
- Re: [討論] Google面試問題
- 7Re: [討論] Google面試問題
- 4Re: [討論] Google面試問題
- 8Re: [討論] Google面試問題
- 2Re: [討論] Google面試問題
- 3Re: [討論] Google面試問題
- Re: [討論] Google面試問題
- -2Re: [討論] Google面試問題
- 2Re: [討論] Google面試問題
- -4Re: [討論] Google面試問題
- 3Re: [討論] Google面試問題
- Re: [討論] Google面試問題
- Re: [討論] Google面試問題
- 1Re: [討論] Google面試問題
- 6Re: [討論] Google面試問題
- 4Re: [討論] Google面試問題
- 6Re: [討論] Google面試問題
- 1Re: [討論] Google面試問題
- 2Re: [討論] Google面試問題
- 1Re: [討論] Google面試問題
- 3Re: [討論] Google面試問題
- Re: [討論] Google面試問題
- 2Re: [討論] Google面試問題
- Re: [討論] Google面試問題
- 4Re: [討論] Google面試問題
- 4Re: [討論] Google面試問題
- 4Re: [討論] Google面試問題
相關文章
37
[心得] 2024 Google面試與刷題心得
11
[心得] Google 面試分享 - AI顧問
83
[心得] Google L4面試時程分享(最終失敗)
53
[心得] 2023 Google SWE Embedded面試分享
14
Re: [心得] Google L4面試時程分享(最終失敗)
10
Re: [心得] Google L4面試時程分享(最終失敗)
1
Re: [心得] Google L4面試時程分享(最終失敗)
28
Re: [心得] SUSE面試經驗
48
[心得] 2022 高雄面試
61
[心得] 2024各公司面試心得
Soft_Job熱門文章
81
[心得]2024 年中找工作經驗分享
73
[心得] 2024 web轉職末班車 面試心得
55
[心得] 2024 下半年 backend engineer 面試心得
52
[心得]非本科學士 德國求職全紀錄 - Data
45
[請益] 轉職後的徬徨
45
[討論] 國泰出這包不太行吧
40
[討論] 公司內部版控
33
Re: [討論] 公司內部版控
30
Re: [心得] 全端培訓轉職失敗心得
29
Re: [心得] 全端培訓轉職失敗心得