虽然发的有些晚,但是本周tiktok的真题如下。其中第7题有2个版本。
错过的了同学不要慌,大约10月5日之后会发下一批,欢迎找我们预约OA代写服务。
6. TikTok Encryption Risk Analysis
The TikTok engineering team is analyzing the security of content encryption on the platform. They are working with two strings, videoHash
and encryptionKey
, both of length n
.
The videoHash
represents the hashed content of a video, while the encryptionKey
is used to encrypt the videoHash
in the system. To test the security, at most one swap operation can be performed between the videoHash
and the encryptionKey
. For any 1≤i≤n1, the iiith character of the videoHash
and the encryptionKey
can be swapped.
The security risk of the encryptionKey
is defined as the smallest value of iii such that after the swap, videoHash
becomes lexicographically smaller than the encryptionKey
. If videoHash
is already lexicographically smaller than the encryptionKey
, then no swap is required, and the security risk is 0. If it’s impossible to achieve this, the security risk is considered to be -1. Your task is to find the security risk.
Example
videoHash = "upload"
encryptionKey = "doupla"
If the characters at the first position are swapped, then videoHash
= "uoupla" and encryptionKey
= "dpload". Here, videoHash
becomes lexicographically smaller than encryptionKey
. This is the smallest possible value for the security risk.
7. TikTok Hashtag Divisor Count
In the latest update to our TikTok backend system, we’ve introduced a feature designed to optimize content discovery by recognizing specific relationships between hashtags used in video descriptions. Imagine two hashtags where one is a repetition of a smaller hashtag. For example, the hashtag #dance
is repeated to form #dance#dance#dance
.
Our new feature identifies these “hashtag divisor” relationships, where one hashtag can be constructed by concatenating another hashtag multiple times. This enhancement is crucial for efficient hashtag pattern analysis in our content recommendation algorithms.
Now, we are further improving our recommendation engine to evaluate and count the number of common hashtag divisors between two video descriptions, which will significantly enhance our ability to analyze and optimize content discovery.
Example
description1 = "ababab"
description2 = "ab"
To determine the number of common hashtag divisors between these two video descriptions, follow these steps:
- Identify the divisors of each hashtag string:
- For
description1
= "ababab":- "ab"
- "abab"
- "ababab"
- For
description2
= "ab":- "ab"
- For
- Count the common divisors between the two descriptions:
- Common divisors: "ab".
Therefore, the output will be 1
, as "ab" is the only common divisor.
7. Parse URLs
In today’s digital age, parsing URLs is crucial for ensuring good monitoring, caching, and logging in web applications. Your task is to parse a list of URLs and extract specific components.
Write a function parseUrl
that takes in a list of URLs and returns a list of strings depending on the structure. There are three types of URLs to parse:
- With params: A URL with params will have the format
https://{string}{/endpoint}?{params}
. Here the endpoint can have multiple/
and params are multiple pairs of the form{string}={string}
separated by&
. For this type of URL, return "{domain}
has endpoint{endpoints}
with{count_params}
params". - With no params but an endpoint: A URL with an endpoint will have the format
https://{string}{/endpoint}
. Here the endpoint can have multiple/
. For this type of URL, return "{domain}
has endpoint{endpoints}
with no params". - With no params or endpoints: A base URL has the format
https://{string}
. For this type of URL, return "{domain}
has no endpoint with no params".
Example
Input:
urls = [
"https://example.com/api/data?sort=asc",
"https://test.com/page?query=python&page=1",
"https://example.com"
]
Output:
[ "example.com has endpoint api/data with 1 params", "test.com has endpoint page with 2 params", "example.com has no endpoint with no params"]
The output contains valid URLs with their components extracted.
- For
https://example.com/api/data?sort=asc
, the domain isexample.com
, the endpoint isapi/data
, and the parameters aresort=asc
. - For
https://test.com/page?query=python&page=1
, the domain istest.com
, the endpoint ispage
, and the parameters arequery=python&page=1
. - For
https://example.com
, there’s only a domain (example.com
), so only that part is extracted.
Function Description
Complete the function parseUrl
in the editor below.
parseUrl
has the following parameter(s):
string urls[n]
: an array of strings representing URLs to validate and parse.
我们长期稳定承接各大科技公司如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.