首页 > 代码库 > leetcode187. Repeated DNA Sequences
leetcode187. Repeated DNA Sequences
https://leetcode.com/problems/repeated-dna-sequences/#/description
https://leetcode.com/problems/repeated-dna-sequences/#/solutions
位运算大法好
值得注意 例如0xff 一个f表示15 二进制中表示1111
1 class Solution { 2 public: 3 vector<string> findRepeatedDnaSequences(string s) { 4 //A is 0101, C is 0103, G is 0107, T is 0124 //3bit to store 5 unordered_map<int,int> m; 6 vector<string> r; 7 int t=0,i=0,ss=s.length(); 8 while(i<9) 9 t=t<<3|s[i++]&7; 10 while(i<ss) 11 if(m[t=t<<3&0x3fffffff|s[i++]&7]++==1) 12 r.push_back(s.substr(i-10,10)); 13 return r; 14 } 15 };
leetcode187. Repeated DNA Sequences
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。