-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringReverse.java
More file actions
34 lines (24 loc) · 849 Bytes
/
StringReverse.java
File metadata and controls
34 lines (24 loc) · 849 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
// A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward.(Wikipedia)
// Given a string A, print Yes if it is a palindrome, print No otherwise.
// Constraints
// A will consist of at most 50 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();
StringBuilder input = new StringBuilder();
input.append(A);
StringBuilder inputReverse = input.reverse();
String AReverse = inputReverse.toString();
if (A.equals(AReverse)){
System.out.println("Yes");}
else {
System.out.println("No");}
}
}