Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dac850d

Browse files
Create Extract Unique characters
1 parent 46d922d commit dac850d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎Hashmaps/Extract Unique characters

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include<string>
2+
#include<unordered_map>
3+
string uniqueChar(string str) {
4+
string ans="";
5+
unordered_map<char,bool> ourmap;
6+
for(int i=0;i<str.length();i++){
7+
if(ourmap[str[i]]==true){
8+
continue;
9+
}
10+
else{
11+
ourmap[str[i]]=true;
12+
ans=ans+str[i];
13+
}
14+
}
15+
return ans;
16+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /