First Repeated Character
You are given a string 'STR' of lowercase English alphabets. You need to find the repeated character present first in the string.
Example:
If the string is: “abccba”, then the first repeated character is ‘c’, but the repeated character that is present first in the string is ‘a’. You need to print ‘a’.
Note:
Keep in mind that you need to print the repeated character that is present first in the string and not the first repeating character.
Input Format:
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case will contain a string ‘S’, which denotes the string of lowercase English alphabets.
Output Format:
For each test case, print the repeated character that occurs first in the string. If no repeated character is found then print ‘%’.
Output for every test case will be printed in a separate line.
Note:
You don't need to print anything. It has already been taken care of.
You just need to complete the “repeatedCharacter” function that returns the first repeating character in the string. In case there is no repeating character then return “%”.
Constraints:
1 <= T <= 200
0 <= size of S <= 10000
where 'S’ is the string of lowercase English alphabets.
Time limit: 1 sec
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