commit b66efa29831c3307701382f89fba4812b7aa9ce8 parent 9bf90b72f4588a291b2d7860ae605bfd04fcee53 Author: AndrewLockVI <andrewlaack1@gmail.com> Date: Mon, 8 May 2023 07:29:22 -0500 Completed regular expression matching problem using dart Diffstat:
| A | regular-expression-matching/regular-expression-matching.dart | | | 12 | ++++++++++++ |
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/regular-expression-matching/regular-expression-matching.dart b/regular-expression-matching/regular-expression-matching.dart @@ -0,0 +1,12 @@ +//Based on the regexp p return true if s is a match of it. +//I used the built in regexp checker for dart because work smarter +//not harder. The time complexity of this is O(n) where n is the length +//of the string. +//Time: 654ms Beats: 35% +//Memory: 162.9MB Beats: 50% +class Solution { + bool isMatch(String s, String p) { + RegExp regex = RegExp('^$p\$'); + return regex.hasMatch(s); + } +}