Tiktok | Phone | Minimum people to shout out a sentence

Each person is repeatedly shouting out a word "tiktok". Their sounds can overlap with each other, creating a combined sentence. Determine the minimum number of people required to produce a given sentence through their overlapping shouts.

One could assume the given sentence is valid, i.e., composed of several complete copies of "tiktok".

e.g.
Input: "tiktoktiktok"
Ouput: 1 --> one person shouts out "tiktok" twice.

Input: "tiktiktoktok"
Output: 2 --> at least two people required.

Input: "tiktiktoktiktoktok"
Output: 2 --> first person shouts out "tiktok" twice; second person shouts out once.


I proposed a greedy approach + state transition DP, but did not solve the problem correctly.

Comments (6)