Wonder Value

You are given a string s consisting only of the characters v and o.

Two consecutive v's (vv) can be interpreted as a single w.

Your task is to calculate the "Wonder Value" of the string, which is the total number of wow subsequences that can be formed.

A subsequence does not need to be contiguous.

Example 1:

Input: s = "vvvovvv"

Output: 4

Explanation:

A "w" is formed by two consecutive 'v's → "vv".

Possible "w" on the left of 'o': vvv → gives 2 possible "w" pairs

Possible "w" on the right of 'o': vvv → gives 2 possible "w" pairs

hence wow subsequences = 4

Example 2:

Input: s = "vov"

Output: 0

Explanation:

A "w" requires two consecutive 'v's ("vv").

The string has no "vv", so no "w" can be formed.

Therefore the wow factor is 0.

Now Your Turn!

Pick the correct output for the given input

Input: s = "vvvvovvv"

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= |s| <= 106

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

0
class Solution {
public:
long long wonderValue(string s) {
// Write your code here
return 0;
}
};
Test Case

Input:

S