C++ 2 lines solution 56ms


  • 0
    5

    class Solution {
    public:
    int firstUniqChar(string s) {
    for (int i=0; i < s.size(); i++) if(s.find(s[i]) == s.rfind(s[i])) return i;
    return -1;
    }
    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.