목록programmers (70)
컴공생의 다이어리

[프로그래머스] 올바른 괄호 - 파이썬(Python) from collections import deque def solution(s): stack = deque() for i in s: if i == ')' and not stack: # 스택에 아무것도 없는데 ')'가 있는 경우 return False elif i == ')' and stack[-1] == '(': # 괄호쌍 없애줌 stack.pop() else: # i가 '('일 때 stack.append(i) return True if not stack else False https://school.programmers.co.kr/learn/courses/30/lessons/12909 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭..

[프로그래머스] 같은 숫자는 싫어 - 파이썬(Python) def solution(arr): answer = [] for i in arr: if not answer or answer[-1] != i: answer.append(i) return answer https://school.programmers.co.kr/learn/courses/30/lessons/12906 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr

[프로그래머스] 양궁대회 - 파이썬(Python) from itertools import combinations_with_replacement def solution(n, info): answer = [-1] max_gap = -1 # 점수 차 for combi in combinations_with_replacement(range(11), n): # 중복 조합으로 0~10점까지 n개 뽑기 info2 = [0] * 11 # 라이언의 과녁 점수 for i in combi: # combi에 해당하는 화살들을 라이언 과녁 점수에 넣기 info2[10 - i] += 1 apeach, lion = 0, 0 for idx in range(11): if info[idx] == info2[idx] == 0: # 라이언과..

[프로그래머스] 교점에 별 만들기 - 파이썬(Python) from itertools import combinations def find_intersection_point(line1, line2): # 두 직선의 모든 좌표가 정수인 교점 구하기 a, b, e = line1 # ax + by + e = 0 c, d, f = line2 # cx + dy + f = 0 if a * d == b * c: # 기울기가 일치하거나 평행인 경우 return x = (b * f - e * d) / (a * d - b * c) y = (e * c - a * f) / (a * d - b * c) if x == int(x) and y == int(y): # 교점이 정수라면 return (int(x), int(y)) def ..

[프로그래머스] 우유와 요거트가 담긴 장바구니 - MySQL SELECT CART_ID FROM CART_PRODUCTS WHERE NAME IN('Yogurt','Milk') GROUP BY CART_ID HAVING COUNT(DISTINCT NAME)=2 ORDER BY CART_ID; https://school.programmers.co.kr/learn/courses/30/lessons/62284 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr

[프로그래머스] 보호소에서 중성화한 동물 - MySQL SELECT I.ANIMAL_ID, I.ANIMAL_TYPE, I.NAME FROM ANIMAL_INS I JOIN ANIMAL_OUTS O ON I.ANIMAL_ID = O.ANIMAL_ID WHERE I.SEX_UPON_INTAKE LIKE 'Intact%' AND O.SEX_UPON_OUTCOME REGEXP 'Spayed|Neutered' ORDER BY ANIMAL_ID; # OR SELECT I.ANIMAL_ID, I.ANIMAL_TYPE, I.NAME FROM ANIMAL_INS I JOIN ANIMAL_OUTS O ON I.ANIMAL_ID = O.ANIMAL_ID WHERE I.SEX_UPON_INTAKE LIKE 'Intact%' ..

[프로그래머스] 오랜 기간 보호한 동물(1) - MySQL SELECT I.NAME, I.DATETIME FROM ANIMAL_INS I LEFT JOIN ANIMAL_OUTS O ON I.ANIMAL_ID = O.ANIMAL_ID WHERE O.ANIMAL_ID IS NULL ORDER BY I.DATETIME LIMIT 3; https://school.programmers.co.kr/learn/courses/30/lessons/59044 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr

[프로그래머스] 있었는데요 없었습니다 - MySQL SELECT O.ANIMAL_ID, O.NAME FROM ANIMAL_OUTS O JOIN ANIMAL_INS I ON O.ANIMAL_ID = I.ANIMAL_ID WHERE O.DATETIME < I.DATETIME ORDER BY I.DATETIME; https://school.programmers.co.kr/learn/courses/30/lessons/59043 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr

[프로그래머스] 없어진 기록 찾기 - MySQL SELECT A.ANIMAL_ID, A.NAME FROM ANIMAL_OUTS A LEFT JOIN ANIMAL_INS B ON A.ANIMAL_ID = B.ANIMAL_ID WHERE B.ANIMAL_ID IS NULL ORDER BY A.ANIMAL_ID; https://school.programmers.co.kr/learn/courses/30/lessons/59042 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr

[프로그래머스] 짝지어 제거하기 - 파이썬(Python) from collections import deque def solution(s): temp = deque() for i in range(len(s)): if temp and temp[-1] == s[i]: temp.pop() else: temp.append(s[i]) return 0 if temp else 1 https://programmers.co.kr/learn/courses/30/lessons/12973 코딩테스트 연습 - 짝지어 제거하기 짝지어 제거하기는, 알파벳 소문자로 이루어진 문자열을 가지고 시작합니다. 먼저 문자열에서 같은 알파벳이 2개 붙어 있는 짝을 찾습니다. 그다음, 그 둘을 제거한 뒤, 앞뒤로 문자열을 이어 붙 program..