codechef FEB14 LCPESY - Longest Common Pattern solution: http://www.codechef.com/viewsolution/3383472
- #include <iostream>
- #include <cstdio>
- #include <cstring>
- using namespace std;
- int main() {
- int t, cnt, a[100], b[100];
- char s1[10005], s2[10005];
- while(t--) {
- cnt=0;
- for(int i=0; i<100; i++) a[i]=b[i]=0;
- for(int i=0; i<strlen(s1); i++) a[s1[i]-48]++;
- for(int i=0; i<strlen(s2); i++) b[s2[i]-48]++;
- for(int i=0; i<100; i++) {
- if(a[i]<b[i]) cnt += a[i];
- else cnt += b[i];
- }
- }
- return 0;
- }
note: memset() gave TLE
No comments:
Post a Comment