Uber | Phone screen | String pattern matching

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2016-09-13Added By Anonymous
Source: Link

Company: Uber
Role: unknown
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

The matching should cover the entire input string (not partial).
The function prototype should be:

bool isMatch(String str, String patter)
Some examples:
isMatch("aa","a") → false
isMatch("aa","aa") → true
isMatch("aaa","aa") → false
isMatch("aa","a{1,3}") → true
isMatch("aaa","a{1,3}") → false
isMatch("ab","a{1,3}b{1,3}") → true
isMatch("abc","a{1,3}b{1,3}c") → true
isMatch("abbc","a{1,3}b{1,2}c") → false
isMatch("acbac","a{1,3}b{1,3}c") → false
isMatch("abcc","a{1,3}b{1,3}cc{1,3}") → true

Comments