Created
June 13, 2016 20:03
-
-
Save isRuslan/89278e2fa61ee32466b4e2d7161fb484 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <math.h> | |
#include <stdlib.h> | |
#define MAX_SIZE 100000 | |
int check_string(char s1[], char s2[]); | |
int main() { | |
int n; | |
char *s1, *s2; | |
scanf("%d", &n); | |
s1=(char*)malloc(sizeof(char)*MAX_SIZE); | |
s2=(char*)malloc(sizeof(char)*MAX_SIZE); | |
char result[n]; | |
for(int i = 0; i <= n; i++){ | |
scanf("%s", s1); | |
scanf("%s", s2); | |
result[i] = check_string(s1, s2); | |
} | |
for(int i = 0; i < n; i++){ | |
printf("%s\n", result[i] == 0 ? "NO" : "YES"); | |
} | |
return 0; | |
} | |
int check_string(char s1[], char s2[]) | |
{ | |
int i, j; | |
int letters[MAX_SIZE] = {0}; | |
for(i = 0; s1[i] != '\0'; i++){ | |
letters[s1[i]] += 1; | |
} | |
for(j = 0; s2[j] != '\0'; j++){ | |
if(letters[s2[j]] > 0){ | |
return 1; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment