We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7aae3ab commit 25049bcCopy full SHA for 25049bc
scripts/algorithms/F/First Letter to Appear Twice/First Letter to Appear Twice.cpp
@@ -1,14 +1,15 @@
1
-class Solution
+// Runtime: 4 ms (Top 25.64%) | Memory: 6.2 MB (Top 18.83%)
2
+class Solution
3
{
4
public:
- char repeatedCharacter(string s)
5
+ char repeatedCharacter(string s)
6
7
unordered_map<char, int> mp; //for storing occurrences of char
-
8
+
9
char ans;
10
for(auto it:s)
11
- if(mp.find(it) != mp.end()) //any char which comes twice first will be the ans;
12
+ if(mp.find(it) != mp.end()) //any char which comes twice first will be the ans;
13
14
ans = it;
15
break;
@@ -17,4 +18,4 @@ class Solution
17
18
}
19
return ans;
20
-};
21
+};
0 commit comments