Array of Digits to Integer
EasyP3Coding
digits holds single decimal digits, most significant first. Return the integer they form. Leading zeros do not change the value, so [0, 0, 7] gives 7.
Example 1
- Input
- digits = [1,2,3]
- Output
- 123
Example 2
- Input
- digits = [0]
- Output
- 0
Example 3
- Input
- digits = [9]
- Output
- 9
Constraints
- 1 <= digits.length <= 15
- 0 <= digits[i] <= 9
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.