목차
개요

풀이
1차원 배열에서 순회하는 문제.
일일히 반복문을 돌아서 찾아도 된다.
Counter나 count를 사용하는 방법도 있다!
코드
Counter 사용
import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
lst = list(map(int, input().split()))
v = int(input())
counter_lst = Counter(lst)
print(counter_lst[v])
count 사용
import sys
input = sys.stdin.readline
N = int(input())
lst = list(map(int, input().split()))
v = int(input())
print(lst.count(v))
'알고리즘 > 백준 풀이' 카테고리의 다른 글
[백준] 2738번: 행렬 덧셈 (파이썬/Python) (0) | 2023.02.20 |
---|---|
[백준] 5597번: 과제 안 내신 분..? (파이썬/Python) (0) | 2023.02.19 |
25710번: 점수 계산(파이썬, 풀이, 정답 코드) (0) | 2022.10.19 |
1966번: 프린터 큐(파이썬, 풀이, 정답코드) (0) | 2022.10.06 |
1956번: 운동 (파이썬, 풀이, 정답 코드) (0) | 2022.10.04 |