K

@kimjuha19

올바른 팰린드롬 문자열

Python
3 days ago
s = "abccba" left = 0 right = len(s) - 1 result = True while left < right: if s[left] != s[right]: result = False break else:

연구소 시약 배합 조합

Python
6 days ago
def solution(concentrations, target): answer = 0 def dfs(start, cnt, total): nonlocal answer if cnt == 4: if total == target: answer += 1 return

미로 탈출 최단 경로

Python
6 days ago
from collections import deque def solution(grid): dx = [-1, 1, 0, 0] dy = [0, 0, -1, 1] visited = [[False] * 5 for _ in range(5)] dist = [[0] * 5 for _ in range(5)] queue = deque()

학급 명부에서 이름 찾기

Python
6 days ago
names = ["alice", "bob", "charlie", "david", "ellen"] target = "david" left = 0 right = len(names) - 1 answer = -1 while left <= right: mid = (left + right) // 2

연속된 며칠간의 매출 최대화

Python
6 days ago
sales = [10, 20, 30, 10, 40, 20] k = 3 answer = 0 idx = 0 for i in range(len(sales)-k): if sales[i] + sales[i+1] + sales[i+2] > answer: answer = sales[i] + sales[i+1] + sales[i+2] idx = i

도서 대출 빈도 다중 조건 정렬

Python
6 days ago
books = [[2001, 50, 5], [2002, 50, 3], [2003, 40, 2]] books.sort(key=lambda x: (-x[1], x[2], x[0])) answer = [] for i in range(len(books)): answer.append(books[i][0]) print(answer)

학생회 투표 집계

Python
6 days ago
votes = ["james", "mary", "james", "mary", "john"] vote_count = {} for name in votes: if name in vote_count: vote_count[name] += 1 else: vote_count[name] = 1

최고 가성비 간식 구매

Python
6 days ago
budget = 3000 satisfactions = [5, 12, 8, 3, 10] count = budget // 1000 answer = 0 satisfactions.sort(reverse = True) for i in satisfactions: if count <= 0: break else:

괄호 짝 맞추기

Python
6 days ago
s = "(()())" stack = [] for ch in s: if ch == '(': stack.append(ch) else: if not stack: print("False")

지그재그 격자판 채우기

Python
1 week ago
n = 3 arr = [ [0,0,0], [0,0,0], [0,0,0] ] num = 1

예산 분배 최적화

Python
1 week ago
requests = [120, 110, 140, 150] total_budget = 485 count = len(requests) average = total_budget / count answer = 0 for i in requests: if i <= average: total_budget -= i count -= 1

도서관 대여 도서 찾기

Python
1 week ago
book_ids = [105, 210, 305, 412, 550, 720] find = 412 left = 0 right = len(book_ids) - 1 answer = -1 while left <= right: mid = (left+right) // 2

입사 시험 다중 조건 정렬

Python
1 week ago
applicants = [ [1001, 80, 90], [1002, 90, 80], [1003, 85, 85] ] applicants.sort( key=lambda x: (-(x[1] + x[2]), -x[2], x[0]) )

사내 메신저 알림 수신

Python
1 week ago
logs = [ ["ryan", "OFF"], ["neo", "OFF"], ["ryan", "ON"], ["muzi", "OFF"] ] answer = [] for i in range(len(logs)):

배송 트럭 적재 제한

Python
1 week ago
max_weight = 10 weights = [2, 8, 4, 3, 5] weights.sort() total = 0 count = 0 for w in weights: if total + w <= max_weight:

연속된 문자열 제거

Python
1 week ago
s = "baabaa" stack = [] for i in range(len(s)): if stack and stack[-1] == s[i]: stack.pop() else: stack.append(s[i])

원형 큐의 데이터 순환 확인

C
1 week ago
#include <stdio.h> int front = 0; int rear = 0; void enqueue() { rear = (rear + 1) % 5; } void dequeue() {

큐의 맨 앞과 맨 뒤 확인

C
1 week ago
#include <stdio.h> int front = 0; int rear = 0; int que[100] = {}; void enqueue(int x) { que[rear++] = x; }

카드 섞기

C
1 week ago
#include <stdio.h> int front = 0; int rear = 0; int que[100]; void enque(int x){ que[rear++] = x; }

마트 계산대 시뮬레이션

C
1 week ago
#include <stdio.h> int front = 0; int rear = 0; int que[100]; void enque(int x){ que[rear++] = x; }