Reverse Integer | LeetCode problem 7
Vložit
- čas přidán 28. 09. 2022
- Reverse Integer
Leetcode problem number 5
Solution in JAVA
JAVA interview programming playlist:
• Interview Programming ...
Linkedin: / amrita-bala-a2b79460
#java #interviewquestions #leetcode - Věda a technologie
Wow! You handled overflow condition greatly, Thank You!
Great explanation, but it would be great if you use dark theme on leetcode
Good explanation amrutha
Great explanation. Thank you.
Great explanation thank you😄👍
great explanation !!!
very well explained ! tysm
Great !!
great Work !
Amazing explanation
NICE SUPER EXCELLENT MOTIVATED
Amazing...keep up the good work. I like the way you break down the problem on white board but please slow it down a little bit when you code.
Sure
Really helpful
thankuu...😇
Thank you Di😊
Amazing
Hello.. Thankyou for this video.
Can you explain please why can't we use overflow condition like
if (rev*10 > Integer.MAX_VALUE || rev*10 < Integer.MIN_VALUE)
Hello mam if rev>max or min we need to get output as 0 then y it is returning garbage value .Leet code is not accepting this code...
Hi .. It is giving 0 only when rev> max or min. .I have shown in the video ,when we don't consider that condition , it would give garbage value.. I think you missed the end part of video.. Please try the code from git repo.. Leetcode is accepting the code.. Thanks!
Why you are dividing by 10 to check overflow condition
reversed * 10 > INT_MAX would mean performing the multiplication first which could already cause overflow
ye gys kaha se aa gya ?
didi
gys?? Sorry..didn't get your question..Can you be more specific?
import java.util.*;
class Main {
public static void main (String [] args){
int nums=4567;
System.out.print(reverseInt(nums)) ;
}
public static int reverseInt(int n) {
int rev=0;
while(n>0){
int Lastdigit=n%10;
n=n/10;
rev=rev*10+Lastdigit;
}
return rev;
}
}