DP알고리즘 6

[Python] 리트코드 1690. Stone Game VII

https://leetcode.com/problems/stone-game-vii/ Stone Game VII - 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 Alice와 Bob이 게임을 한다. 번갈아가며 첫 번째 혹은 마지막 돌무더기를 제거해서 남은 돌무더기 합계를 해당 턴의 점수로 가져간다. stones = [5,3,1,4,2]라면 Alice가 제일 오른쪽 2를 제거하고 5 + 3 + 1 + 4 = 13를 얻는다. 그다음 Bob은 stones = [5,3,1..

알고리즘 2021.10.18

[Python] 리트코드 216. Combination Sum III

https://leetcode.com/problems/combination-sum-iii/ Combination Sum III - 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 ==문제== 1~9까지의 숫자를 k개 사용해서 n이 되는 조합을 찾는 문제이다. 각 숫자는 한 번씩만 사용할 수 있고 모든 조합 경우의 수를 리턴하면 된다. 이 문제는 전에 풀었던 문제가 한단계 업그레이드 된 버전이다. ▼풀이 2021.07.12 - [알고리즘] - [Python] 리트코..

알고리즘 2021.09.02

[Python] 리트코드 1048. Longest String Chain (요소의 길이로 정렬)

https://leetcode.com/problems/longest-string-chain/ Longest String Chain - 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 ==문제== 소문자로 구성된 words 배열을 받는다. 알파벳이 하나씩 추가되어 'a' 'ab' 'dab' 같은 식으로 이어질 때 이것을 word chain이라고 부른다. words배열 안에서 가장 길게 연결할 수 있는 word chain 개수를 구하라. ==처음 코드== 각 단어의 ..

알고리즘 2021.07.19

[Python] 리트코드 1402 : Reducing Dishes (DP)

https://leetcode.com/problems/reducing-dishes/ Reducing Dishes - 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 ==문제== 셰프가 가지고 있는 접시 별로 손님들이 느끼는 만족도가 저장된 리스트 satisfaction이 있다. 이 접시들 중 어떤 걸 사용할지 정할 건데 접시가 배치된 순서에 따라 총만족도가 결정된다. 뒤에 위치한 접시일수록 높은 계수를 부여받아 높은 만족도를 달성할 수 있다. 예를 들어 만족도가 ..

알고리즘 2021.06.18

[Python] 리트코드 877 : Stone Game (DP)

https://leetcode.com/problems/stone-game/submissions/ Stone Game - 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 짝수개의 돌무더기가 있을 때 Alex와 Lee가 한 무더기씩 번갈아가면서 가져갈 것이다. 양쪽 끝에 있는 돌무더기만 가져갈 수 있을 때 Alex가 이길 수 있으면 True를 반환한다. piles의 첫 번째를 piles[i]라고 하고 끝을 piles[j]라고 할 때 piles[i, i+1, i+2, ..

알고리즘 2021.06.16

[Python] 리트코드 1025 : Divisor Game (DP)

https://leetcode.com/problems/divisor-game/ Divisor Game - 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 Alice와 Bob이 게임을 할 건데 Alice가 이길 수 있다면 True를 반환한다. --규칙-- n이 주어졌을 때 n의 약수인 x를 고른다. n-x를 한 숫자가 다음 턴의 새로운 n이 된다. 이 과정을 반복해서 더 이상 제시할 x가 없다면 패배 result 리스트를 만들어서 result[1]~result[n]..

알고리즘 2021.06.16