C
c
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
#include <stdio.h>
int canRead(char *str1, char *str2, int i){
if(*str1 == str2[i]){
if(str1[1] == '\0')
return 1;
int left = 0, right = 0;
if(i > 0)
left = canRead(str1+1, str2, i-1);
if(str2[i+1] != '\0')
right = canRead(str1+1, str2, i+1);
return left||right;
}
return 0;
}
int strStuff(char *str1, char *str2){
int i = 0;
for(; str2[i] != '\0'; i++)
if(canRead(str1, str2, i))
return 1;
return 0;
}
int main(){
printf("%d", strStuff("so", "sos"));
printf("%d", strStuff("kayaks", "skay"));
printf("%d", strStuff("atatata", "ta"));
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run