上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 38 下一页
摘要: 1 class Solution 2 { 3 vector<vector<int>> memo; 4 public: 5 int getMoneyAmount(int n) 6 { 7 memo = vector<vector<int>>(n + 1,vector<int>(n + 1,-1)); 阅读全文
posted @ 2020-04-27 09:24 Jinxiaobo0509 阅读(132) 评论(0) 推荐(0)
摘要: 1 /** 2 * Forward declaration of guess API. 3 * @param num your guess 4 * @return -1 if num is lower than the guess number 5 * 1 if num is higher than 阅读全文
posted @ 2020-04-26 19:26 Jinxiaobo0509 阅读(98) 评论(0) 推荐(0)
摘要: 1 struct cmp 2 { 3 bool operator ()(vector<int> &a, const vector<int> &b) 4 { 5 // < :大顶堆 6 // > :小顶堆 7 return a[0]+a[1] > b[0]+b[1]; 8 } 9 }; 10 prio 阅读全文
posted @ 2020-04-26 19:01 Jinxiaobo0509 阅读(107) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 struct cmp 4 { 5 bool operator ()(vector<int> &a, const vector<int> &b) 6 { 7 // < :大顶堆 8 // > :小顶堆 9 return a[0]+a[1] > b[0]+b 阅读全文
posted @ 2020-04-26 19:00 Jinxiaobo0509 阅读(119) 评论(0) 推荐(0)
摘要: 1 for (int i=arr.size()-1;i>=0;--i) 2 { 3 srand((unsigned)time(NULL)); 4 swap(arr[rand()%(i+1)],arr[i]); 5 } [0,i]中随机选一个数,与第i个数交换 阅读全文
posted @ 2020-04-25 18:56 Jinxiaobo0509 阅读(145) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 vector<int> findAnagrams(string s, string t) 5 { 6 unordered_map<char, int> need, window; 7 for (char c : t) need[c]+ 阅读全文
posted @ 2020-04-25 11:15 Jinxiaobo0509 阅读(121) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 // 判断 s 中是否存在 t 的排列 5 bool checkInclusion(string t, string s) 6 { 7 unordered_map<char, int> need, window; 8 for (cha 阅读全文
posted @ 2020-04-25 11:02 Jinxiaobo0509 阅读(134) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 vector<int> maxSlidingWindow(vector<int>& nums, int k) 5 { 6 vector<int> res; 7 deque<int> q; 8 for(int i = 0;i < num 阅读全文
posted @ 2020-04-24 22:34 Jinxiaobo0509 阅读(139) 评论(0) 推荐(0)
摘要: 1 class Solution 2 { 3 public: 4 string plusOne(string s, int j) // 将 s[j] 向上拨动一次 5 { 6 if(s[j] == '9') s[j] = '0'; 7 else s[j] += 1; 8 return s; 9 } 阅读全文
posted @ 2020-04-24 16:07 Jinxiaobo0509 阅读(169) 评论(0) 推荐(0)
摘要: 1 // 计算从起点 start 到终点 target 的最近距离 2 int BFS(Node start, Node target) { 3 Queue<Node> q; // 核心数据结构 4 Set<Node> visited; // 避免走回头路,大部分时候都是必须的,但是像一般的二叉树结 阅读全文
posted @ 2020-04-24 14:55 Jinxiaobo0509 阅读(478) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 38 下一页