Microsoft | Round 1 | Better url match

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2023-05-19Added By Anonymous
Source: Link

Given a list of url regix that map to a particular url

eg:

/foo/bar/loo/moo/a/b/c/d

All these are valid regex check

answers= ["/foo*" , /foo/bar/*/moo/a/b/c/d , /foo/bar/loo/* /foo/bar/loo/moo/a/b/*/d]


Question

For a given url string (/foo/bar/loo/moo/a/b/c/d) and the answers list which is the best possible regex

Based on this condition

1.The position of * in the url . eg :/foo/bar/loo/* > /foo/bar/*
2.If condition 1. is same for any two urls , count of hoe many matching keys which are not *
3.eg: /foo/bar/loo/*/a/* < `/foo/bar/loo/*/a/b/c


Now the list can be around size 100 .

Comments