mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
添加 0383.赎金信 go版
This commit is contained in:
@ -166,6 +166,21 @@ class Solution(object):
|
|||||||
```
|
```
|
||||||
|
|
||||||
Go:
|
Go:
|
||||||
|
```go
|
||||||
|
func canConstruct(ransomNote string, magazine string) bool {
|
||||||
|
record := make([]int, 26)
|
||||||
|
for _, v := range magazine {
|
||||||
|
record[v-'a']++
|
||||||
|
}
|
||||||
|
for _, v := range ransomNote {
|
||||||
|
record[v-'a']--
|
||||||
|
if record[v-'a'] < 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
javaScript:
|
javaScript:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user