자료구조 & 알고리즘 관련/코딩테스트

https://leetcode.com/problems/design-browser-history/ Design Browser History - LeetCode Design Browser History - You have a browser of one tab where you start on the homepage and you can visit another url, get back in the history number of steps or move forward in the history number of steps. Implement the BrowserHistory class: * BrowserHisto leetcode.com 파이썬 코드 더보기 class ListNode(object): def _..
https://school.programmers.co.kr/learn/courses/30/lessons/42578# 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(clothes): answer = 1 clothes_dict = dict() for c in clothes: item = c[-1] for i in range(len(c) - 2, -1, -1): if item not in clothes_dict: clothes_dict[item] = set() clothes_dict[item].add(c[i]) for key in clo..
https://school.programmers.co.kr/learn/courses/30/lessons/1845 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(nums): answer = len(nums) / 2 poketmon = set() for num in nums: poketmon.add(num) if answer > len(poketmon): answer = len(poketmon) return answer
https://school.programmers.co.kr/learn/courses/30/lessons/17680 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(cacheSize, cities): cacheMemory = list() sec = 0 # 1. 캐시 안에 원소가 있는지 확인한다. for city in cities: if city.upper() in cacheMemory: sec += 1 cacheMemory.remove(city.upper()) cacheMemory.append(city.upper()) # 2. 원소가 ..
https://school.programmers.co.kr/learn/courses/30/lessons/12980 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(n): ans = 0 while n != 0: if n % 2 != 0: n -= 1 ans += 1 else: n /= 2 return ans 문제 풀이 목적지 위치를 2로 나누고 짝수면 순간이동할 수 있다는 것이니 나눠주고 홀수면 -1을 해줌으로써 짝수를 만들어 주고 이는 건전지를 하나 사용한다는 뜻! 다른 분의 풀이 : 깜짝 놀랐다. def solution(n): re..
https://school.programmers.co.kr/learn/courses/30/lessons/42885# 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr def solution(people, limit): answer = 0 people.sort() min = 0 for max in range(len(people) - 1, -1, -1): if min > max: break if people[max] + people[min] 남은 인원이 한명일 경우 min == max: break 한다면 남은 인원을 보트에 태우지 못하게 되는 셈이다. 헤맸던 점..
솜사탕코튼
'자료구조 & 알고리즘 관련/코딩테스트' 카테고리의 글 목록 (4 Page)