practivceAlgorithm/swexpertacademy

[SWEA][Python] 4865 글자수

findTheValue 2021. 8. 15. 18:39

그냥 counting

import sys
input = sys.stdin.readline
from collections import defaultdict

def count_chrs(s1, s2):
    char_set = defaultdict(int)
    for chr in s2:
        char_set[chr] += 1
    max_cnt = 0
    for char in s1:
        max_cnt = max(max_cnt,char_set[char])
    return max_cnt

    
for test in range(1,int(input())+1):
    str1 = input().rstrip()
    str2 = input().rstrip()
    print(f'#{test} {count_chrs(str1, str2)}')