当前位置:网站首页>【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)
边栏推荐
猜你喜欢
OpenCV创始人:开源绝不能完全免费!
qtcreator调试webkit
Realization of vending machine function based on FPGA state machine
AI+医疗:使用神经网络进行医学影像识别分析
Official release丨VS Code 1.70
117. 本地开发好的 SAP UI5 应用部署到 ABAP 服务器时,中文字符变成乱码的原因分析和解决方案
代码 Revert 后再次 Merge 会丢失的问题,已解决
学军中学推理社2017届招新试题
MSP430如何给板子下载程序?(IAR MSPFET CCS)
flink The object probably contains or references non serializable fields.
随机推荐
Multi-threaded ThreadPoolExecutor
维特智能惯导配置
JS-DOM元素对象
SQL 开发的十个高级概念
Summary of debugging skills
对加密世界的经济误解:现金是储蓄?稀缺性创造价值?
Official release丨VS Code 1.70
经典面试题 之 GC垃圾收集器
"Beijing-Taiwan high-speed rail" debuted on Baidu map, can it really be built in 2035?
OpenCV founder: Open source must not be completely free!
多线程之ThreadPoolExecutor
flink The object probably contains or references non serializable fields.
全局大喇叭--广播机制
Docker 链接sqlserver时出现en-us is an invalid culture错误解决方案
ES进阶 数组功能语法新特性详解
The 125th day of starting a business - a note
一言(ヒトコト)Hitokoto API
“京台高铁”亮相百度地图,真能在2035年建成吗?
Research on the Application of Privacy Computing Fusion
CSAPP Data Lab