[TikTok] AMS Intern Assessment 2024 Start -12 to 16 Feb (Generic)

本周的tiktok又开放啦,tiktok的秋招到现在一直保持的高强度的OA 发放。This week's TikTok has opened up again, and TikTok's autumn recruitment has maintained a high intensity of OA distribution.

给不熟悉tiktok OA的朋友们科普一下,tiktok的OA每两周开放一次,当第一次OA未通过时可以再次申请两周后的OA,一般是周一开始做,周五截止。潜规则是周五做OA的人一般不会通过,而越早完成通过率越高。For those who are not familiar with TikTok's OA, it opens every two weeks. When the first OA is not passed, you can reapply for the OA after two weeks, which is generally started on Monday and ends on Friday. The unwritten rule is that people who do the OA on Friday generally do not pass, and the earlier you complete it, the higher the pass rate.

看看本周有什么真题吧,Let’s see what the real questions are this week

Q3.Spend it All

There is a budget and an array of n costs. Repeat the following process until budget is less than the minimum element in cost.

Process Start at element 0 and work to n - 1. At each element cost[i]:

  • If cost[i]budget, reduce budget by cost[i] and move to the next index. This is a purchase.
  • If cost[i] > budget, move to the next index.

The array is circular, so the next index after n - 1 is index 0. Continue until there is not enough budget to make a purchase.

Determine how many purchases are made.

Example cost = [5, 8, 3] budget = 12

Process:

  • Buy item 0 for 5 -> budget = 12 - 5 = 7.
  • Item 1 is too expensive, budget = 7.
  • Buy item 2 for 3, budget = 7 - 3 = 4.
  • Items 0 and 1 are too expensive, budget = 4.
  • Buy item 2 for 3, budget = 4 - 3 = 1.
  • Now budget = 1, and there are no more items that can be purchased.
  • Return 3, the number of items purchased.

Q4.Subsequences of Three

Given an array of n integers, arr[n], determine all of its subsequences of three elements and find the validity of arr. validity = min{3 * abs(mean(S) - median(S))} for all S A subsequence is a sequence that can be derived from a sequence by deleting zero or more elements without changing the order of the remaining elements, for example [3, 4] is a subsequence of [5, 3, 2, 4].

Note mean(A) is the average of the array (the sum of the array divided by the size of the array). median(A) is the middle value of an ordered set of numbers with an odd number of elements. abs(x) is the absolute value of an integer.

Example n = 4 arr = [2, 3, 1, 4]

subsequencemeanmedianvalidity
[2, 3, 1](2 + 3 + 1)/3 = 223 *
[2, 3, 4](2 + 3 + 4)/3 = 333 *
[2, 1, 4](2 + 1 + 4)/3 = 2.3323 *

Q5.Maximum XOR Suffix

An array of n integers, arr, is given. Pick any index then calculate the XOR of the array from that index through the highest index. Append the value to the array. Repeat this process zero or more times. Determine the highest value possible.

Example n = 5 arr = [8, 2, 4, 12, 1]. One way to achieve the maximum is shown. The ⊕ symbol indicates the bitwise XOR operation.

Operation (0-indexed)Resulting Array
Choose i = 4[8, 2, 4, 12, 1, 1]
arr[5] = arr[4]
Choose i = 1[8, 2, 4, 12, 1, 1, 10]
arr[6] = arr[1] ⊕ ... ⊕ arr[5]
Choose i = 2[8, 2, 4, 12, 1, 1, 10, 6]
arr[7] = arr[2] ⊕ ... ⊕ arr[6]
Choose i = 0.[8, 2, 4, 12, 1, 1, 10, 6, 14]
arr[8] = arr[0] ⊕ ... ⊕ arr[7]

选择题稍后公布

The maximum strength possible is 14.

If you're afraid that you can't solve the OA on your own, please scan the code to contact me or telegram

Leave a Reply

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