Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Create ReverseNum.py #269

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions BhaandkaDukaan
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//https://leetcode.com/problems/reverse-integer/
class Solution {
public int reverse(int x) {
int r = 0;
while(x!=0)
{
int r = x%10;
x=x/10;
if(rev> Integer.MAX_VALUE/10 ||rev == Integer.MAX_VALUE/10 && r > 7)
return 0;
if(rev< Integer.MIN_VALUE/10 ||rev == Integer.MIN_VALUE/10 && r > 8)
return 0;
r=r*10+r;
}
return r;
}
}
12 changes: 12 additions & 0 deletions ReverseNum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
num = int(input("Enter your favourite number: "))

test_num = 0


while(num>0):

remainder = num % 10
test_num = (test_num * 10) + remainder
num = num/10

print("The reverse number is :".format(test_num))