String, find the first non-repeating character in it and returnit’s index. If it doesn’t exist, return -1.(c++)
s = “leetcode”
return 0.
s = “loveleetcode”,
return 2.
Answer
#include <string>#include <iostream>using namespace std;int non_repeated_index(string s) { int count; for(int i = 0; i < s.length(); ++i) { count = 0; for(int j = 0; j < s.length(); ++j) { if(s[i] == s[j]) {
OR
OR