X242: oneTwo

Given a string, compute a new string by moving the first char to come after the next two chars, so "abc" yields "bca". Repeat this process for each subsequent group of 3 chars, so "abcdef" yields "bcaefd". Ignore any group of fewer than 3 chars at the end.

Examples:

oneTwo("abc") -> "bca"
oneTwo("tca") -> "cat"
oneTwo("chocolate") -> "hocolctea"

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.