Algorithm
-
[🥰프로그래머스] 신규 아이디 추천 (2021 KAKAO BLIND RECRUITMENT)Algorithm/1일 1코테 2022. 2. 4. 09:28
신규 아이디 추천 https://programmers.co.kr/learn/courses/30/lessons/72410 코딩테스트 연습 - 신규 아이디 추천 카카오에 입사한 신입 개발자 네오는 "카카오계정개발팀"에 배치되어, 카카오 서비스에 가입하는 유저들의 아이디를 생성하는 업무를 담당하게 되었습니다. "네오"에게 주어진 첫 업무는 새로 programmers.co.kr 내 풀이 import re def solution(new_id): new_id = new_id.lower() # 소문자 변경 new_id = re.sub(r'[^a-z0-9-_.]', '', new_id) # 특정 특문, 영어, 숫자외 제거 new_id_list = list(new_id) # 리스트로 변경 for i in range(le..
-
[🥰프로그래머스] 로또의 최고 순위와 최저 순위Algorithm/1일 1코테 2022. 2. 3. 17:36
로또의 최고순위와 최저순위 https://programmers.co.kr/learn/courses/30/lessons/77484 코딩테스트 연습 - 로또의 최고 순위와 최저 순위 로또 6/45(이하 '로또'로 표기)는 1부터 45까지의 숫자 중 6개를 찍어서 맞히는 대표적인 복권입니다. 아래는 로또의 순위를 정하는 방식입니다. 1 순위 당첨 내용 1 6개 번호가 모두 일치 2 5개 번호 programmers.co.kr 내 풀이 def solution(lottos, win_nums): _zero = lottos.count(0) # 0의 갯수 _coincide = 0 # 일치하는 숫자 갯수 rank = [0,6,5,4,3,2,1] # 로또 순위 -> 6개(index) 다 맞으면 1,,, # 일치하는 갯수 세..
-
[🥲 프로그래머스] 신고 결과 받기 (2022 KAKAO BLIND RECRUITMENT)Algorithm/1일 1코테 2022. 2. 3. 14:57
신고 결과 받기 https://programmers.co.kr/learn/courses/30/lessons/92334?language=python3 코딩테스트 연습 - 신고 결과 받기 문제 설명 신입사원 무지는 게시판 불량 이용자를 신고하고 처리 결과를 메일로 발송하는 시스템을 개발하려 합니다. 무지가 개발하려는 시스템은 다음과 같습니다. 각 유저는 한 번에 한 명의 programmers.co.kr 오랜만에 코테.... 몇개월 안풀었다고 다 까먹음 ㅎ^^ 1단계지만 광탈했다! 유저가 신고한 사람들 중 k번 이상 신고당한 사람들을 추출하면 되는 문제! # 다른 사람 풀이 # 다른 사람 코드 참고 def solution(id_list, report, k): answer = [0] * len(id_list) ..
-
[😍 프로그래머스] 튜플 (2019 카카오 개발자 겨울 인턴십)Algorithm/1일 1코테 2021. 8. 26. 23:43
https://programmers.co.kr/learn/courses/30/lessons/64065 코딩테스트 연습 - 튜플 "{{2},{2,1},{2,1,3},{2,1,3,4}}" [2, 1, 3, 4] "{{1,2,3},{2,1},{1,2,4,3},{2}}" [2, 1, 3, 4] "{{4,2,3},{3},{2,3,4,1},{2,3}}" [3, 2, 4, 1] programmers.co.kr 🏐 나의 풀이 🏐 from collections import Counter def solution(s): s= s.replace('{','') # 괄호 제거 s= s.replace('}','') s = list(map(int, s.split(','))) # ,으로 숫자 구분 number_dict = Counte..
-
[😍 프로그래머스] 단속카메라 - greedyAlgorithm/1일 1코테 2021. 8. 22. 12:56
https://programmers.co.kr/learn/courses/30/lessons/42884 코딩테스트 연습 - 단속카메라 [[-20,15], [-14,-5], [-18,-13], [-5,-3]] 2 programmers.co.kr 🍪 나의 풀이 def solution(routes): routes.sort(key=lambda x:x[0], reverse=True) # 시작점이 가장 큰 숫자부터 정렬 # [[-5, -3], [-14, -5], [-18, -13], [-20, 15]] count = 0 # 결과 camera = float('inf') # 카메라 위치는 임의로 가장 큰 숫자로 지정 for i in range(len(routes)): if routes[i][0]
-
[leetcode] 78. subsets (python)Algorithm/1일 1코테 2021. 8. 19. 13:51
리트코드 78번 문제 https://leetcode.com/problems/subsets/submissions/ Subsets - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 내가 푼 풀이 class Solution: def subsets(self, nums: List[int]) -> List[List[int]]: answer = [[]] # 빈 값을 미리 넣어줌 for i in range(1, len(nums)+1): number_group = list(it..
-
[leetcode] 그리디 알고리즘 모음집.zipAlgorithm/1일 1코테 2021. 8. 14. 21:51
그리기 알고리즘의 핵심은 그때그때 가장 적합한 선택을 하는 것! 122번. 주식 팔고사기 가장 적합한 선택 -> 바로 다음 값이 오르면 팔고, 아니면 만다! class Solution: def maxProfit(self, prices: List[int]) -> int: result = 0 # 결과 저장 for i in range(len(prices)-1): if prices[i+1]>prices[i]: # 다음 값이 크면 판다! result += prices[i+1]-prices[i] return result 406번. 키에 따라 재정렬 가장 적합한 선택 -> 키(역순)/인덱스 순으로 정렬한 뒤 인덱스대로 삽입 class Solution: def reconstructQueue(self, people: L..
-
[백준] 4796번 캠핑 - 그리디 알고리즘Algorithm/1일 1코테 2021. 8. 11. 18:37
https://www.acmicpc.net/status?user_id=kimdi96&problem_id=4796&from_mine=1 채점 현황 www.acmicpc.net 처음 단순하게 생각한 답....! 그런데 찾아보니 예외가 있더라 for i in range(1,999): L,P,V = map(int, input().split()) if L == 0 and P == 0 and V == 0: break answer= (V//P)*L + (V%P) print("Case", i, ":", answer) 예외처리를 해줬다! for i in range(1,999): L,P,V = map(int, input().split()) if L == 0 and P == 0 and V == 0: break answer=..