We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dbc93eb commit baf7ed1Copy full SHA for baf7ed1
problems/1207.独一无二的出现次数.md
@@ -221,6 +221,28 @@ func uniqueOccurrences(arr []int) bool {
221
}
222
```
223
224
+### Rust
225
+
226
+```rust
227
+use std::collections::{HashMap, HashSet};
228
+impl Solution {
229
+ pub fn unique_occurrences(arr: Vec<i32>) -> bool {
230
+ let mut hash = HashMap::<i32, i32>::new();
231
+ for x in arr {
232
+ *hash.entry(x).or_insert(0) += 1;
233
+ }
234
+ let mut set = HashSet::<i32>::new();
235
+ for (_k, v) in hash {
236
+ if set.contains(&v) {
237
+ return false
238
+ } else {
239
+ set.insert(v);
240
241
242
+ true
243
244
+}
245
+```
246
247
248
0 commit comments