我拿到的是IOS developer, new grad, 但是给的OA 也是 general。 他家OA只要准备就不难。求加米, 加油
6. TikTok Balanced Clips
TikTok creates random clips made up of lowercase English letters.
A clip is called "smooth" if the difference between any two letters next to each other is not bigger
than a number called diff.
The difference between two letters, xxx and yyy, is how far apart they are in the alphabet. For
example, the difference between 'a' and 'z' is 25, and between 'f' and 'c' is 3.
i.e. If diff = 3, then the clip "ac" is smooth because the difference between 'a' and 'c' is 2, which
is less than or equal to 3. However, the clip "az" is not smooth because the difference between
'a' and 'z' is 25, which is greater than 3.
You are given two numbers: clipLength (the number of letters in the clip) and diff (the
maximum allowed difference between two letters next to each other). Your job is to find how
many smooth clips of length clipLength can be made. Since the number could be very large,
give the answer as the result modulo 109+710^9 or below.
getMinTikTokServerNetworkCost has the following parameters:- int x[n]: The x-coordinates of the servers
- int y[n]: The y-coordinates of the servers
Here's a solution for the TikTok Server Network Optimization problem in both C++ and Java. This problem is essentially about finding the minimum spanning tree (MST) for a graph where the nodes are servers and the edges between servers represent the minimum of either the x or y difference.
|