本周的tiktok OA 真题大揭秘啦，Tiktok发的OA非常规律，每2周一次，全原创题，所有人有着相同的题库。本周是限时110分7道题目，其中5道选择题，2道算法题。如果本周错过了，可以联系我们预约下周的OA代写。

**1. TikTok Video Title Manipulation**

TikTok is developing a video management system where users can upload videos with titles. The system needs to identify and correct any titles that contain unnecessary leading or trailing spaces. Your task is to write a function that ensures the video titles are properly formatted by removing these spaces.

Which of the following pseudocode snippets correctly removes leading and trailing spaces from a given video title?

Pick ONE option:

`function trimSpaces(title): start = 0 end = length(title) - 1 while start <= end and title[start] == ' ': start = start + 1 while end >= start and title[end] == ' ': end = end - 1 return substring(title, start, end - start + 1)`

`function trimSpaces(title): return substring(title, indexOfFirstNonSpace(title), indexOfLastNonSpace(title))`

`function trimSpaces(title): return replace(title, ' ', '')`

`function trimSpaces(title): start = 0 end = length(title) - 1 while start <= end and title[start] == ' ': start = start + 1 while end >= start and title[end] == ' ': end = end - 1 return title[start:end + 1]`

**2. TikTok Engagement Heatmap**

TikTok wants to create a heatmap of user engagement over different times of the day for a week, stored in a 2D array `engagements`

where rows represent days and columns represent hours. Write a pseudo-code to find the total engagement for each day.

Pick ONE option:

`for i = 0 to 6 totalEngagement = 0 for j = 0 to 23 totalEngagement = totalEngagement + engagements[i][j] print(totalEngagement)`

`for j = 0 to 23 totalEngagement = 0 for i = 0 to 6 totalEngagement = totalEngagement + engagements[i][j] print(totalEngagement)`

`for i = 0 to 6 totalEngagement = 0 for j = 0 to 23 totalEngagement = totalEngagement - engagements[i][j] print(totalEngagement)`

`for j = 0 to 23 totalEngagement = 0 for i = 0 to 6 totalEngagement = totalEngagement - engagements[i][j] print(totalEngagement)`

**3. TikTok Trending Videos**

TikTok uses a min-heap to maintain the top 10 trending videos. Write a pseudo-code to insert a new video with its popularity score into the min-heap.

Pick ONE option:

`if heap.size() < 10 heap.insert(video) else if video.popularity > heap.peek().popularity heap.extractMin() heap.insert(video)`

`if heap.size() < 10 heap.insert(video) else if video.popularity < heap.peek().popularity heap.extractMin() heap.insert(video)`

`if heap.size() > 10 heap.insert(video) else if video.popularity > heap.peek().popularity heap.extractMin() heap.insert(video)`

`if heap.size() < 10 heap.insert(video) else if video.popularity > heap.peek().popularity heap.extractMin() heap.insert(video)`

**4. TikTok Video Sorting**

TikTok needs to sort videos by their upload time. Write a pseudo-code to sort an array of videos using quicksort.

Pick ONE option:

`function quickSort(arr, low, high) if low < high pi = partition(arr, low, high) quickSort(arr, low, pi - 1) quickSort(arr, pi + 1, high)`

`function partition(arr, low, high) pivot = arr[high] i = low - 1 for j = low to high - 1 if arr[j].uploadTime <= pivot.uploadTime i = i + 1 swap arr[i] and arr[j] swap arr[i + 1] and arr[high] return i + 1`

**5. TikTok Video Analytics**

`function findMaxConsecutiveOnes(nums):`

`maxCount = 0`

count = 0

for i from 0 to length(nums) - 1:

if nums[i] == 1:

count++

maxCount = max(maxCount, count)

else:

count = 0

return maxCount

What is the purpose of the given pseudocode?

Pick ONE option:

- Finding the maximum sum subarray in an array
- Counting the maximum consecutive ones in a binary array
- Calculating the longest common subsequence in two arrays
- Searching for the maximum element in an array

**6. Minimizing Transitions in TikTok Content Storage**

In the bustling world of TikTok, data management behind the scenes is critical for smooth content delivery. The platform's core storage mechanism is represented by a binary array called `tiktokStorage`

, which holds n bits of data, each representing a different type of content:

- Standard content (represented by 0s)
- Priority content (represented by 1s)

As TikTok’s user engagement peaks, it’s essential to minimize the transitions between standard and priority content in `tiktokStorage`

to ensure the platform’s content pipeline operates seamlessly.

Two engineers, Liora and Thorne, are tasked with reorganizing the content to achieve this goal. They can perform operations to swap the bits at any two distinct indices in the array. Your task is to determine the minimum number of swap operations required so that after performing these operations, there are the fewest possible transitions between 0s and 1s in the `tiktokStorage`

array.

Example Input:

`tiktokStorage = [1, 0, 1, 0, 0, 1]`

Output = 1

**7. TikTok Common Interests**

In the dynamic world of TikTok, each user has a list of favorite content categories they are interested in. You are tasked with analyzing the connections between these users, focusing specifically on the number of shared interests. The goal is to determine the highest number of common interests that any pair of TikTok users shares, where the number of common interests is the largest positive integer that evenly divides the number of interests of both users.

You are given an array `favoriteCategories`

of length n where each element represents the number of favorite content categories of a TikTok user. Find the highest number of common interests between any two TikTok users in the network.

Example Input:

`favoriteCategories = [4, 2, 6, 8]`

Output = 4

Explanation: Out of all the pairs possible from the array, the maximum number of common interests (the largest positive integer that evenly divides the number of favorite content categories of both users) is between the users with 4 and 8 favorite content categories. The number of common interests is 4, which is the highest possible value.

Function Description: Complete the function `maxSharedCategories`

in the editor below.

`maxSharedCategories`

has the following parameter(s):

`int favoriteCategories[n]`

: an array where each element represents the number of favorite content categories of a TikTok user.

Returns: The highest number of common interests between any two TikTok users.

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 代写服务，助您进入梦想大厂，欢迎随时咨询我。**