File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,4 +13,5 @@ LintCode|74 | 第一个错误的代码版本 | 一刷无bug |
1313LintCode|75 | 寻找峰值 | 一刷有点小问题 |
1414LintCode|159|寻找旋转排序数组中的最小值|一刷无bug|
1515LintCode|160|寻找旋转排序数组中的最小值 II|有大量重复元素|
16- LintCode|585 | 山脉序列中的最大值 | 一刷无bug |
16+ LintCode|585 | 山脉序列中的最大值 | 一刷无bug |
17+ LintCode|1699 | 建庙 | 二分法的变形 |
Original file line number Diff line number Diff line change 1+ class Solution :
2+ """
3+ @param m: m pillars of your temple.
4+ @param woods: length of n different wood
5+ @return: return the maximum height of the temple.
6+ """
7+
8+ def buildTemple (self , m , woods ):
9+ # write your code here.
10+ if m < 1 or len (woods ) < 1 :
11+ return 0
12+ start = min (woods )
13+ end = max (woods )
14+ while start + 1 < end :
15+ mid = start + (end - start ) // 2
16+ if self .helper (woods , mid ) < m :
17+ end = mid
18+ else :
19+ start = mid
20+ if self .helper (woods , start ) >= m :
21+ return start
22+ else :
23+ return end
24+
25+ def helper (self , woods , eachlen ):
26+ count = 0
27+ for wood in woods :
28+ count = count + wood // eachlen
29+ return count
You can’t perform that action at this time.
0 commit comments