top of page

Java Edabit: Index Shuffle, Easy Difficulty


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;

}

}


1 view0 comments
Post: Blog2_Post
bottom of page