-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTASHIFT.cpp
More file actions
46 lines (39 loc) · 690 Bytes
/
Copy pathTASHIFT.cpp
File metadata and controls
46 lines (39 loc) · 690 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
46
#include<iostream>
#include<string.h>
using namespace std;
int main(){
long long int n;
cin>>n;
/*char st1[n];
char st2[n];*/
string s1,s2;
cin>>s1>>s2;
const char *st1=s1.c_str();
const char *st2=s2.c_str();
/*cin.getline(st1,n);
cin.getline(st2,n);*/
long int count;
long int idf=-1;
long int prevcount=0;
// cout<<st1<<" "<<strlen(st1)<<endl;
// cout<<st2<<" "<<strlen(st2)<<endl;
for( long int i=0;i<n;i++){
if(st2[i]==st1[0]){
int j=0; int id=i;
count=0;
//cout<<i<<endl;
while(st1[j]==st2[id]){
count++;
id++;
j++;
}
if(count>prevcount){
idf=i;
prevcount=count;
count=0;
}
}
}
cout<<idf;
return 0;
}