본문 바로가기

카테고리 없음

코딜리티 lesson15 (Caterpillar method), AbsDistinct, CountDistinctSlices

AbsDistinct

Compute number of distinct absolute values of sorted array elements.

 

[최초풀이]

# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")

def solution(A):
    res = set()
    for a in A:
        res.add(abs(a))

    return len(res)

CountDistinctSlices

Count the number of distinct slices (containing only unique numbers).