Preview:
#include <bits/stdc++.h>
using namespace std;  

int uniquestring(string s)
{
      int a[26];
for(int i=0;i<26;i++)
a[i]=0;
for(int i =0;i<s.length();i++)
{
    int m = s[i];
    a[m - 97]++;
}

for(int i =0;i<s.length();i++)
{
    int t = s[i];
    if(a[t-97] == 1)
    {
   return i+1;
    }
}
return -1;
}
int main()  
{  
   map<char, int> wordFreq;
    string s, t;
    cin >> s;
 cout << uniquestring(s);
}  
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter