Skip to content

Commit

Permalink
[Feat] 쇠막대기
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwon12 committed Jul 8, 2022
1 parent 01f1ae8 commit a270461
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/7week/jaewon/쇠 막대기.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package `7week`.jaewon

fun main(){
val list = readln()
var stick = 0
var answer = 0
var i = 0
while (i < list.length){
when(list[i]){
'(' -> {
if(list[i+1] == ')'){
answer += stick
i++
}else stick++
}else -> {
answer++
stick--
}
}
i++
}
println(answer)
}

0 comments on commit a270461

Please sign in to comment.