Skip to content

Commit 49690a1

Browse files
committed
update 455.分发饼干; 代码报错
1 parent 4e0ec1f commit 49690a1

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

problems/0455.分发饼干.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ public:
7373
}
7474
};
7575
```
76-
* 时间复杂度:O(nlogn)
77-
* 空间复杂度:O(1)
7876
77+
- 时间复杂度:O(nlogn)
78+
- 空间复杂度:O(1)
7979
8080
从代码中可以看出我用了一个 index 来控制饼干数组的遍历,遍历饼干并没有再起一个 for 循环,而是采用自减的方式,这也是常用的技巧。
8181
@@ -119,9 +119,9 @@ public:
119119
}
120120
};
121121
```
122-
* 时间复杂度:O(nlogn)
123-
* 空间复杂度:O(1)
124122

123+
- 时间复杂度:O(nlogn)
124+
- 空间复杂度:O(1)
125125

126126
细心的录友可以发现,这种写法,两个循环的顺序改变了,先遍历的饼干,在遍历的胃口,这是因为遍历顺序变了,我们是从小到大遍历。
127127

@@ -177,7 +177,9 @@ class Solution {
177177
```
178178

179179
### Python
180+
180181
贪心 大饼干优先
182+
181183
```python
182184
class Solution:
183185
def findContentChildren(self, g, s):
@@ -192,7 +194,9 @@ class Solution:
192194
return result
193195

194196
```
197+
195198
贪心 小饼干优先
199+
196200
```python
197201
class Solution:
198202
def findContentChildren(self, g, s):
@@ -229,7 +233,7 @@ func findContentChildren(g []int, s []int) int {
229233
### Rust
230234

231235
```rust
232-
pub fn find_content_children(mut children: Vec<i32>, mut cookie: Vec<i32>) -> i32 {
236+
pub fn find_content_children(mut children: Vec<i32>, mut cookies: Vec<i32>) -> i32 {
233237
children.sort();
234238
cookies.sort();
235239

@@ -378,7 +382,9 @@ object Solution {
378382
}
379383
}
380384
```
385+
381386
### C#
387+
382388
```csharp
383389
public class Solution
384390
{

0 commit comments

Comments
 (0)