regular expression match interviewbit solution
public class Solution {
public boolean isMatch(String s, String p) {
if(p.length() == 0)
return s.length() == 0;
//p's length 1 is special case
if(p.length() == 1 || p.charAt(1) != '*'){
if(s.length() < 1 || (p.charAt(0) != '.' && s.charAt(0) != p.charAt(0)))
return false;
return isMatch(s.substring(1), p.substring(1));
}else{
int len = s.length();
int i = -1;
while(i<len && (i < 0 || p.charAt(0) == '.' || p.charAt(0) == s.charAt(i))){
if(isMatch(s.substring(i+1), p.substring(2)))
return true;
i++;
}
return false;
}
}
}
Also in JavaScript:
- discord.js bot github
- select parent of elemt
- how to send authorization in header of HTTP GET using ajax
- discord.js get all members with role
- stop a video jquery
- jsx input change
- bootstrap in javascript
- js settimeout
- javascript format number with commas
- angular random number between 1 and 10
- import svg react
- js promiseStatus
- convert string to number javascript
- how to make vue app talk to backend on 8000
- react steam auth
- javascript group array of objects lodash
- redirect browser javascript
- javascript open in new window not tab
- javascript textcontent vs innertext
- prepen an element js
- localStorage
- jest tranform image
- javascript pluck from array of objects
- rest api with mongodb and nodejs