摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solu 阅读全文
posted @ 2020-04-01 16:25 qiujiejie 阅读(113) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solu 阅读全文
posted @ 2020-04-01 16:05 qiujiejie 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 每一轮for循环,判断当points[i]为Boomerangs的第一个point时,第二个point和第三个point有几种情况:计算points[i]与其他每一个points[j]的距离;当距离相等的点大于等于两个时,从这些点中选两个,且则两个点有序(组合问题),就是一种情况。 class So 阅读全文
posted @ 2020-03-31 17:02 qiujiejie 阅读(173) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int longestPalindrome(string s) { int re=0; vector<int> vec(58,0); for(auto& c:s) { ++vec[c-'A']; } for(auto&t: vec) { re+=t/ 阅读全文
posted @ 2020-03-31 16:12 qiujiejie 阅读(92) 评论(0) 推荐(0) 编辑
摘要: class RandomizedCollection { unordered_map<int,unordered_set<int>> m; vector<int> vals; public: /** Initialize your data structure here. */ Randomized 阅读全文
posted @ 2020-03-31 11:40 qiujiejie 阅读(109) 评论(0) 推荐(0) 编辑
摘要: class Twitter { unordered_map<int,deque<pair<int,int>>> uid_tid;//deque is double-ended queue unordered_map<int,unordered_set<int>> uid_fid; int times 阅读全文
posted @ 2020-03-30 10:04 qiujiejie 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 1. class Solution { public: string getHint(string secret, string guess) { int bulls=0,cows=0; vector<int> m(10,0); queue<int> q; for(int i=0;i<guess.s 阅读全文
posted @ 2020-03-27 10:33 qiujiejie 阅读(153) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: bool wordPattern(string pattern, string str) { istringstream is(str); unordered_map<char,string> m; unordered_map<string,char 阅读全文
posted @ 2020-03-27 09:51 qiujiejie 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 参考:https://www.cnblogs.com/grandyang/p/4781203.html class Solution { public: int hIndex(vector<int>& citations) { sort(citations.begin(),citations.end 阅读全文
posted @ 2020-03-26 11:36 qiujiejie 阅读(97) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: bool isAnagram(string s, string t) { vector<int> ms(26,0),mt(26,0); for(auto& str:s) ++ms[str-'a']; for(auto& str:t) ++mt[str 阅读全文
posted @ 2020-03-26 10:46 qiujiejie 阅读(91) 评论(0) 推荐(0) 编辑