나는 이렇게 학습한다/Algorithm & SQL

0207. Divide and Conquer

daco2020 2023. 2. 8. 00:31
반응형

Given a mixed array of number and string representations of integers, add up the non-string integers and subtract this from the total of the string integers.

Return as a number.



Solution:

def div_con(arr):
    x = sum(i for i in arr if isinstance(i, int))
    y = sum(int(i) for i in arr if isinstance(i, str))
    return x - y


반응형

'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글

0209. Sort the Gift Code  (0) 2023.02.09
0209. Sort Out The Men From Boys  (0) 2023.02.09
0206. Find the nth Digit of a Number  (0) 2023.02.07
0205. pick a set of first elements  (0) 2023.02.05
0204. Filter the number  (0) 2023.02.04