摘要: class Solution { public int jump(int[] nums) { if (nums.length <= 1) return 0; //记录每次起跳所能跳到的最远的距离 int farestIndex = 0; int maxIndex = 0; int start = 0 阅读全文
posted @ 2024-02-05 17:45 破忒头头 阅读(19) 评论(0) 推荐(0)
摘要: 用一个变量存放当前所能到达的最远的下标位置 class Solution { public boolean canJump(int[] nums) { int farestIndex = 0;// 记录当前最远能到达的下标 for (int i = 0; i <= farestIndex && i 阅读全文
posted @ 2024-02-05 16:08 破忒头头 阅读(10) 评论(0) 推荐(0)
摘要: 动态规划,五种状态,关键是找出状态转移式 class Solution { public int maxProfit(int[] prices) { int buy1 = -prices[0]; int sell1 = 0; int buy2 = -prices[0]; int sell2 = 0; 阅读全文
posted @ 2024-02-05 15:33 破忒头头 阅读(10) 评论(0) 推荐(0)