{"id":24619414,"url":"https://github.com/emahtab/repeated-dna-sequences","last_synced_at":"2025-03-18T23:20:12.380Z","repository":{"id":273482681,"uuid":"869011228","full_name":"eMahtab/repeated-dna-sequences","owner":"eMahtab","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-21T06:39:46.000Z","size":2,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-21T07:27:44.148Z","etag":null,"topics":["leetcode","repeated-substring"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eMahtab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-07T15:08:50.000Z","updated_at":"2025-01-21T06:39:49.000Z","dependencies_parsed_at":"2025-01-21T07:37:46.640Z","dependency_job_id":null,"html_url":"https://github.com/eMahtab/repeated-dna-sequences","commit_stats":null,"previous_names":["emahtab/repeated-dna-sequences"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Frepeated-dna-sequences","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Frepeated-dna-sequences/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Frepeated-dna-sequences/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Frepeated-dna-sequences/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eMahtab","download_url":"https://codeload.github.com/eMahtab/repeated-dna-sequences/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244320429,"owners_count":20434092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["leetcode","repeated-substring"],"created_at":"2025-01-25T00:52:27.678Z","updated_at":"2025-03-18T23:20:12.356Z","avatar_url":"https://github.com/eMahtab.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Repeated DNA Sequences\n## https://leetcode.com/problems/repeated-dna-sequences\n\nThe DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'.\n\nFor example, \"ACGAATTCCG\" is a DNA sequence.\nWhen studying DNA, it is useful to identify repeated sequences within the DNA.\n\nGiven a string s that represents a DNA sequence, return all the 10-letter-long sequences (substrings) that occur more than once in a DNA molecule. You may return the answer in any order.\n\n```java\nExample 1:\n\nInput: s = \"AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT\"\nOutput: [\"AAAAACCCCC\",\"CCCCCAAAAA\"]\n\nExample 2:\n\nInput: s = \"AAAAAAAAAAAAA\"\nOutput: [\"AAAAAAAAAA\"]\n``` \n\n### Constraints:\n\n1. 1 \u003c= s.length \u003c= 105\n2. s[i] is either 'A', 'C', 'G', or 'T'.\n\n## Implementation 1 :\n```java\nclass Solution {\n    public List\u003cString\u003e findRepeatedDnaSequences(String s) {\n        List\u003cString\u003e result = new ArrayList\u003c\u003e();\n        if(s.length() \u003c= 10)\n          return result;\n        Map\u003cString,Integer\u003e map = new HashMap\u003c\u003e();  \n        for(int i = 0; i \u003c= s.length() - 10; i++) {\n            String substr = s.substring(i, i+10);\n            int occurrence = map.getOrDefault(substr, 0);\n            map.put(substr, occurrence + 1); \n        }\n        for(String str : map.keySet()) {\n            if(map.get(str) \u003e 1)\n             result.add(str);\n        }\n        return result;  \n    }\n}\n```\n\n## Implementation 1a :\n```java\nclass Solution {\n    public List\u003cString\u003e findRepeatedDnaSequences(String s) {\n        if(s == null || s.length() \u003c 11)\n          return new ArrayList\u003c\u003e();\n\n        Map\u003cString,Integer\u003e map = new HashMap\u003c\u003e();\n        map.put(s.substring(0, 10), 1);\n        int left = 1;\n\n        for(int i = 10; i \u003c s.length(); i++) {\n            String str = s.substring(left, i+1);\n            int occurrences = map.getOrDefault(str, 0);\n            map.put(str, occurrences+1);\n            left++;\n        }  \n        return map.entrySet()\n                  .stream()\n                  .filter(entry -\u003e entry.getValue() \u003e 1)\n                  .map(entry -\u003e entry.getKey())\n                  .collect(Collectors.toList());\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Frepeated-dna-sequences","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femahtab%2Frepeated-dna-sequences","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Frepeated-dna-sequences/lists"}