반응형
Recent Posts
Notice
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
Tags
- 코딩테스트준비
- 항해99
- 백준 2309
- easy 딥러닝
- 99클럽
- 혁펜하임
- 스택
- 구현
- python 2309
- 딥러닝
- 개발자 취업
- 파이썬
- 기능개발
- BFS
- 해시
- 활성화 함수
- leetcode
- 프로그래머스
- BOJ
- boj 2309
- 알고리즘
- 백준
- dfs
- 큐
- 99항해
- 코딩테스트 준비
- 개발자취업
- til
- Python
- softeer
Archives
- Today
- Total
동까의 코딩
99클럽 코테 스터디 4일차 TIL 본문
반응형
https://www.acmicpc.net/problem/1253
시간복잡도가 중요한 문제이기 때문에 투포인터로 문제를 풀이했다.
import sys
input = sys.stdin.readline
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
cnt = 0
for i in range(n):
end = arr[i]
start = 0
tail = len(arr) - 1
while start < tail:
if arr[start] + arr[tail] == end:
if start == i:
start += 1
elif tail == i:
tail -= 1
else:
cnt += 1
break
elif arr[start] + arr[tail] > end:
tail -= 1
elif arr[start] + arr[tail] < end:
start += 1
print(cnt)
반응형
'문제 풀이 > 99클럽' 카테고리의 다른 글
99클럽 코테스터디 TIL 6일차 (0) | 2025.01.23 |
---|---|
99클럽 코테 스터디 5일차 TIL (0) | 2025.01.20 |
99클럽 코테 스터디 3일차 TIL (0) | 2025.01.16 |
99클럽 코테 스터디 2일차 TIL (1) | 2025.01.14 |
99클럽 코테 스터디 1일차 TIL (0) | 2025.01.14 |