Characters at Even Positions
EasyP3Coding
Return the characters of s at even indices (0, 2, 4, ...) 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
- ["a","c","e"]
Example 2
- Input
- s = "abcd"
- Output
- ["a","c"]
Example 3
- Input
- s = "a"
- Output
- ["a"]
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.