规范格式

This commit is contained in:
YDZ
2020-08-07 15:50:06 +08:00
parent 854a339abc
commit 4e11f4028a
1438 changed files with 907 additions and 924 deletions

View File

@ -0,0 +1,22 @@
package leetcode
func findPairs(nums []int, k int) int {
if k < 0 || len(nums) == 0 {
return 0
}
var count int
m := make(map[int]int, len(nums))
for _, value := range nums {
m[value]++
}
for key := range m {
if k == 0 && m[key] > 1 {
count++
continue
}
if k > 0 && m[key+k] > 0 {
count++
}
}
return count
}