Skip to content

Commit

Permalink
one line get max matrix val
Browse files Browse the repository at this point in the history
  • Loading branch information
PegasusWang committed Jun 13, 2022
1 parent 2c8a81b commit 3469a79
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/19_python内置常用算法和数据结构/builtins.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ presums = list(accumulate([1,2,3])) # [1, 3, 6]
allsum = sum(map(sum, matrix)) # 或者 allsum = sum((sum(row) for row in matrix))
# 一行代码判断一个元素是否在矩阵中,比如判断 1 是否在矩阵matrix中
any(1 in row for row in matrix)
# 一行代码获取矩阵最大、最小值
maxval = max(map(max, matrix))
```

# python dict 技巧
Expand Down

0 comments on commit 3469a79

Please sign in to comment.