Skip to content

Commit 0a0f0fa

Browse files
committed
Runtime: 785 ms (Top 5.01%) | Memory: 176.5 MB (Top 5.07%)
1 parent 0dff566 commit 0a0f0fa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

scripts/algorithms/N/Number of Excellent Pairs/Number of Excellent Pairs.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Runtime: 785 ms (Top 5.01%) | Memory: 176.5 MB (Top 5.07%)
12
class Solution {
23
public long countExcellentPairs(int[] nums, int k) {
34
HashMap<Integer,Set<Integer>> map = new HashMap<>();
@@ -11,10 +12,10 @@ public long countExcellentPairs(int[] nums, int k) {
1112
for(int i : nums){
1213
if(vis.contains(i)) continue;
1314
int need = Math.max(0,k-Integer.bitCount(i));
14-
for(int key : map.keySet()) // runs at max 30 times
15-
if(key >= need) ans += (long) map.get(key).size();
15+
for(int key : map.keySet()) // runs at max 30 times
16+
if(key >= need) ans += (long) map.get(key).size();
1617
vis.add(i);
1718
}
1819
return ans;
1920
}
20-
}
21+
}

0 commit comments

Comments
 (0)