CS-OA cs-vo Faang

Welcome to TikTok AMS Grad Assessment 2025 Start-10-14 Aug(Generic) – OA代写 – 面试代面 – 代面试

近期的tiktok OA来袭,目前确认题库都一样,限时110分钟,其中5道选择题,2道算法题,今天给大家揭秘2道算法题。

The recent TikTok Online Assessment (OA) is here, and it's confirmed that the question pool remains the same. You have 110 minutes to complete it, which includes 5 multiple-choice questions and 2 algorithm problems. Today, I'm going to reveal the 2 algorithm problems for you.

TikTok Metrics Analysis

Bytedance, renowned for its innovative products like TikTok, is expanding its financial analytics capabilities to offer more comprehensive insights for its creators and partners. The task is to optimize a data processing pipeline for TikTok's financial analytics platform. The objective is to enhance the module to efficiently identify the longest 'good subarray' of financial metrics meeting a specific criterion.

Given an array financialMetrics of size n, where each element represents a numerical financial metric, and a threshold value limit, the goal is to find the maximum length of a non-empty consecutive sequence of data points in financialMetrics that satisfies the following condition:

  • Each data point in the sequence must be greater than (limit / length of the sequence). This sequence is termed a 'good subarray' for analysis. If there is no 'good subarray' in the dataset, the function should return -1.

Example

n = 5
limit = 6
financialMetrics = [1, 3, 4, 3, 1]

Let's observe all the subarrays of financialMetrics.

Analysis of all Subarrays

SubarrayComparisonEvaluation
[1]1 < (6/1=6)Not a good subarray
[3]3 < (6/1=6)Not a good subarray
[4]4 < (6/1=6)Not a good subarray
[3]3 < (6/1=6)Not a good subarray
[1]1 < (6/1=6)Not a good subarray
[1, 3]1 < (6/2=3)Not a good subarray
[3, 4]3 < (6/2=3)Not a good subarray
[4, 3]4 < (6/2=3)Not a good subarray
[3, 1]3 < (6/2=3)Not a good subarray
[1, 3, 4]1 < (6/3=2)Not a good subarray
[3, 4, 3]3 < (6/3=2)Not a good subarray
[4, 3, 1]4 < (6/3=2)Not a good subarray
[3, 1]3 < (6/2=3)Not a good subarray
[1, 3, 4, 3, 1]1 < (6/5=1.2)Not a good subarray

Thus, the maximum length of a good subarray is 3 and the good subarray is [3,4,3].

Function Description

Complete the function getMaxGoodSubarrayLength in the editor. getMaxGoodSubarrayLength has the following parameter:

  • int limit
  • int financialMetrics[n]: an array of length n

Returns

  • int: the maximum length of a good subarray of financialMetrics.

Constraints

  • 1 ≤ n ≤ 10^5
  • 1 ≤ financialMetrics[i] ≤ 10^9
  • 1 ≤ limit ≤ 10^9

Input Format For Custom Testing

Sample Input For Custom Testing
6
6
1 3 4 3 1

在这道题目中,你需要找到满足条件的最长连续子数组。关键在于理解“良好子数组”的定义——子数组中每个元素的值都必须大于 limit 除以子数组的长度。你可以遍历数组,计算每个子数组是否符合条件,并记录符合条件的最大长度。

In this problem, you need to find the longest consecutive subarray that meets the condition. The key is to understand the definition of a "good subarray"—where each element in the subarray must be greater than the limit divided by the length of the subarray. You can iterate through the array, check if each subarray meets the criteria, and keep track of the maximum length that satisfies the condition.

Optimizing TikTok Collectible Packs

ByteDance has launched a new feature on TikTok called "TikTok Collectibles," where users can collect and trade digital cards featuring popular TikTok creators. Each creator has different categories of cards, such as rare cards for the most followed creators, special edition cards with unique designs, and interactive cards that come with exclusive video content.

ByteDance wants to create a number of collectible packs, each containing equal numbers of each type of card. To achieve this, they need to add more cards to ensure each type can be evenly distributed across the packs.
Given the current inventory of each category of cards as an integer array cardTypes of size n, determine the minimum number of additional cards needed so that they can create more than one pack with an equal type distribution.

Example

n = 5
cardTypes = [4, 7, 5, 11, 15]

In order to make 2 matching packets, the following numbers of additional cards of each type must be added: [0, 1, 1, 1, 1]. This sums to 4 additional cards. The numbers of cards are [4, 8, 6, 12, 16] and they can be divided evenly among 2 packets.
If 3 packets are created, an additional [2, 2, 1, 1, 0] cards are needed, sum = 6 items. This yields quantities [6, 9, 6, 12, 15]. Any number of packets ≥ 2 can be created, but creating 2 packets requires the minimum number of additional cards.

Function Description

Complete the function cardPackets in the editor below.

cardPackets has the following parameter(s):

  • int cardTypes[n]: the quantity available of card type

Returns

  • int: the minimum number of additional cards to add

Constraints

  • 1 ≤ n ≤ 10^5
  • 1 ≤ cardTypes[i] ≤ 500

Input Format For Custom Testing

Sample Input For Custom Testing
5
3
8
7
6
4

Sample Output

2

Explanation

For 2 packets add: [1, 0, 1, 0, 0] (2 cards) to get [4, 8, 8, 6, 4].

For 3 add [0, 1, 2, 0, 2] (5 cards) to get [3, 9, 9, 6, 6].

Any number of packets ≥ 2 can be created, but making 2 packets requires the minimum number of additional cards.

Sample Case 1

Sample Input For Custom Testing
6
3
9
7
6
5
2

Sample Output

4

Explanation

To make 2 packets, add [1, 1, 1, 0, 1, 0] (4 additional cards) to get [4, 10, 8, 6, 6, 4].

For 3 packets, add [0, 0, 2, 0, 1, 1] (4 additional cards) to get [3, 9, 9, 6, 6, 3].

Either of these solutions is minimal.

这道题目要求我们在现有卡片的基础上,最小化添加卡片的数量,使得这些卡片可以均匀地分配到多个包中。关键在于找到一个分配的最小模数,使得每种类型的卡片数量能够整除该模数。通过遍历可能的模数值,计算每种情况下需要添加的最小卡片数量,并选择最小值作为最终答案。

This problem requires minimizing the number of additional cards needed to evenly distribute existing cards into multiple packs. The key is to find the smallest divisor that allows the quantities of each card type to be evenly divisible. By iterating through possible divisor values, calculate the minimum number of additional cards needed for each case, and choose the smallest total as the final answer.

If you are also worried about Tiktok's Online Assessment (OA) or simply don't want to go through the hassle of completing these tests on your own, we offer professional services to help you pass with flying colors. Our team has extensive experience and can provide you with one-on-one guidance and comprehensive solutions. Contact us and let's achieve success together!

我们提供面试辅助和 OA 代写服务,助您进入梦想大厂,欢迎随时咨询我

One thought on “Welcome to TikTok AMS Grad Assessment 2025 Start-10-14 Aug(Generic) – OA代写 – 面试代面 – 代面试

  1. Hey,
    Can you please share the one for [TikTok] AMS Grad Assessment 2025 Start – 10 – 14 Aug (Front-end)??

Leave a Reply

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