Company: Corridor Platforms
Difficulty: medium
A Suffix Queries Problem Problem Description You're given a string S of length N , and you need to answer several queries about it. Each query supplies a string T . Among all suffixes of S that begin with T , find the lexicographically smallest one and report its length; if no suffix of S starts with T , report 0 for that query instead. Once every query has been answered, output the sum of all the individual results. Because that total can grow very large, report it modulo 10^9 + 7 . Complete the suffixQueries function in the editor below. It has the following parameters: S : A STRING representing the given string. query : A STRING ARRAY representing the array of strings for each query. The function must return an INTEGER denoting the sum of results of all the queries modulo 10^9 + 7 . Examples Example 1: Input: S = "mzadpoghyykht" query = ["yk"] Output: 4 Explanation: Here S is "mzadpoghyykht" and the query string T is "yk". The single suffix of S beginning with "yk" is "ykht" (starti