摘要: 今天是第四十九天,用动态规划的思想去解决之前用贪心算法解决的股票买卖问题 121. 买卖股票的最佳时机 class Solution { public int maxProfit(int[] prices) { int n = prices.length; if(n == 1){ return 0; 阅读全文
posted @ 2022-11-30 16:15 小猫Soda 阅读(17) 评论(0) 推荐(0)
摘要: 今天是训练营的第四十八天,开始了动态规划的强盗问题 198. 打家劫舍 class Solution { public int rob(int[] nums) { int n = nums.length; if(n==1){ return nums[0]; } int[] dp = new int[ 阅读全文
posted @ 2022-11-30 03:49 小猫Soda 阅读(21) 评论(0) 推荐(0)