ง่าย 0 ข้อที่แก้แล้ว อัตราผ่าน 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.

เงื่อนไข

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

ตัวอย่าง

ตัวอย่างที่ 1
อินพุต:
n = 352

ผลลัพธ์ที่คาดหวัง:
expected = 253
อินพุต:
long long n = 352;

ผลลัพธ์ที่คาดหวัง:
long long expected = 253;
อินพุต:
long n = 352;

ผลลัพธ์ที่คาดหวัง:
long expected = 253;

คำอธิบาย

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

ตัวอย่างที่ 2
อินพุต:
n = 1200

ผลลัพธ์ที่คาดหวัง:
expected = 21
อินพุต:
long long n = 1200;

ผลลัพธ์ที่คาดหวัง:
long long expected = 21;
อินพุต:
long n = 1200;

ผลลัพธ์ที่คาดหวัง:
long expected = 21;

คำอธิบาย

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

เรียนรู้จากคนอื่น

แนวทางจากชุมชน

ยังไม่มีวิธีทำที่เผยแพร่ ลองแก้โจทย์นี้เพื่อแชร์วิธีแรก