Nth Repeating Character - String | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Nth Repeating Character - String

A string S is passed as the input to the program. The program must print the Nth repeating character C in the string S. The repeating characters are considered in their order of occurrence from the beginning of the string S. If no such Nth repeating character is present the program must print -1 as the output. Input Format: The first line contains the value of S. Output Format: The first line contains the value of C. Boundary Conditions: 2 <= Length of S <= 1000 Example Input/Output 1: Input: abcdaeaedbapple 3 Output: d Explanation: a is the first repeating character. b is the second repeating character. c is not repeating and hence not considered. d is the third repeating character and as here N=3, d is printed as the output. Example Input/Output 2: Input: desktoppublishing 3 Output: i

2nd Jul 2018, 12:28 PM
OBULIRAJ S
OBULIRAJ S - avatar
4 Answers
0
Hi OBULIRAJ S , Welcome to Q&A! This looks like a statement. What's your question?
2nd Jul 2018, 1:45 PM
Janning⭐
Janning⭐ - avatar
+ 1
Nice. Add [ASSIGNMENT] to the title so that people know its an Assignment. Heres my try. https://code.sololearn.com/cfangEi42Ugr/?ref=app
2nd Jul 2018, 6:18 PM
Louis
Louis - avatar
+ 1
Louis hi, could u check this out? it’s a one-liner, but pretty lame way to do the task! https://code.sololearn.com/ceyl6R78s2y5/?ref=app
2nd Jul 2018, 11:16 PM
Flash
+ 1
Very nice Flash. VcC would be proud of you.
3rd Jul 2018, 3:08 AM
Louis
Louis - avatar