Skip to content

Commit 90ccc90

Browse files
committed
🚀(LEETCODE) First Unique Character
1 parent 9571917 commit 90ccc90

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution
2+
{
3+
public:
4+
int firstUniqChar(string s)
5+
{
6+
unordered_map<char, int> mp1;
7+
for (auto c : s)
8+
mp1[c]++;
9+
for (int i = 0; i < s.length(); i++)
10+
if (mp1[s[i]] == 1)
11+
return i;
12+
return -1;
13+
}
14+
};

0 commit comments

Comments
 (0)