Algorithm/1일 1코테
-
[🥰프로그래머스] 압축 (2018 KAKAO BLIND RECRUITMENT)Algorithm/1일 1코테 2022. 10. 8. 17:38
나의 풀이 def solution(msg): # 알파벳 사전을 만들기 위한 스트링 alphabet_string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' # 알파벳 사전 만들기... enumerate는 0부터 시작해서 1씩 더해줌 _dict = {} for i, a in enumerate(alphabet_string): _dict[a] = i+1 answer = [] l = 0 r = l+1 # msg[l:r]이 이미 사전에 있으면 하나 더 해줌 (K->KA) # 없으면 (KA) 사전에 넣어주고 이전 글자 (K)를 answer에 더해줌 # 다만 이미 사전에 있어도 마지막인 경우 (KAKAO 중 O) answer에 더해주지 않아서 따로 처리해줌 while r
-
[🥰프로그래머스] 신고 결과 받기 [2022 KAKAO BLIND RECRUITMENT]Algorithm/1일 1코테 2022. 10. 6. 16:56
나의 풀이 from collections import defaultdict def solution(id_list, report, k): count_dict = defaultdict(int) people_dict = defaultdict(list) for p in report: g, r = p.split(' ') if r not in people_dict[g]: count_dict[r] += 1 people_dict[g].append(r) count_list = [p for p in count_dict.keys() if count_dict[p] >= k] answer = [] for i in id_list: count = 0 for t in people_dict[i]: if t in count_list: ..
-
[😭 leetcode] 15. 3SumAlgorithm/1일 1코테 2022. 7. 25. 20:48
리트코드 13번째 문제 [3Sum] https://leetcode.com/problems/3sum/ 3Sum - 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 문제 배열을 입력받아 합으로 0을 만들 수 있는 3개의 엘리먼트를 출력하라 (중복X) 정답 class Solution: def threeSum(self, nums: List[int]) -> List[List[int]]: result = [] # 편의상 정렬 수행 nums.sort() # i를 기준으로 투 ..
-
[🥰프로그래머스] 폰켓몬 (찾아라 프로그래밍 마에스터)Algorithm/1일 1코테 2022. 2. 7. 12:36
https://programmers.co.kr/learn/courses/30/lessons/1845 코딩테스트 연습 - 폰켓몬 당신은 폰켓몬을 잡기 위한 오랜 여행 끝에, 홍 박사님의 연구실에 도착했습니다. 홍 박사님은 당신에게 자신의 연구실에 있는 총 N 마리의 폰켓몬 중에서 N/2마리를 가져가도 좋다고 했습니다. programmers.co.kr 내 풀이 def solution(nums): n_set = set(nums) if len(n_set) < len(nums)/2: return len(n_set) return len(nums)/2 다른 사람 풀이 def solution(ls): return min(len(ls)/2, len(set(ls)))
-
[🥰프로그래머스] 신규 아이디 추천 (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..