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 words from the prohibited list, ignoring the case.
Given a review and a list of prohibited string, calculate the review score.
Complete the function findReviewScore in the editor.
findReviewScore has the following parameters:
review: a stringstring prohibitedWords[n]: the prohibited wordsReturns
int: the score of the reviewExamples
01 Β· Example 1
review = "GoodProductButScrapAfterWash" prohibitedWords = ["crap", "odpro"] return = 15
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.
02 Β· Example 2
review = "FastDeliveryOkayProduct" prohibitedWords = ["eryoka", "yo", "eli"] return = 11

The substring "OkayProduct" is the longest substring which does not contain a prohibited word.
Its length is 11.
03 Β· Example 3
review = "ExtremeValueForMoney" prohibitedWords = ["tuper", "douche"] return = 20
The review does not contain any prohibited word, so the longest substring is "ExtremeValueForMoney", length 20.
Constraints
1 <= |review| <= 1051 <= n <= 101 <= prohibitedWords[i] <= 10review consists of English letters, both lowercase and uppercaseprohibitedWords[i] consists of lowercase English lettersMore Amazon problems
- Count Promotional PeriodsOA Β· Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Get Minimum AmountOA Β· Seen Jun 2026
- Find Minimum CostOA Β· Seen Jun 2026
- Get Smallest Base SegmentOA Β· Seen Jun 2026
- Maximum Non-Adjacent House ValueONSITE INTERVIEW Β· Seen Jun 2026
- Running Delivery Time MediansONSITE INTERVIEW Β· Seen Jun 2026
- Select Least Resource TasksOA Β· Seen Jun 2026
public int amazonReviewScore(String review, String[] prohibitedWords) {
// write your code here
}
review"GoodProductButScrapAfterWash"
prohibitedWords["crap", "odpro"]
expected15
sign in to submit