Leetcode 9. Palindrome Number [Java]
ฝัง
- เผยแพร่เมื่อ 22 ส.ค. 2024
- Check out how to solve the leetcode 9 Palindrome Number question in Java.
Question URL: leetcode.com/p...
Please write in the comments below which leetcode problem you want me to solve next.
And remember, a leetcode a day keeps unemployment away!
Thanks for watching!
#leetcode9
Awesome bro)) I was able to do this question pretty easily but wanted to check how to do it without string conversion like you show in the video. Spasibo!
String conversion would not give you a good offer in a prestigious company if this exact problem would appear in an interview. Always think not about just how to solve the problem but how to solve the problem in a most efficient day! And remember, leetcode a day keeps sh**ty unemployment away! All the best and thanks for watching!
thank you
*why it's wrong??!!!*
(c++)
#include
using namespace std;
int main()
{
int x ;
cin>>x;
int n = x ;
if(x > 0)
{
int rev = 0 ;
while(x > 0)
{
rev = (rev*10) + (x%10) ;
x /= 10 ;
}
if(n == rev)
{
cout