Digits Before Letters
EasyP3Coding
s contains only digits and lowercase letters. Return a string made of all its digits first, then all its letters, each group in the same relative order as in s.
Example 1
- Input
- s = "r1h4l"
- Output
- "14rhl"
Example 2
- Input
- s = "abc"
- Output
- "abc"
Example 3
- Input
- s = "123"
- Output
- "123"
Constraints
- 1 <= s.length <= 10^5
- s contains only digits 0-9 and lowercase letters a-z.
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 11. ⌘Enter runs, ⌘⇧Enter submits.