Characters at Odd Positions
EasyP3Coding
Return the characters of s at odd indices (1, 3, 5, ...) as an array of one-character strings, in order. The result has one line per character, as if printed one per line.
Example 1
- Input
- s = "abcde"
- Output
- ["b","d"]
Example 2
- Input
- s = "abcd"
- Output
- ["b","d"]
Example 3
- Input
- s = "a"
- Output
- []
Constraints
- 0 <= s.length <= 10^5
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 10. ⌘Enter runs, ⌘⇧Enter submits.