当前位置:网站首页>Leetcode 187 Repeated DNA sequence (2022.07.06)
Leetcode 187 Repeated DNA sequence (2022.07.06)
2022-07-07 08:10:00 【ChaoYue_ miku】
DNA Sequence It consists of a series of nucleotides , Abbreviation for ‘A’, ‘C’, ‘G’ and ‘T’..
for example ,“ACGAATTCCG” It's a DNA Sequence .
Research on DNA when , distinguish DNA The repeats in are very useful .
Given a representation DNA Sequence String s , Return all in DNA More than once in a molecule The length is 10 Sequence ( Substring ). You can press In any order Return to the answer .
Example 1:
Input :s = “AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT”
Output :[“AAAAACCCCC”,“CCCCCAAAAA”]
Example 2:
Input :s = “AAAAAAAAAAAAA”
Output :[“AAAAAAAAAA”]
Tips :
0 <= s.length <= 105
s[i]==‘A’、‘C’、‘G’ or ‘T’
source : Power button (LeetCode)
Method 1 : Hashtable
C++ Submission :
class Solution {
const int L = 10;
public:
vector<string> findRepeatedDnaSequences(string s) {
vector<string> ans;
unordered_map<string, int> cnt;
int n = s.length();
for (int i = 0; i <= n - L; ++i) {
string sub = s.substr(i, L);
if (++cnt[sub] == 2) {
ans.push_back(sub);
}
}
return ans;
}
};
边栏推荐
- Hisense TV starts the developer mode
- Interactive book delivery - signed version of Oracle DBA work notes
- Pytorch(六) —— 模型调优tricks
- 芯片 設計資料下載
- Leetcode 40: combined sum II
- Record a stroke skin bone error of the skirt
- Niu Mei's mathematical problem --- combinatorial number
- The charm of SQL optimization! From 30248s to 0.001s
- offer收割机:两个长字符串数字相加求和(经典面试算法题)
- [quick start of Digital IC Verification] 15. Basic syntax of SystemVerilog learning 2 (operators, type conversion, loops, task/function... Including practical exercises)
猜你喜欢
[Matlab] Simulink 自定义函数中的矩阵乘法工作不正常时可以使用模块库中的矩阵乘法模块代替
复杂网络建模(一)
The charm of SQL optimization! From 30248s to 0.001s
这5个摸鱼神器太火了!程序员:知道了快删!
[quickstart to Digital IC Validation] 15. Basic syntax for SystemVerilog Learning 2 (operator, type conversion, loop, Task / Function... Including practical exercises)
青龙面板-今日头条
王爽 《汇编语言》之寄存器
Es FAQ summary
Li Kou interview question 04.01 Path between nodes
LeetCode简单题之判断一个数的数字计数是否等于数位的值
随机推荐
Empire CMS collection Empire template program general
Linux server development, MySQL cache strategy
Uniapp mobile terminal forced update function
LeetCode中等题之我的日程安排表 I
Thinkcmf6.0 installation tutorial
【踩坑系列】uniapp之h5 跨域的问题
Ansible
QT learning 28 toolbar in the main window
C language flight booking system
Network learning (III) -- highly concurrent socket programming (epoll)
JS quick start (I)
复杂网络建模(一)
Network learning (II) -- Introduction to socket
MySQL multi column index (composite index) features and usage scenarios
快解析内网穿透为文档加密行业保驾护航
Few shot Learning & meta learning: small sample learning principle and Siamese network structure (I)
Record a stroke skin bone error of the skirt
Explore dry goods! Apifox construction ideas
Find the mode in the binary search tree (use medium order traversal as an ordered array)
2022 Inner Mongolia latest advanced fire facility operator simulation examination question bank and answers