Skip to content

Commit 08a2c0f

Browse files
lijunjie127imhuay
lijunjie127
authored andcommitted
4.第四题区间最大最小值ljj个人解题思路 (#23)
头条笔试第四题解题思路
1 parent 9877a66 commit 08a2c0f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

D-笔试面经/笔试-字节跳动-180812.md

+6
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ else:
153153
<div align="center"><img src="../_assets/TIM截图20180812100503.png" height="" /></div>
154154
<div align="center"><img src="../_assets/TIM截图20180812100524.png" height="" /></div>
155155

156+
**思路**
157+
- max(a[l,r])<min(b[l,r])说明对任意l<=i<=r,均有a[i]<b[i]
158+
- 新建一个和a或者b等长对数组c
159+
- 数组c中每个元素的计算方法:c[i] = a[i]<b[i] ? c[i-1]+1 : 0
160+
- 对数组c中元素求和,得到满足题目要求对区间个数
161+
156162
## 5. 直播爱好者
157163
<div align="center"><img src="../_assets/TIM截图20180812100550.png" height="" /></div>
158164
<div align="center"><img src="../_assets/TIM截图20180812100606.png" height="" /></div>

0 commit comments

Comments
 (0)