Extract Unique characters
The first and only line of input contains a string, that denotes the value of S.
The first and only line of output contains the updated string, as described in the task.
0 <= Length of S <= 10^8
Time Limit: 1 sec
ababacd
abcd
abcde
abcde
#include<bits/stdc++.h>string uniqueChar(string str) { // Write your code here unordered_map<char,int>mp; string ans; for(int i=0;i<str.length();i++){ mp[str[i]]++; if(mp[str[i]]==1) ans.push_back(str[i]); } return ans;}
Comments
Post a Comment