Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Amazon is developing a string matching library. You are to develop a service that finds the longest substring that matches a given regex. More

 

Amazon is developing a string matching library. You are to develop a service that finds the longest substring that matches a given regex. More formally, you are given two strings, a text string text, and a regex expression regex. The string regex contains exactly one wildcard character(*). A wildcard character (*) matches any sequence of zero or more lowercase English characters. A regex matches some string if it is possible to replace the wildcard character with some sequence of characters such that the regex expression becomes equal to the string. No other character can be changed. For example, regex "abc*bcd" matches "abcbcd", "abcefgbcd" and "abccbcd" whereas it does not match the strings "abcbd", "abzbcd", "abcd". Return the length of the longest substring of text that matches the expression regex. Return -1 if there is no such substring. Note: A substring is a contiguous sequence of characters within a string Example Given text="hackerrank", regex = "ack*r" The following substrings match regex

Step by Step Solution

There are 3 Steps involved in it

Step: 1

It appears the image contains a programming problem description Lets tackle the problem stepbystep T... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Statistics For Business And Economics

Authors: Paul Newbold, William Carlson, Betty Thorne

8th Edition

0132745658, 978-0132745659

More Books

Students also viewed these Programming questions