Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Amazon allows customers to add reviews for the products they bought from their store. The review must follow Amazon's community guidelines in order to be
Amazon allows customers to add reviews for the products they bought from their store. The review must follow Amazon's community guidelines in order to be published.
Suppose that Amazon has marked n strings that are prohibited in reviews. They assign a score to each review that denotes how well it follows the guidelines. The score of a review is defined as the longest contiguous substring of the review which does not contain any string among the list of n prohibited strings. A string contains a prohibited word if it has a contiguous substring that matches a word from the prohibited list, ignoring the case.
Given a review and a list of prohibited strings, calculate the review score.
Example
review "GoodProductButScrapAfterWash"
prohibitedWords crap "odpro"
Some of the substrings that do not contain a prohibited word are:
ProductBut
rapAfterWash
dProductButScu
Wash
The longest substring is "dProductButScra", return its length,
Function Description
Complete the function findReviewScore in the editor below.
findReviewScore has the following parameters:
review: a string
string prohibitedWordsn: the prohibited words
Returns
int: the score of the review
Constraints
review
n
prohibitedWordsi
review consists of English letters, both lowercase and uppercase
prohibitedWordsi consists of lowercase English letters
Input Format For Custom Testing Sample Case
Sample Input For Custom Testing
STDIN FUNCTION
FastDeliveryOkayProduct review "FastDeliveryOkayProduct"
n
eryoka prohibitedWords eryokayo "eli"
yo
eli
Sample Output
Please write c code for the above and use older version of c With time and space complexity
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started