leetcode2560专题

LeetCode2560. House Robber IV——二分答案+动态规划

文章目录 一、题目二、题解 一、题目 There are several consecutive houses along a street, each of which has some money inside. There is also a robber, who wants to steal money from the homes, but he refuses t

Leetcode2560. 打家劫舍 IV

Every day a Leetcode 题目来源:2560. 打家劫舍 IV 解法1:二分答案 + 动态规划 给定数组 nums,从中选择一个长度至少为 k 的子序列 A,要求 A 中没有任何元素在 nums 中是相邻的。 最小化 max⁡(A)。 看到「最大化最小值」或者「最小化最大值」就要想到二分答案,这是一个固定的套路。 对于本题,「偷走的最大金额」越小,能偷的房子就越少,反