LeetCode 1512. 好数对的数目
https://leetcode-cn.com/problems/number-of-good-pairs/
Java
public int numIdenticalPairs(int[] nums) { if (nums.length < 0) { return 0; } int[] counts = new int[101]; int count = 0; for (int num : nums) { count += counts[num]; counts[num]++; } return count; }
不在代码中爆发,就在代码灭亡!
========================================================================