[TikTok] OA 2025 Start – 06 Feb (Generic)

6. Changing Username

A TikTok user has a username represented by a string of lowercase English letters, username. The user wants to transform their username to explore possible variations. The user can perform the following operations on the username multiple times, in any order:

  • Replace an occurrence of "cc" with 'a'
  • Replace an occurrence of "dd" with 'b'

The user may also choose not to apply any operations, leaving the username unchanged.

Given the string username, determine the total number of distinct usernames that can be generated by applying these transformations. Since the result can be large, return the total count modulo 109+710^9+7.


Example

Input:

username = "ccc"

Possible Transformations:

  • "ccc" → "ac"
  • "ccc" → "ca"
  • "ccc" (No operation applied)

Output:

3

7. Playlist Partitioning

The TikTok platform stores content creators' videos in a distributed database, where each videoCategory[i] represents the number of videos available in the iᵗʰ content category.

To improve efficiency, the system needs to create some content playlists such that:

  • Each playlist contains exactly k distinct content categories.
  • Each video can only belong to one playlist.

Determine the maximum number of playlists that can be created while following these rules.


Example

Input:

k = 3, n = 4  
videoCategory = [1, 2, 2, 3]

Explanation:

Each playlist must include 2 videos from different categories. There are 4 different categories.

One optimal arrangement is:

  1. Playlist 1 gets videos from categories 2, 3, and 4. Remaining videos per category: [1, 1, 1, 2]
  2. Playlist 2 gets videos from categories 1, 2, and 4. Remaining videos per category: [0, 0, 1, 1]

Alternative choices were possible, but at most 2 playlists can be created.

Output:

2

我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。

We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

Leave a Reply

Your email address will not be published. Required fields are marked *