Answered step by step
Verified Expert Solution
Link Copied!

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, 15.
Function Description
Complete the function findReviewScore in the editor below.
findReviewScore has the following parameters:
review: a string
string prohibitedWords[n]: the prohibited words
Returns
int: the score of the review
Constraints
1<=| review |<=105
1<= n <=10
1<=| prohibitedWords[i]|<=10
review consists of English letters, both lowercase and uppercase
prohibitedWords[i] consists of lowercase English letters
Input Format For Custom Testing Sample Case 0
Sample Input For Custom Testing
STDIN FUNCTION
-------------
FastDeliveryOkayProduct -> review = "FastDeliveryOkayProduct"
3-> n =3
eryoka -> prohibitedWords =["eryoka","yo", "eli"]
yo
eli
Sample Output
11
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

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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions