当前位置:网站首页>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;
}
};
边栏推荐
- 2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
- 数据库实时同步利器——CDC(变化数据捕获技术)
- Zsh shell adds automatic completion and syntax highlighting
- Relevant data of current limiting
- Roulette chart 2 - writing of roulette chart code
- 调用 pytorch API完成线性回归
- 【数字IC验证快速入门】15、SystemVerilog学习之基本语法2(操作符、类型转换、循环、Task/Function...内含实践练习)
- Explore dry goods! Apifox construction ideas
- Real time monitoring of dog walking and rope pulling AI recognition helps smart city
- C language communication travel card background system
猜你喜欢

2022 recurrent training question bank and answers of refrigeration and air conditioning equipment operation

这5个摸鱼神器太火了!程序员:知道了快删!

Network learning (II) -- Introduction to socket

Call pytorch API to complete linear regression

Bugku CTF daily one question chessboard with only black chess

Make LIVELINK's initial pose consistent with that of the mobile capture actor

LeetCode中等题之我的日程安排表 I

2022 tea master (intermediate) examination questions and mock examination
![[quick start of Digital IC Verification] 17. Basic grammar of SystemVerilog learning 4 (randomization)](/img/39/cac2b5492d374da393569e2ab467a4.png)
[quick start of Digital IC Verification] 17. Basic grammar of SystemVerilog learning 4 (randomization)

buureservewp(2)
随机推荐
Linux server development, MySQL cache strategy
王爽 《汇编语言》之寄存器
CDC (change data capture technology), a powerful tool for real-time database synchronization
Linux server development, redis source code storage principle and data model
Pytorch(六) —— 模型调优tricks
【数字IC验证快速入门】10、Verilog RTL设计必会的FIFO
JSON data flattening pd json_ normalize
Chip information website Yite Chuangxin
Empire CMS collection Empire template program general
Myabtis_ Plus
【数字IC验证快速入门】17、SystemVerilog学习之基本语法4(随机化Randomization)
【数字IC验证快速入门】11、Verilog TestBench(VTB)入门
互动送书-《Oracle DBA工作笔记》签名版
Qt学习28 主窗口中的工具栏
追风赶月莫停留,平芜尽处是春山
[quick start of Digital IC Verification] 15. Basic syntax of SystemVerilog learning 2 (operators, type conversion, loops, task/function... Including practical exercises)
Recursive method to verify whether a tree is a binary search tree (BST)
Interactive book delivery - signed version of Oracle DBA work notes
【踩坑系列】uniapp之h5 跨域的问题
2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案