Q187.h 530 B

12345678910111213141516171819202122232425262728
  1. //
  2. // Created by 李洋 on 2023/11/5.
  3. //
  4. #ifndef LEECODE_C_Q187_H
  5. #define LEECODE_C_Q187_H
  6. #include <string>
  7. #include <vector>
  8. #include <unordered_map>
  9. using namespace std;
  10. vector<string> findRepeatedDnaSequences(string s) {
  11. vector<string> ret;
  12. unordered_map<string, int> m;
  13. for(int i = 0;i+9<s.length();i++){
  14. m[s.substr(i,i+9)] = m[s.substr(i,i+9)] + 1;
  15. }
  16. for(auto [key,value]:m){
  17. if(value > 1){
  18. ret.push_back(key);
  19. }
  20. }
  21. return ret;
  22. }
  23. #endif //LEECODE_C_Q187_H
备用站点 当前处于降级运行的备用站点,仅供应急访问,数据和功能可能不是最新。