Skip to content

Commit dbd5ab7

Browse files
committed
ConvertToPalindrome(String) added in the Strings
1 parent 86a1306 commit dbd5ab7

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
string A;
7+
cin>>A;
8+
int n = A.size();
9+
int i=0, j=n-1, count=0;
10+
while(i<j)
11+
{
12+
if(A[i]==A[j])
13+
{
14+
i++;
15+
j--;
16+
}
17+
else if(A[i+1]==A[j] && count == 0)
18+
{
19+
count++;
20+
i++;
21+
}
22+
else if(A[i]==A[j-1] && count == 0)
23+
{
24+
count++;
25+
j--;
26+
}
27+
else break;
28+
}
29+
if(i<j)
30+
cout<<"0"<<endl;
31+
else
32+
cout<<"1"<<endl;
33+
}
34+

0 commit comments

Comments
 (0)