FastPrepMatch and Swipe
Problems/Match and Swipe

Match and Swipe

TikTok logoTikTok● MediumOA

Updated Sep 2026

QuestionFunctionExamples

Problem statement

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.

Function

matchAndSwipe(videoSequence: String, k: int) → int

Examples

Example 1

videoSequence = "pzwoowz"k = 3return = 1

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.

More TikTok interview questions

  • Center of the Largest Perfect X-ShapeOA · Seen Nov 2026
  • Count Subarrays Matching a Comparison PatternOA · Seen Nov 2026
  • Count Suffix Word PairsOA · Seen Nov 2026
  • Minimum Cost of Every K-Capable Model SetOA · Seen Nov 2026
  • Longest Substring Without Repeating CharactersPHONE SCREEN · Seen Oct 2026
  • Next Greater Indices and Maximum GapPHONE SCREEN · Seen Oct 2026
  • Count Subarrays with at Least K Equal-Fruit PairsOA · Seen Oct 2026
  • Shell Command Counts with History ReferencesOA · Seen Oct 2026
  • Product Minus Sum of DigitsOA · Seen Aug 2026
  • Count 2x2 Submatrices by Black CellsOA · Seen Aug 2026

Similar questions at other companies

  • Basic Calculator IITypeSafe AI · OA
  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Server Upgrade PlanningWells Fargo · OAWells Fargo interview questions
  • Task Scheduler with CooldownGoDaddy · OA
  • Minimize Adjacent Squared-Difference Cost with One InsertionMcKinsey & Company · OAMcKinsey & Company interview questions
  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Substring RemovalJP Morgan Chase · OAJP Morgan Chase interview questions
  • Minimum Values with Even Powers of TwoVisa · OAVisa interview questions
  • Minimize Adjacent Squared-Difference Cost with One InsertionMicrosoft · OAMicrosoft interview questions
  • Minimum Halvings for Alternating ParityIBM · OAIBM interview questions

TikTok interview experiences

  • TikTok AI Infra Intern LLM Round 2: 1 Experience
  • TikTok AI Infra Intern DeepSpeed Round: 1 Experience
  • TikTok AI Infra Intern Kernel Round: 1 Experience
  • TikTok AI Infra Intern Interviews, 3 Rounds: 1 Experience
  • TikTok AI Infra Intern Interview Timeline: 1 Experience
  • TikTok AI Infra Intern Onsite Round 2: 1 Experience
All TikTok interview questionsSee TikTok hiring insights
Saved
class Solution {
    public int matchAndSwipe(String videoSequence, int k) {
      // write your code here
    }

}
Checking account…