Last active
February 3, 2022 03:43
-
-
Save yuhangwang/eb9f2b0f567f1f14b311b303306172d0 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
| # see: https://www.deepmind.com/blog/article/Competitive-programming-with-AlphaCode | |
| # Why AlphaCode generated an unused variable `c` to store a string that has no use at all? | |
| t = int(input()) | |
| for i in range(t): | |
| s = input() | |
| t = input() | |
| a = [] | |
| b = [] | |
| for j in s: | |
| a.append(j) | |
| for j in t: | |
| b.append(j) | |
| a.reverse() | |
| b.reverse() | |
| c = [] | |
| while len(b) != 0 and len(a) != 0: | |
| if a[0] == b[0]: | |
| c.append(b.pop(0)) | |
| a.pop(0) | |
| elif a[0] != b[0] and len(a) != 1: | |
| a.pop(0) | |
| a.pop(0) | |
| elif a[0] != b[0] and len(a) == 1: | |
| a.pop(0) | |
| if len(b) == 0: | |
| print("YES") | |
| else: | |
| print("NO") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment