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 prohibited words, ignoring case. A string contains a prohibited word if it has a contiguous substring that matches a word from the prohibited list, ignoring case.
Given a review and a list of prohibited words, calculate the review score.
Complete the function amazonReviewScore in the editor.
amazonReviewScore has the following parameters:
review: a stringprohibitedWords[n]: the prohibited words
Returns
int: the score of the review
review = "GoodProductButScrapAfterWash" prohibitedWords = ["crap", "odpro"] return = 15
Matching is case-insensitive. The prohibited words are "crap" and "odpro".
The substring "dProductButScra" does not contain either prohibited word and has length 15. Any longer substring would contain either "odpro" or "crap". Therefore the score is 15.
review = "FastDeliveryOkayProduct" prohibitedWords = ["eryoka", "yo", "eli"] return = 11

review = "ExtremeValueForMoney" prohibitedWords = ["tuper", "douche"] return = 20
1 <= |review| <= 1051 <= n <= 101 <= |prohibitedWords[i]| <= 10review consists of English letters, both lowercase and uppercaseprohibitedWords[i] consists of lowercase English letters
- Minimum Operations to Make the Integer ZeroSeen Jun 2026
- Create Array Generator ServiceSeen Jun 2026
- Minimum Merge ConflictsOA Β· Seen Jun 2026
- Get Minimum AmountOA Β· Seen Jun 2026
- Drone Delivery RouteOA Β· Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Minimum Operations to Make Array ValidOA Β· Seen Jun 2026
- Sort Bug Report FrequenciesOA Β· Seen Jun 2026
public int amazonReviewScore(String review, String[] prohibitedWords) {
// write your code here
}