Skip to content
Onsite

Number from Reversed Digit Array

EasyP3Coding

digits holds decimal digits (0 to 9). Build the number formed by reading the digits from the last element to the first, and return it as an integer. Leading zeros in the result disappear, so [1,0,0] gives 1. An empty array gives 0.

Example 1

Input
digits = [1,2,3]
Output
321
Why
Reading 3, 2, 1 gives 321.

Example 2

Input
digits = [0]
Output
0

Example 3

Input
digits = []
Output
0

Constraints

  • 0 <= digits.length <= 15
  • 0 <= digits[i] <= 9

Hints

Run checks the 3 visible tests, Submit all 10.