FastPrepFastPrep
Problem Brief

Match and Swipe

OA

Several TT creators are participating in a trending challenge called Match-and-Swipe. There are k creators, labeled from 1 to k, and they start with a shared video sequence represented by the string videoSequence.

Here is how the challenge works: each creator takes turns (creator 1 goes first, followed by creator 2, and so on, cycling back to creator 1 after cretor k's turn). On each turn, a creator can remove any two consecutive matching clips (represented by matching letters in videoSequence) and merge the remaining parts of the sequence back together.

The game continues until there are no consecutive matching clips left. If a creator cannot make a move, they lose, and the challenge ends. Given that all creators play stratigically, determine the number of the creator who will lose.

1Example 1

Input
videoSequence = "pzwoowz", k = 3
Output
1
Explanation
Creator videoSequence 1 pzwoowz 2 pzwwz 3 pzz 4 p On each turn, the creator selects the highlighted pair. Creator 1 loses when there are no valid pairs left to remove. Return 1.
public int matchAndSwipe(String videoSequence, int k) {
  // write your code here
}
Input

videoSequence

"pzwoowz"

k

3

Output

1

Sign in to submit your solution.