Array to String with Negatives as Zero
EasyP3Coding
Join the elements of arr into one string with no separator, writing 0 in place of every negative number. A non-negative number is written as its decimal digits, so [12, -5, 7] gives "1207".
Example 1
- Input
- arr = [12,-5,7]
- Output
- "1207"
Example 2
- Input
- arr = [1,2,3]
- Output
- "123"
Example 3
- Input
- arr = [-1,-2]
- Output
- "00"
Constraints
- 1 <= arr.length <= 1000
- -1000 <= arr[i] <= 1000
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 8. ⌘Enter runs, ⌘⇧Enter submits.