上一页 1 2 3 4 5 6 ··· 23 下一页
摘要: class Solution { public: int longestConsecutive(vector<int>& nums) { if(nums.size()==0) return 0; sort(nums.begin(), nums.end()); // 去除重复元素, 不然遇到0 1 1 阅读全文
posted @ 2021-09-28 15:43 三一一一317 阅读(30) 评论(0) 推荐(0)
摘要: class Solution { public: int getSum(int a, int b) { while(b!=0){ // 进位为0的时候停止 // 注意这个unsigned int 很重要 unsigned int carry = (unsigned int) (a&b)<<1; // 阅读全文
posted @ 2021-09-26 21:03 三一一一317 阅读(24) 评论(0) 推荐(0)
摘要: class Solution { public: // 字符串分割 vector<string> spltstr(string s){ vector<string> res; string tmp; for(auto c: s){ if(c!=' ') tmp = tmp + c; else if( 阅读全文
posted @ 2021-09-25 15:09 三一一一317 阅读(58) 评论(0) 推荐(0)
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : 阅读全文
posted @ 2021-09-22 14:27 三一一一317 阅读(26) 评论(0) 推荐(0)
摘要: /* dp[i]表示以i下标结尾的最长严格递增子序列的长度,需要注意的是最后算出来的dp[i]才是以i下标结尾的 最长严格递增子序列的长度,中间运行过程中dp[i]并不是以i结尾的最长严格递增子序列的长度, 而是以i结尾的递增子序列的长度。 cnt[i]为考虑以nums[i]结尾的最长上升子序列的个 阅读全文
posted @ 2021-09-20 14:58 三一一一317 阅读(69) 评论(0) 推荐(0)
摘要: 单源最短路径,其实就是求某个节点到其他所有节点中路径的最大值 class Solution { public: void dijkstra(vector<vector<int>>& w, int k, int n,vector<bool>& vis,vector<int>& dist) { // 只 阅读全文
posted @ 2021-09-19 10:59 三一一一317 阅读(64) 评论(0) 推荐(0)
摘要: 示例: 输入: [[100, 200], [200, 1300], [1000, 1250], [2000, 3200]] 输出: 3 解释: 这里一共有 4 门课程, 但是你最多可以修 3 门: 首先, 修第一门课时, 它要耗费 100 天,你会在第 100 天完成, 在第 101 天准备下门课。 阅读全文
posted @ 2021-09-18 16:27 三一一一317 阅读(71) 评论(0) 推荐(0)
摘要: 示例 2: 输入: 4, [[1,0],[2,0],[3,1],[3,2]] 输出: [0,1,2,3] or [0,2,1,3] class Solution { public: vector<int> findOrder(int numCourses, vector<vector<int>>& 阅读全文
posted @ 2021-09-18 15:19 三一一一317 阅读(79) 评论(0) 推荐(0)
摘要: class Solution { public: bool isBipartite(vector<vector<int>>& graph) { int n = graph.size(); if(n==0) return true; queue<int> q; vector<int> color(n, 阅读全文
posted @ 2021-09-18 14:52 三一一一317 阅读(23) 评论(0) 推荐(0)
摘要: Amazon - 北京/上海 AMD - 上海 Airbnb - 北京 Apple - 北京/上海 ArcSoft - 杭州 Autodesk - 北京/上海 Booking - 上海 Citrix - 南京 Cisco - 北京/上海/杭州/苏州 Coolapk (酷安) - 北京/深圳 Coup 阅读全文
posted @ 2021-09-12 19:33 三一一一317 阅读(83) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 ··· 23 下一页