leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0387.cpp (262B)


      1 class Solution {
      2   public:
      3     int firstUniqChar(string s) {
      4         vector<int> um(26, 0);
      5         for (char c : s)
      6             um[c - 'a']++;
      7         for (int i = 0; i < s.size(); i++)
      8             if (um[s[i] - 'a'] == 1) return i;
      9         return -1;
     10     }
     11 };