string reverseString(string s) { unordered_map<char,int>mp; string ans=""; for(int i=s.length()-1 ; i>=0 ; i--) { mp[s[i]]++; if((mp[s[i]]==1)&&(s[i]!=' ')) { ans+=s[i]; } } return ans; }
Preview:
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