File tree 3 files changed +27
-0
lines changed
3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ Solutions from [LeetCode](https://leetcode.com) on Dart.
17
17
| 217. Contains Duplicate | [ Link] ( https://leetcode.com/problems/contains-duplicate/ ) | [ Link] ( ./lib/easy/contains_duplicate.dart ) |
18
18
| 226. Invert Binary Tree | [ Link] ( https://leetcode.com/problems/invert-binary-tree/ ) | [ Link] ( ./lib/easy/invert_binary_tree.dart ) |
19
19
| 342. Power of Four | [ Link] ( https://leetcode.com/problems/power-of-four/ ) | [ Link] ( ./lib/easy/power_of_four.dart ) |
20
+ | 392. Is Subsequence | [ Link] ( https://leetcode.com/problems/is-subsequence/ ) | [ Link] ( ./lib/easy/is_subsequence.dart ) |
20
21
| 414. Third Maximum Number | [ Link] ( https://leetcode.com/problems/third-maximum-number/ ) | [ Link] ( ./lib/easy/third_maximum_number.dart ) |
21
22
| 796. Rotate String | [ Link] ( https://leetcode.com/problems/rotate-string/ ) | [ Link] ( ./lib/easy/rotate_string.dart ) |
22
23
| 944. Delete Columns to Make Sorted | [ Link] ( https://leetcode.com/problems/delete-columns-to-make-sorted/ ) | [ Link] ( ./lib/easy/delete_columns_to_make_sorted.dart ) |
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ bool isSubsequence (String s, String t) {
3
+ var sP = 0 ;
4
+ var tP = 0 ;
5
+ while (sP != s.length && tP != t.length) {
6
+ if (s[sP] == t[tP]) {
7
+ sP++ ;
8
+ }
9
+ tP++ ;
10
+ }
11
+ return sP == s.length;
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ import 'package:leetcode_dart/easy/is_subsequence.dart' ;
2
+ import 'package:test/test.dart' ;
3
+
4
+ void main () {
5
+ group (
6
+ 'Example tests' ,
7
+ () {
8
+ final isSub = Solution ();
9
+ test ('true' , () => isSub.isSubsequence ('abc' , 'ahbgdc' ));
10
+ test ('false' , () => isSub.isSubsequence ('axc' , 'ahbgdc' ));
11
+ },
12
+ );
13
+ }
You can’t perform that action at this time.
0 commit comments