about | help | code help+videos | done | prefs |
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. HINTSThe 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. Use substring() with two parameters or charAt() to extract characters from a String. You will probably need to use length() and maybe also equals(). Remember that the nth character has index n-1. apcsaStringsGimmeDoubled("Aladdin", 4) → "d" apcsaStringsGimmeDoubled("hi", 4) → "hi" apcsaStringsGimmeDoubled("moo", 2) → "o" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 150
Copyright Nick Parlante 2017 - privacy