Update 0048、1011

This commit is contained in:
YDZ
2021-04-26 01:24:48 +08:00
parent 0a87bb5a02
commit 6fcc9ec669
3 changed files with 22 additions and 4 deletions

View File

@ -10,8 +10,9 @@ Rotate the image by 90 degrees (clockwise).
You have to rotate the image **[in-place](https://en.wikipedia.org/wiki/In-place_algorithm)**, which means you have to modify the input 2D matrix directly. **DO NOT** allocate another 2D matrix and do the rotation.
**Example 1:**
**Example 1**:
![](https://assets.leetcode.com/uploads/2020/08/28/mat1.jpg)
Given input matrix =
[
@ -28,8 +29,9 @@ You have to rotate the image **[in-place](https://en.wikipedia.org/wiki/In-plac
]
**Example 2:**
**Example 2**:
![](https://assets.leetcode.com/uploads/2020/08/28/mat2.jpg)
Given input matrix =
[

View File

@ -12,6 +12,7 @@ You have to rotate the image **[in-place](https://en.wikipedia.org/wiki/In-plac
**Example 1**:
![](https://assets.leetcode.com/uploads/2020/08/28/mat1.jpg)
Given input matrix =
[
@ -30,6 +31,7 @@ You have to rotate the image **[in-place](https://en.wikipedia.org/wiki/In-plac
**Example 2**:
![](https://assets.leetcode.com/uploads/2020/08/28/mat2.jpg)
Given input matrix =
[

View File

@ -73,8 +73,6 @@ Return the least weight capacity of the ship that will result in all the package
```go
package leetcode
func shipWithinDays(weights []int, D int) int {
maxNum, sum := 0, 0
for _, num := range weights {
@ -98,6 +96,22 @@ func shipWithinDays(weights []int, D int) int {
return low
}
func calSum(mid, m int, nums []int) bool {
sum, count := 0, 0
for _, v := range nums {
sum += v
if sum > mid {
sum = v
count++
// 分成 m 块,只需要插桩 m -1 个
if count > m-1 {
return false
}
}
}
return true
}
```