-
Notifications
You must be signed in to change notification settings - Fork 2
/
31.1 String Palidrom.java
59 lines (43 loc) · 1.17 KB
/
31.1 String Palidrom.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
/*
Kumar has been given a string and asked to determine whether it can be converted into a palindrome after removing at most one characte
Input Format
str="abcbea"
Constraints
1<=Str.length<=10^3 Str consists of Lowercase English characters
Output Format
true
Sample Input 0
abceba
Sample Output 0
true
Explanation 0
you can remove character 'e' to make it palindrome
*/
import java.io.*;
import java.util.*;
public class Solution {
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();
String r = "";
for(int i=0;i<s.length();i++)
{
char ch = s.charAt(i);
r = ch+r;
}
boolean check = true;
int count = 0;
int i=0;
for(i=0;i<s.length();i++)
{
if((s.charAt(i)!=r.charAt(i)))
count++;
}
if(count > 2)
{
check = false;
}
System.out.print(check);
}
}