-
괄호 쌍 만들어주기 24학년/CodeTree 코딩캠프 2025. 3. 6. 12:37
https://www.codetree.ai/trails/complete/curated-cards/challenge-pair-parentheses-2/description
Code Tree | Learning to Code with Confidence
A super-comprehensive, meticulously arranged Coding Learning Curriculum engineered by Algorithm Experts composed of former International Olympiad in Informatics (IOI) medalists.
www.codetree.ai
a = list(input()) cnt = 0 #어차피 a는 100까지숫자라 탐색 두번한다해도 10000개인데 무식하게 돌려도 되지 않을까? for i in range(len(a)-1): if a[i] =="(" and a[i+1] =="(": for j in range(i+2,i+1+len(a[i+2:])): if a[j] ==")" and a[j+1]==")": cnt+=1 print(cnt)
이건뭐 ... 별다른 말 안붙여도 될 것 같습니다.
j for문의 범위가 저따구인 이뉴는 i 가 3 이라면 뒤쪽탐색을 3 + 2 부터하고 맨끝까지하고싶은데 인덱스로 하려니까 저렇게 나오더라구요....?
728x90'4학년 > CodeTree 코딩캠프' 카테고리의 다른 글
바구니 안의 사탕 2 (0) 2025.03.06 씨 오 더블유 2 (0) 2025.03.06 마라톤 중간에 택시타기 2 (0) 2025.03.06 [4일차] 완전탐색 (0) 2025.03.05 세 자리를 정하여 완전탐색 (0) 2025.03.05