LeetCode || Repeated DNA Sequences

【LeetCode】Repeated DNA Sequences 解题报告 【题目】 All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the D 阅读详情

Repeated DNA Sequences

  Total Accepted: 19705  Total Submissions: 99010 My Submissions

All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.

Write a function to find all the 10-letter-long sequences (substrings) that occur more than once in a DNA molecule.

For example,

Given s = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT",

Return:
["AAAAACCCCC", "CCCCCAAAAA"].

class Solution {
public:
    int getVal(char ch) {
        if (ch == 'A') return 0;
        if (ch == 'C') return 1;
        if (ch == 'G') return 2;
        if (ch == 'T') return 3;
    }
    
    vector<string> findRepeatedDnaSequences(string s) {
        vector<string> vt;
        string sub;
        if(s.size()<10 || s == "")
            return vt;
        int mp[1024*1024] = {0};//2^20的空间
        unsigned int val = 0;
        
        for(int i = 0;i<9;i++){//得到前面9为的二进制数据
            val <<= 2;
            val |= getVal(s[i]);
        }
        
        for(int i = 9;i<s.size();i++)
        {
            val <<= 14;//为了删除前面两位,也就是第一个字符
            val >>= 12;//后面字符代替前面字符。
            
            val|=getVal(s[i]);
            
            if(mp[val] > 1)
                continue;
                
            mp[val]++;//统计每个字符出现的次数
            
            if(mp[val] >1){//表明循环多次得字符串
                sub = s.substr(i-9, 10);
                vt.push_back(sub);
            }
        }
        
        return vt;
    }
};

告别臃肿VS!仅用Visual Studio 2022 Build Tools为Qt 5.12.12配置MSVC2017开发环境 本文详细介绍了如何仅使用Visual Studio 2022 Build Tools为Qt 5.12.12配置MSVC2017开发环境,避免安装臃肿的完整VS。通过精准选择组件、配置Qt Creator编译器和优化Kit设置,实现高效、精简的Windows平台Qt开发环境搭建,特别适合追求性能和资源优化的开发者。 阅读详情

相关推荐

开放平台 - 互动玩法演进之路

随着直播业务和用户规模日益壮大,如何丰富直播间内容、增强直播间内用户互动效果,提升营收数据变得更加关键。

bilibili_TC的博客 1738

Leetcode Repeated DNA Sequences

Leetcode Repeated DNA Sequences

coderhuhy的专栏 4012

OKCC呼叫中心部署实战指南:从零搭建高效外呼系统

本文提供OKCC呼叫中心系统的完整部署实战指南,从服务器选型、操作系统准备到详细安装步骤和性能优化,帮助企业从零搭建高效外呼系统。重点介绍FreeSWITCH核心组件的安装配置技巧,以及常见问题排查方法,助力企业提升客户服务效率。

weixin_29275257的博客 163

leetcode 187: Repeated DNA Sequences

Total Accepted: 1161 Total Submissions: 6887 All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes usef

西施豆腐渣 6033

UQLab——其他概率分布随机变量转换标准Gaussian分布

