[HackerRank][Python3] Abbreviation
2018. 7. 18. 23:18 |
프로그래밍/HackerRank
Problem :
https://www.hackerrank.com/challenges/abbr/problem
My Solution :
#!/usr/bin/env python3
def abbreviation(a, b):
dp = [[0]*(len(b)+1) for _ in range(len(a)+1)]
dp[0][0] = 1
for i in range(len(a)):
for j in range(len(b)+1):
if dp[i][j]:
if j < len(b) and a[i].upper() == b[j]:
dp[i+1][j+1] = 1
if a[i].islower():
dp[i+1][j] = 1
return dp[-1][-1]
q = int(input())
for _ in range(q):
a = input()
b = input()
print('YES') if abbreviation(a, b) else print('NO')
'프로그래밍 > HackerRank' 카테고리의 다른 글
| [HackerRank][Python3] Tree: Huffman Decoding (0) | 2018.07.20 |
|---|---|
| [HackerRank][Python3] Binary Search Tree : Lowest Common Ancestor (0) | 2018.07.20 |
| [HackerRank][Python3] Balanced Brackets (0) | 2018.07.20 |
| [HackerRank][Python3] Queues: A Tale of Two Stacks (0) | 2018.07.19 |
| [HackerRank][Python3] Max Array Sum (0) | 2018.07.18 |
| [HackerRank][Python3] Making Candies (0) | 2018.07.18 |
| [HackerRank][Python3] Minimum Time Required (0) | 2018.07.17 |
| [HackerRank][Python3] Pairs (0) | 2018.07.17 |
최근에 달린 댓글 최근에 달린 댓글