X

DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
Reverse digits
School Accuracy: 54.86% Submissions: 11489 Points: 0

Given N,  reverse the digits of N.
 

Example 1:

Input: 200
Output: 2
Explanation: By reversing the digts of 
number, number will change into 2.

Example 2:

Input : 122
Output: 221
Explanation: By reversing the digits of 
number, number will change into 221.

 

Your Task:
You don't need to read or print anything. Your task is to complete the function reverse_digit() which takes N as input parameter and returns the reversed number.

 

Expected Time Complexity: O(Log(N))
Expected Space Complexity: O(1)

 

Constraints:
1 <= N <= 1015

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Reverse digits

Output Window