Description
Solutions
Submission
Amazon Review Score 🍅
🔥 FULLTIME

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.

Function Description

Complete the function findReviewScore in the editor.

findReviewScore has the following parameters:

  • review: a string
  • string prohibitedWords[n]: the prohibited words
  • Returns

  • int: the score of the review
  • Example 1:

    Input:  review = "GoodProductButScrapAfterWash", prohibitedWords = ["crap", "odpro"]
    Output: 15
    Explanation:
    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.

    Example 2:

    Input:  review = "FastDeliveryOkayProduct", prohibitedWords = ["eryoka", "yo", "eli"]
    Output: 11
    Explanation:
    The substring "OkayProduct" is the longest substring which does not contain a prohibited word. Its length is 11.

    Example 3:

    Input:  review = "ExtremeValueForMoney", prohibitedWords = ["tuper", "douche"]
    Output: 20
    Explanation:
    The review does not contain any prohibited word, so the longest substring is "ExtremeValueForMoney", length 20.
    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
    Thumbnail 0
    Thumbnail 1
    Thumbnail 2
    Testcase

    Result
    Case 1

    input:

    output: