-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringReverse.java
More file actions
43 lines (35 loc) · 1 KB
/
Copy pathStringReverse.java
File metadata and controls
43 lines (35 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
/*
Problem Statement : Java String Reverse
A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward.
Given a string A, print Yes if it is a palindrome, print No otherwise.
Constraints
A will consist at most 50 lower case english letters.
Sample Input
madam
Sample Output
Yes
*/
import java.io.*;
import java.util.*;
public class Solution14 {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
String s= sc.next();
boolean a= false;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i)==s.charAt(s.length()-i-1)){
a= true;
}
else {
a=false;
}
}
if (a==true){
System.out.println("Yes");
}
else {
System.out.println("No");
}
}
}