Skip to content

Commit d8c2a16

Browse files
authored
Create index.ts
1 parent 10940f2 commit d8c2a16

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

assign-cookies/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function findContentChildren(g: number[], s: number[]): number {
2+
g.sort((a, b) => a - b);
3+
s.sort((a, b) => a - b);
4+
const m = g.length, n = s.length;
5+
let count = 0;
6+
for (let i = 0, j = 0; i < m && j < n; i++, j++) {
7+
while (j < n && g[i] > s[j]) {
8+
j++;
9+
}
10+
if (j < n) {
11+
count++;
12+
}
13+
}
14+
return count;
15+
}
16+
export default findContentChildren

0 commit comments

Comments
 (0)