일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- 리터럴 타입
- CORS
- React
- 호이스팅
- autosize
- Cypress
- async/await
- 태그된 유니온
- 결정 알고리즘
- recoil
- TS
- 반공변성
- 투포인터
- map
- webpack
- tailwind
- 인터섹션
- dfs
- app router
- 무한 스크롤
- 공변성
- RTK Query
- ESlint
- useAppDispatch
- 타입 좁히기
- Jest
- CI/CD
- SSR
- 이분 검색
- Promise
- Today
- Total
목록전체 글 (510)
짧은코딩
https://www.acmicpc.net/problem/10816 10816번: 숫자 카드 2 첫째 줄에 상근이가 가지고 있는 숫자 카드의 개수 N(1 ≤ N ≤ 500,000)이 주어진다. 둘째 줄에는 숫자 카드에 적혀있는 정수가 주어진다. 숫자 카드에 적혀있는 수는 -10,000,000보다 크거나 같고, 10, www.acmicpc.net 내 풀이(맞음) n = int(input()) a = list(map(int, input().split())) dic = {} for i in range(n): if a[i] in dic: dic[a[i]] += 1 else: dic[a[i]] = 1 m = int(input()) b = list(map(int, input().split())) rst = [] f..
https://www.acmicpc.net/problem/1158 1158번: 요세푸스 문제 첫째 줄에 N과 K가 빈 칸을 사이에 두고 순서대로 주어진다. (1 ≤ K ≤ N ≤ 5,000) www.acmicpc.net 내 풀이(맞음) n, k = map(int, input().split()) ary = [] rst = [] for i in range(n): ary.append(i+1) t = k -1 while(True): if(len(rst) == n): break if t < len(ary): True else: t %= len(ary) a = ary[t] del ary[t] rst.append(a) t += k-1 print("
https://www.acmicpc.net/problem/11279 11279번: 최대 힙 첫째 줄에 연산의 개수 N(1 ≤ N ≤ 100,000)이 주어진다. 다음 N개의 줄에는 연산에 대한 정보를 나타내는 정수 x가 주어진다. 만약 x가 자연수라면 배열에 x라는 값을 넣는(추가하는) 연산이고, x가 www.acmicpc.net 내 풀이(최대 힙 응용 인터넷에서 참고했음) import heapq n = int(input()) ary = [] heap = [] rst = [] for i in range(n): x = int(input()) ary.append(x) for i in range(n): if ary[i] == 0: if heap: a = heapq.heappop(heap)[1] rst.appe..
https://www.acmicpc.net/problem/4949 4949번: 균형잡힌 세상 하나 또는 여러줄에 걸쳐서 문자열이 주어진다. 각 문자열은 영문 알파벳, 공백, 소괄호("( )") 대괄호("[ ]")등으로 이루어져 있으며, 길이는 100글자보다 작거나 같다. 입력의 종료조건으로 맨 마 www.acmicpc.net 내 풀이(맞음) x = 1 lst = [] while(True): x = input() if x == '.': break lst.append(x) rst = [] for i in range(len(lst)): ary = [] for j in range(len(lst[i])): if lst[i][j] == '(' or lst[i][j] == '[': ary.append(lst[i][j..
https://www.acmicpc.net/problem/1927 1927번: 최소 힙 첫째 줄에 연산의 개수 N(1 ≤ N ≤ 100,000)이 주어진다. 다음 N개의 줄에는 연산에 대한 정보를 나타내는 정수 x가 주어진다. 만약 x가 자연수라면 배열에 x라는 값을 넣는(추가하는) 연산이고, x가 0 www.acmicpc.net 내 풀이(맞음) import heapq n = int(input()) que = [] rst = [] for i in range(n): x = int(input()) if x == 0: if que: rst.append(heapq.heappop(que)) else: rst.append(0) else: heapq.heappush(que, x) for i in rst: print(..
https://www.acmicpc.net/problem/2164 2164번: 카드2 N장의 카드가 있다. 각각의 카드는 차례로 1부터 N까지의 번호가 붙어 있으며, 1번 카드가 제일 위에, N번 카드가 제일 아래인 상태로 순서대로 카드가 놓여 있다. 이제 다음과 같은 동작을 카드가 www.acmicpc.net 내 풀이(맞음) from collections import deque n = int(input()) ary = deque() for i in range(1, n+1): ary.appendleft(i) while(len(ary) != 1): ary.pop() if(len(ary) > 1): t = ary.pop() ary.appendleft(t) print(ary[0]) ary를 덱으로 만듭니다. ..
https://www.acmicpc.net/problem/10773 10773번: 제로 첫 번째 줄에 정수 K가 주어진다. (1 ≤ K ≤ 100,000) 이후 K개의 줄에 정수가 1개씩 주어진다. 정수는 0에서 1,000,000 사이의 값을 가지며, 정수가 "0" 일 경우에는 가장 최근에 쓴 수를 지우고, 아닐 경 www.acmicpc.net 내 풀이(맞음) n = int(input()) ary = [] for i in range(n): x = int(input()) if x == 0: ary.pop() else: ary.append(x) print(sum(ary)) ary가 0이면 오른쪽걸 삭제하고 0이 아니면 오른쪽에 삽입한다. 그리고 ary의 합을 출력한다.
https://www.acmicpc.net/problem/1920 1920번: 수 찾기 첫째 줄에 자연수 N(1 ≤ N ≤ 100,000)이 주어진다. 다음 줄에는 N개의 정수 A[1], A[2], …, A[N]이 주어진다. 다음 줄에는 M(1 ≤ M ≤ 100,000)이 주어진다. 다음 줄에는 M개의 수들이 주어지는데, 이 수들 www.acmicpc.net 내 풀이(맞음) n = int(input()) ary = list(map(int, input().split())) m = int(input()) s = list(map(int, input().split())) for i in range(m): if s[i] in ary: print(1) else: print(0) m만큼 반복하면서 ary안에 s의 값..
https://www.acmicpc.net/problem/9012 9012번: 괄호 괄호 문자열(Parenthesis String, PS)은 두 개의 괄호 기호인 ‘(’ 와 ‘)’ 만으로 구성되어 있는 문자열이다. 그 중에서 괄호의 모양이 바르게 구성된 문자열을 올바른 괄호 문자열(Valid PS, VPS)이라고 www.acmicpc.net 내 풀이(맞음) n = int(input()) rst = [] for i in range(n): ary = [] x = input() for j in range(len(x)): if x[j] == "(": ary.append('(') if j == len(x) - 1: rst.append("NO") else: if ary: ary.pop() if j == len(x)..
https://www.acmicpc.net/problem/10866 10866번: 덱 첫째 줄에 주어지는 명령의 수 N (1 ≤ N ≤ 10,000)이 주어진다. 둘째 줄부터 N개의 줄에는 명령이 하나씩 주어진다. 주어지는 정수는 1보다 크거나 같고, 100,000보다 작거나 같다. 문제에 나와있지 www.acmicpc.net 내 풀이(맞음) from collections import deque class Deque: def __init__(self, ary = deque()): self.ary = ary def push_front(self, ary, item): ary.append(item) def push_back(self, ary, item): ary.appendleft(item) def pop_f..