ominiv


  • Home

  • Categories

  • About

  • Archives

  • Tags

  • Search

Python/Greedy BOJ-1541 잃어버린 괄호

Posted on 2021-12-28 | In CodingTest

[Python/Greedy] BOJ-1541 잃어버린 괄호

📌문제링크


’-‘를 기준으로 문자열을 나눈다.

’-‘ 이전의 값은 더하고 이후의 값은 빼주면된다.


1
2
3
4
5
6
7
8
9
arr = input().split('-')

result=0
for i in arr[0].split('+'):
    result+=int(i)
for i in arr[1:]:
    for j in i.split('+'):
        result-=int(j)    
print(result)
# Greedy
Python/Greedy BOJ-1931 회의실 배정
Python/Greedy BOJ-11047 동전0
  • Table of Contents
  • Overview
ominiv

ominiv

ominiv-Technology-Blog 🤸‍♀️

157 posts
12 categories
84 tags
RSS
  1. 1 [Python/Greedy] BOJ-1541 잃어버린 괄호
© 2022 ominiv
Powered by Jekyll
Theme - NexT.Muse