摘要:
public int searchInsert(int[] nums, int target) { int n = nums.length; int left = 0, right = n-1, ans = n; while(left <= right) { // [left, right] int 阅读全文
摘要:
解题思路 Java代码如下: class Solution { int inf = 0x3f3f3f3f; public int maxProfit(int[] prices) { /* * dp[i][j][k]:i表示天数,j表示当前是否持股(j=0、1),k表示卖出的次数(k=0、1、2) * 阅读全文
摘要:
背包问题主要由三类: 01背包 完全背包 多重背包 1、01背包(使用滚动数组优化) import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(S 阅读全文