Skip to content

Commit

Permalink
Add C# solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
hellomrsun committed Oct 17, 2020
1 parent 9bb31e9 commit 8b8e045
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class Solution {
public IList<string> FindRepeatedDnaSequences(string s) {
if(s == null || s.Length == 0) return new List<string>();
var seen = new HashSet<string>();
var repeated = new HashSet<string>();
for(int i=0; i<s.Length-9; i++){
string curr = s.Substring(i, 10);
if(!seen.Add(curr)){
repeated.Add(curr);
}
}
return new List<string>(repeated);
}
}

0 comments on commit 8b8e045

Please sign in to comment.