Advertisement
thewitchking

Untitled

Jun 22nd, 2025
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.23 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int firstUniqChar(string s) {
  4.        unordered_map<char, int> mp;
  5.  
  6.         for (auto a : s) mp[a]++;
  7.         for (int i = 0; i < s.size(); i++)if(mp[s[i]] == 1)return i;
  8.  
  9.         return -1;
  10.     }
  11. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement