mirror of
https://git.wolves.top/wolves/leetcode.git
synced 2025-11-04 17:26:32 +08:00
init
This commit is contained in:
28
23/11/Q187.h
Normal file
28
23/11/Q187.h
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Created by 李洋 on 2023/11/5.
|
||||
//
|
||||
|
||||
#ifndef LEECODE_C_Q187_H
|
||||
#define LEECODE_C_Q187_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace std;
|
||||
|
||||
vector<string> findRepeatedDnaSequences(string s) {
|
||||
vector<string> ret;
|
||||
unordered_map<string, int> m;
|
||||
for(int i = 0;i+9<s.length();i++){
|
||||
m[s.substr(i,i+9)] = m[s.substr(i,i+9)] + 1;
|
||||
}
|
||||
for(auto [key,value]:m){
|
||||
if(value > 1){
|
||||
ret.push_back(key);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif //LEECODE_C_Q187_H
|
||||
Reference in New Issue
Block a user