Created
March 17, 2017 05:23
-
-
Save M-ZubairAhmed/629c4679680bff1693678c99d22f2f30 to your computer and use it in GitHub Desktop.
Pattern generating algorithm. eg: abcd -> A-Bb-Ccc-Dddd
This file contains hidden or 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
public class Accumul { | |
public static String accum(String s){ | |
StringBuilder stBuild = new StringBuilder(); | |
for(int i = 0; i < s.length(); i++){ | |
for(int j = 0; j <= i; j++) { | |
if (j==0){ | |
stBuild.append(s.toUpperCase().charAt(i)); | |
} | |
else { | |
stBuild.append(s.toLowerCase().charAt(i)); | |
} | |
} | |
stBuild.append('-'); | |
} | |
stBuild.delete(stBuild.length()-1,stBuild.length()); | |
return stBuild.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment