Find First Repeated Character in a String
Given a string 'STR' composed of lowercase English letters, identify the character that repeats first in terms of its initial occurrence.
Example:
Input:
STR = "abccba"
Output:
"a"
Explanation:
Although the first repeating character is 'c', the character 'a' is the first repeated character by initial appearance.
Constraints:
- 1 <= T <= 200
- 0 <= length of S <= 10000
- ‘S’ consists of lowercase English alphabets.
In the scenario where no repeated character exists, output '%'.
Note:
Ensure that you return the repeated character that appears first, rather than simply the first character that repeats. If there are no repeating characters, return '%'. The function to implement is called “repeatedCharacter”.
Be the first one to answer
Add answer anonymously...
Top Borderfree Mern Stack Developer interview questions & answers
Popular interview questions of Mern Stack Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app