Snowflake sde oa –Snowflake -OA代写 -OA ghost writing -一亩三分地 -OA help

String Patterns

Given the length of a word (wordLen) and the maximum number of consecutive vowels that it can contain (maxVowels), determine how many unique words can be generated. Words will consist of English alphabetic letters a through z only. Vowels are v: {a, e, i, o, u}; consonants are c: the remaining 21 letters. In the explanations, v and c represent vowels and consonants.

Example:

wordLen = 1
maxVowels = 1

Patterns: {v, c}
That means there are 26 possibilities, one for each letter in the alphabet.

wordLen = 4
maxVowels = 1

Patterns: {cccc, vccc, cvcc, ccvc, cccv, vcvc, cvvc, cvcv, vccv}
There are 412,776 possibilities -- see below:

(21 * 21 * 21 * 21) = 194481
(5 * 21 * 21 * 21) + (21 * 5 * 21 * 21) + (21 * 21 * 5 * 21) + (21 * 21 * 21 * 5) = 4 * 46305 = 185220
(5 * 21 * 5 * 21) + (21 * 5 * 21 * 5) + (5 * 21 * 21 * 5) = 3 * 11025 = 33075

2. Vowel Substring

Given a string of lowercase letters in the range ascii['a'-'z'], determine the number of substrings that can be created where every letter is a vowel and every vowel is present at least once. The vowels are ['a', 'e', 'i', 'o', 'u']. A substring is a contiguous group of characters in the string.

Example
s = 'aeioaexaaeoiou'

There is a substring to the left that is made of vowels, 'aeioae' which is followed by an 'x'. Since 'x' is not a vowel, it cannot be included in the substring, and this substring does not contain all of the vowels. It is not a qualifying substring. Moving to the right, there are four substrings that do qualify: 'aaeoiou', 'aaeoiu', 'aeoiou', and 'aeoiu'.

Function Description
Complete the function vowelSubstring in the editor below.

vowelSubstring has the following parameter(s):

  • string s: a string

Returns

  • int: the number of substrings that consist of vowels only ('a', 'e', 'i', 'o', 'u') where every vowel appears at least once

Constraints

  • 1 ≤ size_of(s) ≤ 10⁵
  • s[i] ∈ ascii['a'-'z'] (where 0 ≤ i < size_of(s))

CSOAhelp长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。

CSOAhelp consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

Leave a Reply

Your email address will not be published. Required fields are marked *