Skip to content

Commit a412efc

Browse files
authored
Create 0455_assing_cookies.rs
1 parent 2477882 commit a412efc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

rust/easy/0455_assing_cookies.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
impl Solution {
2+
pub fn find_content_children(g: Vec<i32>, s: Vec<i32>) -> i32 {
3+
let mut g = g;
4+
let mut s = s;
5+
g.sort_unstable_by(|a, b| b.cmp(&a));
6+
s.sort_unstable_by(|a, b| b.cmp(&a));
7+
let mut answer = 0;
8+
let (mut i, mut j) = (0, 0);
9+
while i < g.len() && j < s.len() {
10+
if s[j] >= g[i] {
11+
answer += 1;
12+
j += 1;
13+
}
14+
i += 1;
15+
}
16+
answer
17+
}
18+
}

0 commit comments

Comments
 (0)