카멜케이스 매칭
queries과 문자열 pattern이 주어지면 answer가 answer[i]와 일치하면 true가 queries[i]이고 그렇지 않으면 pattern인 부울 배열 false을 반환합니다.질의어
queries[i]는 질의어와 같도록 영문 소문자 패턴을 삽입할 수 있으면 일치pattern합니다. 임의의 위치에 각 문자를 삽입할 수 있으며 아무 문자도 삽입할 수 없습니다.예 1:
입력: 쿼리 = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], 패턴 = "FB"
출력: [참,거짓,참,참,거짓]
설명: "FooBar"는 "F"+ "oo"+ "B"+ "ar"와 같이 생성될 수 있습니다.
"FootBall"은 "F"+ "oot"+ "B"+ "all"과 같이 생성될 수 있습니다.
"FrameBuffer"는 "F"+ "rame"+ "B"+ "uffer"와 같이 생성될 수 있습니다.
예 2:
입력: 쿼리 = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], 패턴 = "FoBa"
출력: [참,거짓,참,거짓,거짓]
설명: "FooBar"는 "Fo"+ "o"+ "Ba"+ "r"과 같이 생성될 수 있습니다.
"FootBall"은 "Fo"+ "ot"+ "Ba"+ "ll"과 같이 생성될 수 있습니다.
예 3:
입력: 쿼리 = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], 패턴 = "FoBaT"
출력: [거짓,참,거짓,거짓,거짓]
설명: "FooBarTest"는 "Fo"+ "o"+ "Ba"+ "r"+ "T"+ "est"와 같이 생성될 수 있습니다.
제약:
1 <= pattern.length, queries.length <= 100 1 <= queries[i].length <= 100 queries[i] 및 pattern는 영문자로 구성됩니다. 해결책:
class Solution:
    def camelMatch(self, queries: List[str], pattern: str) -> List[bool]:
        n = len(pattern)
        pattCaps = "".join([c for c in pattern if c.isupper()])
        answer = []
        for q in queries:
            m = len(q)
            qCaps = "".join([c for c in q if c.isupper()])
            if pattCaps != qCaps:
                answer.append(False)
                continue
            i = 0
            j = 0
            while i < n and j < m:
                if pattern[i] == q[j]:
                    i += 1
                    j += 1
                else:
                    j += 1
            answer.append(i == n)
        return answer
Reference
이 문제에 관하여(카멜케이스 매칭), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/theabbie/camelcase-matching-4bo8텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)