Skip to content

Commit

Permalink
【update】笔试-度小满-180913
Browse files Browse the repository at this point in the history
  • Loading branch information
imhuay committed Sep 13, 2018
1 parent 8ccc7d1 commit e5a95fd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions 笔试面经/笔试-度小满-180913.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
笔试-度小满-180913
===
选择 30,编程 2
- 机器学习研发
- 选择 30,编程 2

Index
---
Expand All @@ -10,6 +11,9 @@ Index
<div align="center"><img src="../assets/TIM截图20180913154830.png" height="" /></div>
<div align="center"><img src="../assets/TIM截图20180913154842.png" height="" /></div>

**思路**
- 求区间最大重叠数

**暴力法**(36%)
```python
n = int(input())
Expand Down Expand Up @@ -57,15 +61,17 @@ print(mx)
## 商品交易
<div align="center"><img src="../assets/TIM截图20180913154909.png" height="" /></div>

**思路**
- LeetCode原题
- 因为这里要求输出最小交易次数,所以贪心不可行,改用双指针

**贪心**(9%)
```python
n = int(input())

nums = list(map(int, input().split()))


def foo(nums):
tmp = []
ans = 0
cnt = 0
if len(nums) <= 1:
Expand All @@ -76,7 +82,6 @@ def foo(nums):
cnt += 2
return ans, cnt


ans, cnt = foo(nums)
print(ans, cnt)
```
Expand All @@ -87,7 +92,6 @@ n = int(input())

nums = list(map(int, input().split()))


def foo(nums):
ans = i = 0
cnt = 0
Expand All @@ -106,7 +110,6 @@ def foo(nums):

return ans, cnt


ans, cnt = foo(nums)
print(ans, cnt)
```

0 comments on commit e5a95fd

Please sign in to comment.