Dễ 0 đã giải Tỷ lệ chấp nhận 0%

Reverse a Number

Reverse the decimal digits of a positive integer.

Write the decimal digits of n in reverse order and return the resulting number. Zeros that end up at the front disappear, so 1200 becomes 21.

Implement reverse_number(n).

Input

n: A positive integer.

Output

Return the reversed number.

Ràng buộc

1 ≤ n ≤ 10¹⁸. The reversed value always fits a signed 64-bit integer.

Ví dụ

Ví dụ 1
Đầu vào:
n = 352

Kết quả mong đợi:
expected = 253
Đầu vào:
long long n = 352;

Kết quả mong đợi:
long long expected = 253;
Đầu vào:
long n = 352;

Kết quả mong đợi:
long expected = 253;

Giải thích

The digits 3, 5, 2 reversed are 2, 5, 3.

Ví dụ 2
Đầu vào:
n = 1200

Kết quả mong đợi:
expected = 21
Đầu vào:
long long n = 1200;

Kết quả mong đợi:
long long expected = 21;
Đầu vào:
long n = 1200;

Kết quả mong đợi:
long expected = 21;

Giải thích

Reversed digits are 0021; leading zeros are dropped, giving 21.

Học hỏi từ người khác

Giải pháp cộng đồng

Chưa có giải pháp nào được chia sẻ. Hãy giải thử thách này để đăng giải pháp đầu tiên.