摘要:
123. 买卖股票的最佳时机 III 分类: dp 我以为是动态规划之实际上是暴力 class Solution { public: int maxProfit(vector<int>& prices) { int n = prices.size(); vector<vector<int>> dp( 阅读全文
摘要:
189. 旋转数组 分类: 数组 数组循环移位经典题 class Solution { // 翻转数组 public: void reverse(vector<int>& nums, int i, int j){ int t; while(i < j){ t = nums[i]; nums[i++] 阅读全文
摘要:
分类: 图 并查集 class Solution { public: int root(int* u, int j){ //找到j的集合根 while(j != u[j]) j = u[j]; return j; } void combine(int* u, int i, int j){ //把j接 阅读全文