코딩 테스트
-
[PCCE 기출문제] 10번 / 데이터 분석코딩 테스트/Level 1 2024. 4. 8. 22:42
https://school.programmers.co.kr/learn/courses/30/lessons/250121 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(data, ext, val_ext, sort_by): cols = {"code": 0, "date": 1, "maximum": 2, "remain": 3} return sorted(filter(lambda x: x[cols[ext]] < val_ext, data), key=lambda x: x[cols[sort_by]]) print(solution( [[1, 2030010..
-
[PCCE 기출문제] 9번 / 이웃한 칸코딩 테스트/Level 1 2024. 4. 3. 14:09
https://school.programmers.co.kr/learn/courses/30/lessons/250125 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(board, h, w): answer = 0 for dh, dw in ((0, 1), (1, 0), (-1, 0), (0, -1)): if 0
-
[PCCP 기출문제] 1번 / 붕대 감기코딩 테스트/Level 1 2024. 4. 3. 11:14
https://school.programmers.co.kr/learn/courses/30/lessons/250137 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(bandage, health, attacks): max_health = health success = 0 attacks_dict = {time: attack for time, attack in attacks} for time in range(1, max(attacks_dict) + 1): if time in attacks_dict: health -= attacks_dict..
-
2024 KAKAO WINTER INTERNSHIP 가장 많이 받은 선물코딩 테스트/Level 1 2024. 4. 3. 09:49
https://school.programmers.co.kr/learn/courses/30/lessons/258712 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 자료 구조까지 예시로 제공되어 풀기 쉽도록 만든 문제.. 매번 friends에서 원소의 위치를 찾는 것은 비효율적이다. 딕셔너리(맵, 해시)를 이용해 O(1)로 위치를 찾도록 하자. def solution(friends, gifts): friend_index = {friend: index for index, friend in enumerate(friends)} gift_table = [[0 fo..
-
프로그래머스 / 두 원 사이의 정수코딩 테스트/Level 2 2023. 4. 15. 15:54
https://school.programmers.co.kr/learn/courses/30/lessons/181187 파이썬 def solution(r1, r2): answer = 0 pow_r1, pow_r2 = r1 ** 2, r2 ** 2 for y in range(1, r2 + 1): temp1 = pow_r1 - y ** 2 if temp1 >= 0: temp2 = temp1 ** 0.5 x1 = int(temp2) - (1 if temp2 == int(temp2) else 0) else: x1 = -1 answer += int((pow_r2 - y ** 2) ** 0.5) - x1 return answer * 4
-
프로그래머스 / 연속된 부분 수열의 합코딩 테스트/Level 2 2023. 4. 11. 23:29
https://school.programmers.co.kr/learn/courses/30/lessons/178870 파이썬 이렇게 쉽게는 넘어가지 않겠지.. def solution(sequence, k): answer = [] for i in range(len(sequence)): for j in range(i + 1, len(sequence) + 1): s = sum(sequence[i:j]) if s == k: answer.append([i, j - 1]) elif s > k: break return sorted(answer, key=lambda x: x[1] - x[0])[0] 소티드를 이용해서 간결하게.. def solution(sequence, k): answer = [] left = right..
-
프로그래머스 / 달리기 경주코딩 테스트/Level 1 2023. 4. 10. 18:21
https://school.programmers.co.kr/learn/courses/30/lessons/178871 파이썬 def solution(players, callings): players_map = {each: index for index, each in enumerate(players)} for player in callings: index = players_map[player] players_map[player] -= 1 players_map[players[index - 1]] += 1 players[index - 1], players[index] = players[index], players[index - 1] return players 계속 find 명령을 쓰면 시간이 너무 오래 걸린다...