Untitled
Anonymous
plain_text
02/16/2026 6:11 PM
564 B
26
Indexable
// TC: O(N log N)
// MC: O(N)
class Solution {
public:
int firstUniqueFreq(vector<int>& nums) {
int ans = -1;
map<int, int> mp, f;
for(auto &x : nums) {
mp[x]++;
}
for(auto &[x, y] : mp) {
f[y]++;
}
for(auto &x : nums) {
if(f[mp[x]] == 1) {
ans = x; break;
}
}
return ans;
}
};Editor is loading...
Leave a Comment