File tree 2 files changed +22
-0
lines changed
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 28
28
29
29
1 . [ Rotate Array] ( https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/561/week-3-october-15th-october-21st/3496/ ) ➡️ [ CPP Solution] ( Week3/rotate.cpp )
30
30
2 . [ Search a 2D Matrix] ( https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/561/week-3-october-15th-october-21st/3497/ ) ➡️ [ CPP Solution] ( Week3/searchMatrix.cpp )
31
+ 3 . [ Repeated DNA Sequences] ( https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/561/week-3-october-15th-october-21st/3498/ ) ➡️ [ CPP Solution] ( Week3/findRepeatedDnaSequences.cpp )
31
32
32
33
## Week 4 🚧
33
34
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public:
3
+ vector<string> findRepeatedDnaSequences (string s) {
4
+ unordered_map<string, int > seen;
5
+ int n = s.size ();
6
+ vector<string> res;
7
+
8
+ if (n < 10 ) return {};
9
+
10
+ for (int i = 0 ; i + 10 <= n; ++i) {
11
+ string sub = s.substr (i, 10 );
12
+ seen[sub]++;
13
+
14
+ if (seen[sub] == 2 ) {
15
+ res.push_back (sub);
16
+ }
17
+ }
18
+
19
+ return res;
20
+ }
21
+ };
You can’t perform that action at this time.
0 commit comments