PPK(outdated)
if (!state) {
temp1 += s.charAt(i);
} else if (state) {
temp2 += s.charAt(i);}}
s = temp2 + temp1;
System.out.println(s);}}
Recursion (mostly codingBat solutions)
1. Count the number of certain word in a string
if(str.length() < 2) return 0;
if(str.startsWith("hi")) return 1 + countHi(str.substring(1));
return countHi(str.substring(1)) ; }
2. Replace pi with 3.14 (hhhpihhh -> hhh3.14hhh)
if(str.length()<2) return str;
if(str.startsWith("pi")) return
"3.14" + changePi(str.substring(2));
return str.charAt(0) + changePi(str.substring(1));
4. Given a string, compute recursively a new string where all the adjacent
chars are now separated by a "*".
if(str.length()==1 || str.equals("")) return str;