We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0e64838 + 8e8e078 commit 3088d12Copy full SHA for 3088d12
README.md
@@ -49,6 +49,8 @@ Step 2. Add the dependency
49
50
<summary>展开查看</summary>
51
52
+https://leetcode-cn.com/problems/assign-cookies/
53
+
54
https://leetcode-cn.com/problems/evaluate-the-bracket-pairs-of-a-string/
55
56
https://leetcode.cn/problems/find-the-middle-index-in-array/
assign-cookies/index.ts
@@ -0,0 +1,14 @@
1
+function findContentChildren(g: number[], s: number[]): number {
2
+ g = g.sort((a, b) => a - b)
3
+ s = s.sort((a, b) => a - b)
4
+ let result = 0
5
+ let index = s.length - 1
6
+ for(let i = g.length - 1; i >= 0; i--) {
7
+ if(index >= 0 && s[index] >= g[i]) {
8
+ result++
9
+ index--
10
+ }
11
12
+ return result
13
+}
14
+export default findContentChildren
0 commit comments