forked from RyanFehr/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
45 lines (31 loc) · 1 KB
/
Solution.java
File metadata and controls
45 lines (31 loc) · 1 KB
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
package strings;
//A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward.(Wikipedia)
//Given a string , print Yes if it is a palindrome, print No otherwise.
//
//Constraints
// will consist at most lower case english letters.
//Sample Input
//
//madam
//Sample Output
//
//Yes
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String A=sc.next();
/* Enter your code here. Print output to STDOUT. */
boolean palindrome = true;
for(int i = 0; i<A.length()/2;i++)
{
if(!A.substring(i,i+1).equals(A.substring(A.length()-i-1,A.length()-i)))
{
palindrome = false;
}
}
if(palindrome){System.out.println("Yes");}
else{System.out.println("No");}
}
}