国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

187. Repeated DNA Sequences

2019-11-11 02:35:07
字體:
來源:轉載
供稿:網友

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”].

一刷ac 解題思路:遍歷字符串,按長度10截取字符串,判斷截取的子串是否截取過,分別將遍歷的結果和重復的串放在兩個set中,返回結果。

public class Solution { public List<String> findRepeatedDnaSequences(String s) { Set seen = new HashSet(), repeated = new HashSet(); for (int i = 0; i + 9 < s.length(); i++) { String ten = s.substring(i, i + 10); if (seen.contains(ten)){ repeated.add(ten); }else seen.add(ten); } return new ArrayList(repeated); }}
上一篇:27.Yii App應用

下一篇:Maven學習筆記

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 鄂伦春自治旗| 会同县| 开封县| 邓州市| 吴堡县| 大足县| 德州市| 长乐市| 监利县| 雷山县| 台南市| 临江市| 龙江县| 廊坊市| 镇宁| 龙南县| 三门峡市| 盘山县| 小金县| 周宁县| 时尚| 略阳县| 岳阳县| 彭泽县| 扶沟县| 凤城市| 颍上县| 嘉义县| 万全县| 玉林市| 南城县| 金阳县| 黄梅县| 翁牛特旗| 沂水县| 齐齐哈尔市| 凤阳县| 子洲县| 白银市| 北碚区| 阿拉善左旗|