class Solution {
fun solution(absolutes: IntArray, signs: BooleanArray): Int {
for ((index,sign) in signs.withIndex()){
if(sign) absolutes[index] = absolutes[index]
else absolutes[index] = - absolutes[index]
}
var answer: Int = absolutes.sum()
return answer
}
}
좋아
class Solution {
fun solution(a: Int, b: Int): Long {
var answer: Long = 0
if (a <= b) for (i in a..b) answer += i
else for (i in b..a) answer += i
return answer
}
}
[Kotlin] 실패율 (0) | 2021.04.18 |
---|---|
[Python] 크레인 인형뽑기 (0) | 2021.04.13 |
[Kotlin] 정규식 (0) | 2021.04.10 |
[Kotlin] 시퀀스를 이용한 피보나치 수열 (0) | 2021.04.09 |
[Kotlin] forEach / for EachIndexed (0) | 2021.04.08 |
댓글 영역