摘要:
动态规划——NC19. 子数组的最大累加和问题 题目: 思路: dp数组的定义:dp[m] 代表在arr[m]时的最大子数组和 base_case: 状态转移方程:化简了,思路就是要么加入之前的,要么另起炉灶。 代码: class Solution { public: /** * max sum o 阅读全文
摘要:
二叉搜索树——230. 二叉搜索树中第K小的元素 题目: 思路: 中序遍历+辅助计数,到k了就输出就行。 代码: class Solution { public: // 计数 int n=0; // 存放结果 int res; int kthSmallest(TreeNode* root, int 阅读全文