会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
7
8
9
10
···
38
下一页
2020年4月28日
395. 至少有K个重复字符的最长子串
摘要: 1 class Solution 2 { 3 public: 4 int longestSubstring(string s, int k) 5 { 6 if(s.empty()) return 0; 7 vector<int> hash(26); 8 for(auto a : s) hash[a
阅读全文
posted @ 2020-04-28 12:19 Jinxiaobo0509
阅读(85)
评论(0)
推荐(0)
2020年4月27日
393. UTF-8 编码验证
摘要: 1 class Solution 2 { 3 public: 4 bool validUtf8(vector<int>& data) 5 { 6 int n = 0; 7 for(int i = 0;i < data.size();i ++) 8 { 9 if(n > 0) 10 { 11 if(d
阅读全文
posted @ 2020-04-27 22:54 Jinxiaobo0509
阅读(179)
评论(0)
推荐(0)
389. 找不同
摘要: 1 class Solution 2 { 3 public: 4 char findTheDifference(string s, string t) 5 { 6 unordered_map<char,int> hash; 7 for(auto a : s) hash[a] ++; 8 for(au
阅读全文
posted @ 2020-04-27 17:49 Jinxiaobo0509
阅读(114)
评论(0)
推荐(0)
387. 字符串中的第一个唯一字符
摘要: 1 class Solution 2 { 3 public: 4 int firstUniqChar(string s) 5 { 6 unordered_map<char,int> hash; 7 for(auto a : s) hash[a] ++; 8 for(int i = 0;i < s.s
阅读全文
posted @ 2020-04-27 16:00 Jinxiaobo0509
阅读(96)
评论(0)
推荐(0)
386. 字典序排数
摘要: 1 class Solution 2 { 3 public: 4 vector<int> lexicalOrder(int n) 5 { 6 set<string> hash; 7 vector<int> res; 8 for(int i = 1;i <= n;i ++) 9 { 10 hash.i
阅读全文
posted @ 2020-04-27 15:54 Jinxiaobo0509
阅读(113)
评论(0)
推荐(0)
384. 打乱数组
摘要: 1 class Solution 2 { 3 vector<int> vec; 4 public: 5 Solution(vector<int>& nums) 6 { 7 vec = nums; 8 } 9 10 /** Resets the array to its original config
阅读全文
posted @ 2020-04-27 15:26 Jinxiaobo0509
阅读(239)
评论(0)
推荐(0)
383. 赎金信
摘要: 1 class Solution 2 { 3 public: 4 bool canConstruct(string ransomNote, string magazine) 5 { 6 unordered_map<char,int> hash_r,hash_m; 7 for(auto a : mag
阅读全文
posted @ 2020-04-27 14:20 Jinxiaobo0509
阅读(90)
评论(0)
推荐(0)
382. 链表随机节点
摘要: 1 class Solution 2 { 3 public: 4 ListNode* nod; 5 Solution(ListNode* head) 6 { 7 this->nod = head; 8 } 9 10 int getRandom() 11 { 12 if(nod == NULL) re
阅读全文
posted @ 2020-04-27 14:06 Jinxiaobo0509
阅读(102)
评论(0)
推荐(0)
380. 常数时间插入、删除和获取随机元素
摘要: 1 class RandomizedSet 2 { 3 unordered_map<int,int> hash; 4 vector<int> nums; 5 public: 6 /** Initialize your data structure here. */ 7 RandomizedSet()
阅读全文
posted @ 2020-04-27 11:22 Jinxiaobo0509
阅读(111)
评论(0)
推荐(0)
378. 有序矩阵中第K小的元素
摘要: 1 class Solution 2 { 3 public: 4 int kthSmallest(vector<vector<int>>& matrix, int k) 5 { 6 priority_queue<int,vector<int>,greater<int>> pq; 7 int n =
阅读全文
posted @ 2020-04-27 09:59 Jinxiaobo0509
阅读(131)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
8
9
10
···
38
下一页
公告