贪心
贪心
Chamberlain T
尼蝶
展开
-
LeetCode.121. Best Time to Buy and Sell Stock
LeetCode.121. 买卖股票的最佳时机难度:easyJava:// //暴力法:超时了哈哈// class Solution {// public int maxProfit(int[] prices) {// int length = prices.length;// int ans = 0;// for (int i = 0; i < length; i++) {// fo..原创 2021-12-26 17:09:08 · 314 阅读 · 1 评论 -
LeetCode.343.整数拆分
LeetCode.343.整数拆分难度:medium典型的动态规划的题,写出了状态转移方程后也很好写了;Java:动态规划:class Solution { public int integerBreak(int n) { //dp[i] 存储 i 的拆分最大乘积 int[] dp = new int[n + 1]; //初始化:dp[0]和dp[1]无意义 dp[2] = 1; //动态规划.原创 2021-12-19 16:05:20 · 93 阅读 · 0 评论