Home [1일 1문제] 3월 23일 문제풀이
Post
Cancel

[1일 1문제] 3월 23일 문제풀이

✏️백준 1439번 : 뒤집기

문제

나의 풀이

- Swift

1
2
3
4
5
6
let s = readLine()!

var temp1 = s.split(separator: "0").map{ String($0) }
var temp2 = s.split(separator: "1").map{ String($0) }

print(min(temp1.count, temp2.count))

- Python

1
2
3
4
5
6
7
8
s = input()

temp1 = s.split("0")
temp1 = list(filter(None, temp1))
temp2 = s.split("1")
temp2 = list(filter(None, temp2))

print(min(len(temp1), len(temp2)))
This post is licensed under CC BY 4.0 by the author.