-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStringReversePalindrome.java
65 lines (43 loc) · 1.26 KB
/
StringReversePalindrome.java
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
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 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. */
/* char first=A.charAt(0);
System.out.println(first);
int value=A.length();
char second=A.charAt(1);
System.out.println(second);
for(int i=0;i <3;i++){
if(A.charAt(i)==A.charAt(value)){
}
String substring=indexOf(A);
System.out.println(substring);
*/
String B="";
// System.out.println(A.length());
for(int i=A.length()-1;i>=0;i--){
char char_value=A.charAt(i);
B=B+char_value;
// System.out.println(B);
}
if (A.equals(B))
System.out.println("Yes");
else
System.out.println("No");
}
}