Problem · String

TikTok Circular Clip Analysis

Learn this problem
MediumTiktokINTERNOA
See Tiktok hiring insights

Problem statement

The TikTok team is analyzing clips to measure their unique content strength. Given a string clip of length n consisting of only lowercase English characters, imagine the clip is circular, meaning after the n-th character, the sequence continues from the 1st character again.

Circular Nature: Since the clip is circular, you can form substrings that wrap around from the end of the string back to the beginning. For instance, with the string "yxz", valid substrings include "y","x","z","yx","xz","zy","yxz","xzy" and "zyx".

The "content strength" of a circular clip is determined by the number of unique substrings that consist of only consonants. Your task is to find the content strength of this circular clip.

Function

calculateContentStrength(clip: String) → int

Complete the function calculateContentStrength in the editor.

calculateContentStrength has the following parameter:

  1. string clip: the circular clip whose content strength has to be determined.

Returns

int: the content strength of the circular clip

Examples

Example 1

clip = "bac"return = 3
The different possible substrings of the circular clip are: ["b", "a", "c", "ba", "ac", "cb", "bac", "acb", "cba"]. The substrings that consist of only consonants are: ["b", "c", "cb"].

Constraints

🎶

More Tiktok problems

drafts saved locally
public int calculateContentStrength(String clip) {
  // write your code here
}
clip"bac"
expected3
checking account