๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿƒ algorithm/boj

BOJ 6550 - ๋ถ€๋ถ„ ๋ฌธ์ž์—ด

by HandHand 2021. 3. 18.

๋ฌธ์ œ

๋ฐฑ์ค€ ์˜จ๋ผ์ธ ์ €์ง€ - 6550๋ฒˆ

ํ’€์ด ๊ณผ์ •

๋‘ ๊ฐœ์˜ ๋ฌธ์ž์—ด์ด ์ฃผ์–ด์งˆ ๋•Œ ํ•œ ๋ฌธ์ž์—ด์ด ๋‹ค๋ฅธ ๋ฌธ์ž์—ด์— ํฌํ•จ๋˜๋Š”์ง€ ํŒ๋‹จํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค.

๋ฌธ์ž๊ฐ€ ์—ฐ์†์œผ๋กœ ๋‚˜ํƒ€๋‚˜์•ผํ•œ๋‹ค๋Š” ์กฐ๊ฑด์ด ์—†๊ธฐ ๋•Œ๋ฌธ์— ๊ฒ€์‚ฌํ•  ์กฐ๊ฑด์ด ๋˜๋Š” ๋ฌธ์ž์—ด์˜ ์ธ๋ฑ์Šค๋ฅผ ํ•˜๋‚˜์”ฉ ์ฆ๊ฐ€์‹œํ‚ค๋ฉด์„œ
๋‹ค๋ฅธ ๋ฌธ์ž์—ด์— ํ•ด๋‹น ์ธ๋ฑ์Šค์— ํ•ด๋‹นํ•˜๋Š” ๋ฌธ์ž๊ฐ€ ์กด์žฌํ•˜๋Š”์ง€ ํŒ๋‹จํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

์ฝ”๋“œ


import sys


def solution(s, t):
    si = 0

    for ti in range(len(t)):
        if t[ti] == s[si]:
            si += 1
            if si == len(s):
                return 'Yes'

    return 'No'


if __name__ == '__main__':
    while True:
        line = sys.stdin.readline().strip()
        if not line:
            break

        s, t = line.split()
        answer = solution(s, t)
        print(answer)

๋ฐ˜์‘ํ˜•

'๐Ÿƒ algorithm > boj' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

BOJ 1303 - ์ „์Ÿ - ์ „ํˆฌ  (0) 2021.03.18
BOJ 1260 - DFS์™€ BFS  (0) 2021.03.18
BOJ 10819 - ์ฐจ์ด๋ฅผ ์ตœ๋Œ€๋กœ  (0) 2021.03.18
BOJ 15240 - Paint bucket  (0) 2021.03.18
BOJ 1449 - ์ˆ˜๋ฆฌ๊ณต ํ•ญ์Šน  (0) 2021.03.18

๐Ÿ’ฌ ๋Œ“๊ธ€