当前位置:网站首页>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;
}
};
边栏推荐
- OpenJudge NOI 2.1 1752:鸡兔同笼
- Few shot Learning & meta learning: small sample learning principle and Siamese network structure (I)
- Complex network modeling (III)
- Zsh shell adds automatic completion and syntax highlighting
- 复杂网络建模(二)
- 基于Pytorch 框架手动完成线性回归
- jeeSite 表单页面的Excel 导入功能
- 【数字IC验证快速入门】13、SystemVerilog interface 和 program 学习
- It took "7" years to build the robot framework into a micro service
- CDC (change data capture technology), a powerful tool for real-time database synchronization
猜你喜欢
电池、电机技术受到很大关注,反而电控技术却很少被提及?
【踩坑系列】uniapp之h5 跨域的问题
【数字IC验证快速入门】14、SystemVerilog学习之基本语法1(数组、队列、结构体、枚举、字符串...内含实践练习)
Dedecms collects content without writing rules
Unityhub cracking & unity cracking
[quickstart to Digital IC Validation] 15. Basic syntax for SystemVerilog Learning 2 (operator, type conversion, loop, Task / Function... Including practical exercises)
LeetCode简单题之字符串中最大的 3 位相同数字
Shell 脚本的替换功能实现
微信小程序基本组件使用介绍
通俗易懂单点登录SSO
随机推荐
Merging binary trees by recursion
JS quick start (I)
Thinkcmf6.0安装教程
Interactive book delivery - signed version of Oracle DBA work notes
2022 welder (elementary) judgment questions and online simulation examination
Network learning (III) -- highly concurrent socket programming (epoll)
Recursive construction of maximum binary tree
芯片资料 网站 易特创芯
MySQL multi column index (composite index) features and usage scenarios
Paddlepaddle 29 dynamically modify the network structure without model definition code (relu changes to prelu, conv2d changes to conv3d, 2D semantic segmentation model changes to 3D semantic segmentat
The legend about reading the configuration file under SRC
[VHDL parallel statement execution]
复杂网络建模(三)
【数字IC验证快速入门】12、SystemVerilog TestBench(SVTB)入门
【踩坑系列】uniapp之h5 跨域的问题
2022 simulated examination question bank and online simulated examination of tea master (primary) examination questions
Empire CMS collection Empire template program general
The element with setfieldsvalue set is obtained as undefined with GetFieldValue
通俗易懂单点登录SSO
buureservewp(2)