Created
November 4, 2020 10:50
-
-
Save udhaya21/9c13c4f0a51219ed958f693a36d77d98 to your computer and use it in GitHub Desktop.
This time no story, no theory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Accumul.accum("abcd"); // "A-Bb-Ccc-Dddd" | |
// Accumul.accum("RqaEzty"); // "R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy" | |
// Accumul.accum("cwAt"); // "C-Ww-Aaa-Tttt" | |
public class Accumul { | |
public String accum(String s) { | |
StringBuilder result = new StringBuilder(); | |
int i = 0; | |
for (char c : s.toCharArray()) { | |
if (i > 0) | |
result.append('-'); | |
result.append(Character.toUpperCase(c)); | |
for (int j = 0; j < i; j++) | |
result.append(Character.toLowerCase(c)); | |
i++; | |
} | |
return result.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment