1748. 唯一元素的和

题目链接:https://leetcode-cn.com/problems/sum-of-unique-elements/

执行用时:0 ms, 在所有 Java 提交中击败了100.00% 的用户
内存消耗:39.3 MB, 在所有 Java 提交中击败了5.13% 的用户

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Solution {
public int sumOfUnique(int[] nums) {
int[] array = new int[101];
for (int i : nums) {
array[i]++;
}
int ans = 0;
for (int i = 0; i < 101; i++) {
if (array[i] == 1) {
ans += i;
}
}
return ans;
}
}

1748. 唯一元素的和
https://pisces34.github.io/2022/02/06/leetcode/1748/
发布于
2022年2月6日
许可协议