当前位置:网站首页>【LeetCode】Day112-重复的DNA序列
【LeetCode】Day112-重复的DNA序列
2022-08-11 02:51:00 【倒过来是圈圈】
题目
题解
哈希表
哈希表记录长度为10的子串的对应出现次数,也用到了滑动窗口的思想
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)
边栏推荐
猜你喜欢

A practice arrangement about map GIS (below) GIS practice of Redis

Oops novice template Framework project guide

JS-DOM元素对象

117. 本地开发好的 SAP UI5 应用部署到 ABAP 服务器时,中文字符变成乱码的原因分析和解决方案

言简意赅,说说 @Transactional 在项目中的使用

ES6 advanced string processing new features

TRCX: doping process analysis

redis学习五redis的持久化RDB,fork,copyonwrite,AOF,RDB&AOF混合使用

OpenCV founder: Open source must not be completely free!

The practice of alibaba data synchronization component canal
随机推荐
多线程之ThreadPoolExecutor
混币器Tornado遭制裁 对DeFi市场意味着什么?
BUU刷题记录
Entity到Vo的转换
ifconfig与ip命令的比较
Add user error useradd: cannot open /etc/passwd
Multi-threaded ThreadPoolExecutor
Geogebra 教程之 04 Geogebra 小程序
ARM development (4) How to read the chip manual for novice Xiaobai, bare metal driver development steps and pure assembly to achieve lighting, assembly combined with c lighting, c to achieve lighting
BUU brushing record
[4G/5G/6G专题基础-154]: 5G无线准入控制RAC(Radio Admission Control)
添加用户报错useradd: cannot open /etc/passwd
Google search skills - programmer is recommended
GBJ3510-ASEMI家电电源用整流桥GBJ3510
求和、计数的窗口函数应用
The ifconfig compared with IP command
Add support for Textbundle
21天学习挑战赛第一周总结
[Pdf generated automatically bookmarks]
今天聊聊接口幂等性校验