Skip to content

Commit ad81ab2

Browse files
committed
Assign Cookies
1 parent 40c4c83 commit ad81ab2

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/leetcode2018/AssignCookies.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package leetcode2018;
2+
3+
public class AssignCookies {
4+
public int findContentChildren(int[] g, int[] s) {
5+
int t = 0;
6+
for(int i = 0; i< g.length; i++){
7+
if(isContent(g[i], s))
8+
t++;
9+
}
10+
return t;
11+
}
12+
13+
public boolean isContent(int n, int[] s){
14+
for(int i = 0; i< s.length; i++){
15+
if(s[i]!=-1){
16+
if(s[i] >= n){
17+
s[i]=-1;
18+
return true;
19+
}
20+
}
21+
}
22+
return false;
23+
}
24+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy