-
프로그래머스 / 카드 뭉치코딩 테스트/Level 1 2023. 2. 18. 10:14반응형
https://school.programmers.co.kr/learn/courses/30/lessons/159994
코틀린
class Solution { fun solution(cards1: Array<String>, cards2: Array<String>, goal: Array<String>): String { var index1 = 0 var index2 = 0 for (each in goal) when { index1 < cards1.size && each == cards1[index1] -> index1++ index2 < cards2.size && each == cards2[index2] -> index2++ else -> return "No" } return "Yes" } }
파이썬
def solution(cards1, cards2, goal): index1 = index2 = 0 for each in goal: if index1 < len(cards1) and cards1[index1] == each: index1 += 1 elif index2 < len(cards2) and cards2[index2] == each: index2 += 1 else: return 'No' return 'Yes'
반응형