How to check if a string is a palindrome or not? An Optimised Approach

preview_player
Показать описание
#tech #techreview #technews #smartphone #techtips #techyoutuber #mobile #techie #youtube
#youtuber #subscribe #youtubelikes #youtubevide #youtubemarketing #youtubeviews #instavideo
#instayoutube
Рекомендации по теме
Комментарии
Автор

//CODE IMPLEMENTATION//

class Palindrome{
public static void mai(String[ ] args) {
Scanner sc = new Scanner(System.in) ;
System.out.print("Enter a String") ;
String s = sc.next();

int i=0, j=s.length() -1;
while(i<s.length() & j>=0) {
if(i>j) {
System.out.println("String is Palindrome") ;
return;
else if(s.charAt(i)==s.charAt(j)) {
i++;
j--;
}
else{
System.out.println("String is not a Palindrome");
return;
}
}
}
}

//THANK YOU ❤.

bandhangowda
Автор

Can u please convert this explanation in code using array string and using recursion

mehakarora
Автор

But why we do complex code. can we use 2 variable 1st have racecar & then we can reverce to 1st variable value & assign result to 2nd Variable. once it done then will compare both variable is the same then we can say its Palindrome value.

skvprajapati
Автор

Create for loop.
I, core, i++
Iske andar
J, code, j--
Log().

Short me likha hai samajh jao

Mayank_Bisht_MB
Автор

Can anyone help me with the code have a few doubts

nikhilvlogs
Автор

You means need to make 2 loops? Is this more efficient?

Mayank_Bisht_MB
Автор

Sir i and j ko Initialize kase kare???

anmolkaur