-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc88.c
More file actions
45 lines (44 loc) · 880 Bytes
/
c88.c
File metadata and controls
45 lines (44 loc) · 880 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
35
36
37
38
39
40
41
42
43
44
45
#include<stdio.h>
#include<string.h>
#include<stdbool.h>
//palindrome check on removal of any character
bool isPalindrome(char *s, int left, int right)
{
while (left<right)
{
if(s[left]!=s[right])
{
return false;
}
left++; right--;
}
return true;
}
bool ValidPal(char *s)
{
int left = 0 , right = strlen(s)-1;
while (left<right)
{
if(s[left]!=s[right])
{
return isPalindrome(s,left+1,right) ||
isPalindrome(s,left,right-1) ;
}
left++;
right--;
}
return true;
}
int main(){
char s[100];
printf("Enter a string: ");
scanf("%s",s);
if(ValidPal(s))
{
printf("Yes it can be valid palindrom on one character removal");
}
else
{
printf("aint valid palidrome even after removing one");
}
}