当前位置:网站首页>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;
}
};
边栏推荐
- 让Livelink初始Pose与动捕演员一致
- Linux server development, MySQL index principle and optimization
- [quick start of Digital IC Verification] 17. Basic grammar of SystemVerilog learning 4 (randomization)
- 基于Pytorch 框架手动完成线性回归
- Network learning (I) -- basic model learning
- WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after conne
- 2022 recurrent training question bank and answers of refrigeration and air conditioning equipment operation
- Es FAQ summary
- 2022 National latest fire-fighting facility operator (primary fire-fighting facility operator) simulation questions and answers
- The element with setfieldsvalue set is obtained as undefined with GetFieldValue
猜你喜欢
【数字IC验证快速入门】11、Verilog TestBench(VTB)入门
Niu Mei's mathematical problem --- combinatorial number
互动送书-《Oracle DBA工作笔记》签名版
调用 pytorch API完成线性回归
Es FAQ summary
Linux server development, MySQL index principle and optimization
青龙面板-今日头条
2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
Codeforce c.strange test and acwing
QT learning 26 integrated example of layout management
随机推荐
Unityhub cracking & unity cracking
Es FAQ summary
Linux server development, MySQL index principle and optimization
【数字IC验证快速入门】15、SystemVerilog学习之基本语法2(操作符、类型转换、循环、Task/Function...内含实践练习)
王爽 《汇编语言》之寄存器
探索干货篇!Apifox 建设思路
电池、电机技术受到很大关注,反而电控技术却很少被提及?
Leetcode 90: subset II
Real time monitoring of dog walking and rope pulling AI recognition helps smart city
互动送书-《Oracle DBA工作笔记》签名版
【数字IC验证快速入门】13、SystemVerilog interface 和 program 学习
快解析内网穿透助力外贸管理行业应对多种挑战
Force buckle 144 Preorder traversal of binary tree
DNS server configuration
Relevant data of current limiting
JS cross browser parsing XML application
Pytorch(六) —— 模型调优tricks
Complex network modeling (II)
Quickly use Jacobo code coverage statistics
ROS Bridge 笔记(05)— carla_ackermann_control 功能包(将Ackermann messages 转化为 CarlaEgoVehicleControl 消息)