1、使用UQLab将其他类型的随机变量转换成标准Gaussian分布; 2、使用科学计数法输出样本,方便后续ANSYS的调用分析; 3、基于MC的可靠度分析。 原随机变量分布类型: % 调用UQLab进行采样 clc clear uqlab %% Specify these distributions as a UQLab INPUT object: PriorOpts.Marginals(1...

ikhui7的博客 3013

工业质检封神!YOLOv8实战金属表面缺陷检测,自建数据集mAP突破95%

本文详细介绍了基于YOLOv8的金属表面缺陷检测实战方案。针对工业质检中的光照不均、纹理复杂、小样本等挑战,作者构建了12000张图像的数据集,提出针对性数据增强策略和两阶段训练方法。通过优化损失函数、调整超参数等技术手段,最终在测试集上达到95.1%的mAP@0.5,检测速度32FPS。相比传统方法,该方案在精度和鲁棒性上均有显著提升,为工业视觉质检提供了可复现的落地解决方案。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 427

[leetcode] Repeated DNA Sequences

题目链接https://leetcode.com/problems/repeated-dna-sequences/ 题意:寻找出现1次以上的长度为10的基因片段,例如: 需要特别注意的是:所有基因均由 A, C, G, T 四种核苷酸组成。 看到题目,最先想到的是提取所有的长度为10的片段,放入map中,map的key为长度为10的片段,value为key出现的起始位置。提交之

曲径通幽处 464

TI单芯片毫米波雷达1642demo代码走读(一)

今天我们来实际看下代码。 首先使用CCS软件导入demo工程,工程有两个,一个是ARM的工程,工程名是mmw_mss_16xx;另一个是DSP的工程,工程名为mmw_dss_16xx。我们将这两个工程的主函数打开,分别位于mss_main.c和dss_main.c文件中。 先看mss的主函数,代码如下。我为每行代码都加了中文注释和自己的理解。 int main (void) { Task_Params taskPara...

1万+

Repeated DNA Sequences [leetcode]

All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA. Wri

Parrot的专栏 1417

RV1126笔记二十七:MetaRTC6移植

MetaRTC6移植

6038

【Zephyr存储专题】09_LittleFs文件系统操作

本文档旨在为开发者介绍Zephyr下Littlef's文件系统相关配置使用指南

zero的博客 3246

LeetCode 187. Repeated DNA Sequences

LeetCode 187. Repeated DNA Sequences 问题来源LeetCode187 Repeated DNA Sequences 问题描述 All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: “ACGAATTCCG”. When studyi

yanqinghe123的专栏 474

人工智能技术基础系列之:迁移学习

作者:禅与计算机程序设计艺术 1.背景介绍 随着深度学习和神经网络的快速发展,越来越多的应用场景需要处理大量的数据和复杂的任务。然而,由于计算资源、存储空间等条件的限制,传统的人工智能方法往往不能满足实际需求。因此,为了提高效率和降低成本,研究人员提出了迁移学习的概念。本篇文章将详细介绍迁移学习的基

AI天才研究院 695

Leetcode 187 Repeated DNA Sequences 重复出现的DNA序列

编写一个程序来找到一个DNA分子中出现次数超过一次的长度为10的子序列(子串)。Tags: Hash Table, Bit Manipulation

(ง •̀_•́)ง 962

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

【Leetcode】Repeated DNA Sequences

题目链接:https://leetcode.com/problems/repeated-dna-sequences/题目: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: “ACGAATTCCG”. When studying DNA, it is sometim

业精于勤,荒于嬉 3197

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

LeetCode Repeated DNA Sequences

LeetCode Repeated DNA Sequences All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repe

FightForProgrammer的专栏 831

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

[leetcode] 187. Repeated DNA Sequences

Description All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: “ACGAATTCCG”. When studying DNA, it is sometimes useful to identify repeated sequences within the...

Learning from the mistakes 206

Leetcode 187 Repeated DNA Sequences

Leetcode 187 Repeated DNA Sequences题目思路代码优化 题目 All DNA is composed of a series of nucleotides abbreviated as ‘A’, ‘C’, ‘G’, and ‘T’, for example: “ACGAATTCCG”. When studying DNA, it is sometimes useful to identify repeated sequences within the DNA. Write a

weixin_43796689的博客 177

[LeetCode]Repeated DNA Sequences

All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA. Wri

大力拜 841

LeetCode-Repeated DNA Sequences

题目链接:https://leetcode.com/problems/repeated-dna-sequences/ All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is someti

vanish_dust 569

leetcode之 Repeated DNA Sequences

Total Accepted: 2932 Total Submissions: 16668All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: “ACGAATTCCG”. When studying DNA, it is sometimes useful to identi

TO TOP CODER 698

Leetcode: Repeated DNA Sequences

All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA. Write

YMHH的专栏 430

[LeetCode] Repeated DNA Sequences

All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA. Write...

weixin_34130389的博客 74

187. Repeated DNA Sequences**

187. Repeated DNA Sequences** https://leetcode.com/problems/repeated-dna-sequences/ 题目描述 All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When s...

珍妮的选择的博客 278
上一篇: LeetCode || Subsets
下一篇: LeetCode- Bit Manipulation LeetCode总结(1) —— 位运算
xuxumoi
博客等级 码龄16年 16粉丝 151原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值