
Asked in Cognizant and 49 others
Write a JavaScript code to check if a string is a palindrome.

AnswerBot
11mo
To check if a string is a palindrome, compare the string with its reverse.
Create a function to reverse the input string.
Compare the original string with the reversed string to check for palindrome.
Exa...read more
Anonymous
11mo
class Solution { public boolean isPalindrome(String s) { s = s.toLowerCase().replaceAll("[^a-z0-9]", ""); int i = 0; int j = s.length() - 1; while(i <= j) { if (s.charAt(i) != s.charAt(j)) { return fa...read more
Anonymous
1y
public static void polindromNumber(){ String original, reverse =""; Scanner sc = new Scanner(System.in); original= sc.nextLine(); for(int i= original.length()-1 ; i>=0 ;i--){ reverse = reverse+origin...read more
madhavi punna
1y
public static void main (string[]args) { Scanner sc=new Scanner(System.in); System.out.println("Enter your String:"); String str=sc.next(); String str=org_str; String rev=" "; int len=str.length(); fo...read more
Anonymous
1y
func palindrome(n int) bool {
rev := 0
curr := n
for n > 0 {
p := n % 10
rev = rev*10 + p
n = n / 10
}
if curr == rev {
return true
} else {
return false
}
}
Add answer anonymously...
Interview Questions from Popular Companies

3.7
• 8.7k Interviews

4.0
• 5.4k Interviews

3.5
• 4.2k Interviews

3.6
• 8k Interviews

3.7
• 6k Interviews

3.7
• 6.1k Interviews

3.5
• 4.2k Interviews

3.7
• 5.1k Interviews
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

