-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheck String
More file actions
46 lines (38 loc) · 830 Bytes
/
Check String
File metadata and controls
46 lines (38 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//{ Driver Code Starts
//Initial Template for Java
import java.io.*;
import java.util.*;
class GfG
{
public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- > 0)
{
String s = sc.next ();
if (new Sol().check (s))
System.out.println ("YES");
else
System.out.println ("NO");
}
}
}
// Contributed By: Pranay Bansal
// } Driver Code Ends
//User function Template for Java
class Sol
{
Boolean check (String s)
{
int i=0;
int j= s.length()-1;
while(i<=j){
if(s.charAt(i) != s.charAt(j))
return false;
i++;
j--;
}
return true;
}
}