Given a String str and an int n, return a one-character String containing the nth character of the input, but only when the nth character is the same as the character after it. For this problem, some of the inputs will have less than n+1 characters. If the input does not have the proper repeating characters, return an empty string. If the input has less than n+1 characters, return the entire input.
Something to rememberThis is in the hint too, but it's worth remembering. The nth character of a String is actually the character with index (n-1). The first character has index 0, the second character has index 1 and so forth.
hcsStringsGimmeDoubled("Aladdin", 4) → "d"
hcsStringsGimmeDoubled("hi", 4) → "hi"
hcsStringsGimmeDoubled("moo", 2) → "o"
...Save, Compile, Run (ctrl-enter)
Difficulty: 150 Post-solution available