cswork / OA打开练习工作台

AmazonOA #238

Get Redundant Substrings

估计中等评测数据准备中,可先阅读题面

考点(AI 标注)前缀和区间哈希计数

Data analysts at Amazon are building a utility to identify redundant words in advertisements. They define a string as redundant if the length of the string, |word| = a * V + b * C, where a and b are given integers and V and C are the numbers of vowels and consonants in the string word. Given a string word, and two integers, a, and b, find the number of redundant substrings of word. Note: A substring is a contiguous group of 0 or more characters in a string. For example- "bcb" is a substring of "abcba", while "bba" is not. Function Description Complete the function getRedundantSubstrings in the editor below. Returns int: the number of redundant substrings

Constraints

  • 1 ≤ |word| ≤ 10⁵
  • -10³ ≤ a ≤ 10³
  • -10³ ≤ b ≤ 10³
  • word contains lowercase English letters, [a-z].