当前位置:网站首页>【LeetCode】Day112-repetitive DNA sequence
【LeetCode】Day112-repetitive DNA sequence
2022-08-11 02:56:00 【It's a circle upside down】
题目
题解
哈希表
The length of the hash table record is10The corresponding occurrences of the substring of ,The idea of sliding windows is also used
class Solution {
public List<String> findRepeatedDnaSequences(String s) {
List<String>res=new ArrayList<>();
Map<String,Integer>map=new HashMap<>();
for(int i=0;i<=s.length()-10;i++){
String str=s.substring(i,i+10);//截子串
map.put(str,map.getOrDefault(str,0)+1);
if(map.get(str)==2)
res.add(str);
}
return res;
}
}
时间复杂度: O ( n L ) O(nL) O(nL),L=10 即目标子串的长度,因为substring复杂度是O(L)
空间复杂度: O ( n L ) O(nL) O(nL)
边栏推荐
- 带你系统学习MySQL索引
- 求和、计数的窗口函数应用
- 成都纸质发票再见!开住宿费电子发票即将全面取代酒店餐饮加油站发票
- Summary of Logstash log data write exception troubleshooting
- shell脚本入门
- Goodbye Guangzhou paper invoices!The issuance of electronic invoices for accommodation fees will completely replace the invoices of hotels, restaurants and gas stations
- 面试常考的7种排序算法
- 超声三维重建总体架构
- 数据存储全方案----详解持久化技术
- 解决vim与外界的复制粘贴(不用安装插件)
猜你喜欢

leetcode: 358. Reorder strings at K distance intervals

DOM-DOM树,一个DOM树有三种类型的节点

AI+医疗:使用神经网络进行医学影像识别分析

flink The object probably contains or references non serializable fields.

如何解决高度塌陷

BUU brushing record

Summary of Logstash log data write exception troubleshooting

A Practical Arrangement of Map GIS Development Matters (Part 1)

JS-DOM元素对象

Multi-threaded ThreadPoolExecutor
随机推荐
(Nips-2015)空间变换器网络
The ifconfig compared with IP command
聊聊对RPC的理解
花甲的思考
Goodbye Chongqing paper invoices!The issuance of electronic invoices for accommodation expenses will soon completely replace the invoices of hotels, catering and gas stations
SQL 开发的十个高级概念
全局大喇叭--广播机制
调试技巧总结
Official release丨VS Code 1.70
对加密世界的经济误解:现金是储蓄?稀缺性创造价值?
深度学习中的模型设计
言简意赅,说说 @Transactional 在项目中的使用
CC0 vs. commercial IP: which model is better for NFTs?
Entity to Vo conversion
掌握这几招,轻松K.O面试官,Offer拿到吐
IDE编译报错:Dangling metacharacter
A practice arrangement about map GIS (below) GIS practice of Redis
MySQL的主从复制+读写分离+分库分表,看这一篇文章就够了
代码 Revert 后再次 Merge 会丢失的问题,已解决
Summary of Logstash log data write exception troubleshooting