Java Edabit: Index Shuffle, Easy Difficulty
- Justin Mah
- May 3, 2021
- 1 min read
Solving this question in Edabit: https://edabit.com/challenge/BZzAm9KXuB993p35r
Question:

Answer:

public class Challenge {
public static String indexShuffle(String str) {
String even = "";
String odd = "";
int count = 0;
for(char i : str.toCharArray()) {
if(count % 2 == 0) {
even += str.charAt(count);
} else {
odd += str.charAt(count);
}
count++;
}
return even + odd;
}
}
Comments