Check If The String Is A Palindrome
You are given a string 'S'. Your task is to check whether the string is palindrome or not. For checking palindrome, consider alphabets and numbers only and ignore the symbols and whitespaces.
Note :
String 'S' is NOT case sensitive.
Example :
Let S = “c1 O$d@eeD o1c”.
If we ignore the special characters, whitespaces and convert all uppercase letters to lowercase, we get S = “c1odeedo1c”, which is a palindrome. Hence, the given string is also a palindrome.
Input format :
The very first line of input contains an integer 'T' denoting the number of test cases.
The first line of every test case contains the string 'S'.
Output format :
For each test case, print “Yes” if 'S' is a palindrome, and “No” otherwise.
Print the output of each test case in a separate line.
Note :
You do not need to print anything, it has already been taken care of. Just implement the given function.
Follow Up :
Can you solve the problem using O(1) space complexity?
Constraints :
1 <= T <= 100
1 <= Length(S) <= 10^4
Where 'T' denotes the number of test cases and 'S' denotes the given string.
Time Limit : 1 sec
CodingNinjas
author
2y
Code :
import java.util.*;
public class Test {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
String word = s.nextLine();
System.out.println("Is "+word+" palindrome? - "+isW...read more
CodingNinjas
author
2y
Reverse and Compare
- A palindrome string is a sequence of characters which reads the same backward as forward. We use this property of palindrome to check whether the given string is a palindrome or not...read more
CodingNinjas
author
2y
Iterate from Start and End
- A palindrome string is a sequence of characters which reads the same backward as forward. We use this property of palindrome to check whether the given string is a palindrome...read more
Add answer anonymously...
Top Capita Software Consultant interview questions & answers
Popular interview questions of Software Consultant
Top HR questions asked in Capita Software Consultant
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app