Skip to content

Commit 715e4a6

Browse files
authored
feat: update solution to lc problem: No.3394
1 parent ba060d5 commit 715e4a6

File tree

1 file changed

+1
-2
lines changed
  • solution/3300-3399/3396.Minimum Number of Operations to Make Elements in Array Distinct

1 file changed

+1
-2
lines changed

solution/3300-3399/3396.Minimum Number of Operations to Make Elements in Array Distinct/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,9 @@ class Solution {
122122
public int minimumOperations(int[] nums) {
123123
Set<Integer> s = new HashSet<>();
124124
for (int i = nums.length - 1; i >= 0; --i) {
125-
if (s.contains(nums[i])) {
125+
if (!s.add(nums[i])) {
126126
return i / 3 + 1;
127127
}
128-
s.add(nums[i]);
129128
}
130129
return 0;
131130
}

0 commit comments

Comments
 (0)