목록Dynamic Programming (2)
취미가 좋다
https://leetcode.com/problems/house-robber/ House Robber - 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 Solution class Solution: def rob(self, nums): if len(nums) < 2: return nums[0] dp = [] dp.append(nums[0]) dp.append(max(nums[0], nums[1])) for i in range(2, len(nums)): dp.app..
https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ Best Time to Buy and Sell Stock - 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 You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing ..