摘要:
这是一道动态规划题目,动态规划的核心是:状态和转态转移方程。 //方法一: //Time:O(n),Space:O(n) class Solution { public: int max(int a,int b) { return a>b?a:b; } int rob(vector<int>& nu 阅读全文
摘要:
这道题属于属于动态规划中比较简单的一道题目。 //Time:O(n),Space:O(1) class Solution { public: int max(int a,int b) { return a>b?a:b; } int maxSubArray(vector<int>& nums) { i 阅读全文
摘要:
//方法一:暴力破解法,使用2重循环来解决,这种方法时间复杂度较高 //Time:O(n^2),Space:O(1) //语言:经典C++ class Solution { public: int max(int a,int b) { return a>b?a:b; } int maxProfit( 阅读全文