CHIqueen
from collections import Counter def commonCharacterCount(s1, s2): common_letters = Counter(s1) & Counter(s2) return sum(common_letters.values()) 딱히 Counter말고 떠오르는게 없어서 Counter를 썼다. def commonCharacterCount(s1, s2): com = [min(s1.count(i),s2.count(i)) for i in set(s1)] return sum(com) 다른 풀이를 보면 set으로 중복을 없앤 다음 파이썬 str 메서드중 count를 이용해 갯수를세 가장 최소를 구했다.
def allLongestStrings(inputArray): maxd = 0 for i in inputArray: maxd = max(maxd,len(i)) return [i for i in inputArray if len(i) == maxd] 나머지 풀이들을 봤는데 max함수에 key를 len으로만 줘서 반복문 돌릴필요가 없었던것이 신기했다. def allLongestStrings(inputArray): return [i for i in inputArray if len(i) == len(max(inputArray, key=len))]
After becoming famous, the CodeBots decided to move into a new building together. Each of the rooms has a different cost, and some of them are free, but there's a rumour that all the free rooms are haunted! Since the CodeBots are quite superstitious, they refuse to stay in any of the free rooms, or any of the rooms below any of the free rooms. Given matrix, a rectangular matrix of integers, wher..