[이·코·테] Q27. 정렬된 배열에서 특정 수의 개수 구하기

이정진·2021년 8월 10일
0

이·코·테

목록 보기
16/20
post-thumbnail

소스 코드 :

from bisect import bisect_left, bisect_right


def counting(numbers, number):
    left = bisect_left(numbers, number)
    right = bisect_right(numbers, number)
    
    if right == left:
        return -1
    return right - left

n, x = map(int, input().split())

sequence = list(map(int, input().split()))

print(counting(sequence, x))

0개의 댓글

관련 채용 정보