Easy · Strings
Swap even odd
Given a string s, swap the characters at indices 0 and 1, 2 and 3, and so on (each even index with the index after it), leave a final unpaired character in place, and return the resulting string.
Examples
Example 1
{
"s": "abcdef"
}Output: "badcfe"
Example 2
{
"s": "algorithm"
}Output: "laogirhtm"
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.