随笔分类 - Week4 字符串专题
摘要:1 //用到了贪心思想 2 class Solution 3 { 4 public: 5 string small[20] = {"Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten", 6 "Eleve
阅读全文
摘要:1 //所有实现最好写在一个类中 2 class Trie 3 { 4 public: 5 bool is_end; //是否以该单词结尾 6 Trie* son[26]; //该节点儿子的个数 7 Trie() 8 { 9 is_end = false; 10 for(int i = 0;i <
阅读全文
摘要:1 //1、除了小写字母,这些电子邮件还可能包含 '.' 或 '+' 2 //2、每封 emails[i] 都包含有且仅有一个 '@' 字符 3 //3、只考虑本地名称,即'@'字符以前的 4 class Solution 5 { 6 public: 7 int numUniqueEmails(ve
阅读全文
摘要:1 class Solution 2 { 3 vector<int> res; 4 void spilt(string s,char c,vector<int> &res) 5 { 6 istringstream iss(s); 7 string temp; 8 while(getline(iss,
阅读全文
摘要:1 class Solution 2 { 3 //spilt函数的实现 4 //假设以空格切分:char c = ' '; 5 vector<string> res; 6 void spilt(string s,char c,vector<string> &res) 7 { 8 istringstr
阅读全文
摘要:1 class Solution 2 { 3 public: 4 vector<vector<string>> groupAnagrams(vector<string>& strs) 5 { 6 vector<vector<string>> res; 7 unordered_map<string,v
阅读全文
摘要:比如:111221 1、找出相同子串:str[i + 1] == str[i] 2、在每相同子串的最后一位进行记录与更新 1 class Solution 2 { 3 public: 4 string countAndSay(int n) 5 { 6 string str = "1"; 7 whil
阅读全文
摘要:1 //找规律题 等差数列 2m-2 2 class Solution 3 { 4 public: 5 string convert(string s, int m) 6 { 7 if(m == 1) return s; 8 int n = s.size(); 9 string res; 10 fo
阅读全文
摘要:1 //左右同时走,如果相等,更新最大值 2 class Solution 3 { 4 public: 5 string longestPalindrome(string s) 6 { 7 int res = 0; 8 string str; 9 for(int i = 0;i < s.size()
阅读全文
摘要:1 //双指针算法模板+哈希表 2 class Solution 3 { 4 public: 5 int lengthOfLongestSubstring(string s) 6 { 7 unordered_map<char,int> nums; 8 int res = 0; 9 for(int i
阅读全文

浙公网安备 33010602011771号