Citadel Summer intern 的 OA 限时66分钟有2道算法题,2025年的NG们抓紧这次实习机会,一起来看看真题吧。
Citadel Summer Intern Online Assessment includes 2 algorithm questions with a time limit of 66 minutes. For 2025 New Grads, don’t miss this internship opportunity. Let’s take a look at the actual questions!
Question 2
Description:
In an organization, there are n
servers, each with a capacity of capacity[i]
. A contiguous subsegment [l, r]
of servers is said to be stable if:
capacity[l] = capacity[r] = sum[i+1, r-1]
In other words, the capacity of the servers at the endpoints of the segment should be equal to the sum of the capacities of all the interior servers.
Task:
Find the number of stable subsegments of length 3 or more.
Example:
Input:
n = 5, capacity = [9, 3, 3, 3, 9]
Analysis:
Segment | First & Last Capacity | Interior Capacity Sum | Balanced |
---|---|---|---|
[9, 3, 3] | 9 | 6 | No |
[3, 3, 3] | 3 | 3 | Yes |
[3, 3, 9] | 3 | 6 | No |
[9, 3, 3, 3] | 9 | 9 | Yes |
[3, 3, 3, 9] | 3 | 9 | No |
[9, 3, 3, 3, 9] | 9 | 9 | Yes |
Output:
There are 2 stable subsegments: [3, 3, 3] and [9, 3, 3, 3, 9]. Return 2.
Function Description:
Complete the function countStableSegments
with the following parameter:
int capacity[n]
: the capacities of each server.
Returns:
- An integer, the number of stable subsegments
Question 3
Description:
Implement a prototype of a friend recommendation system for a social media application.
There are n
users indexed from 0
to n-1
, and m
friends represented as a 2D array, friendships
, where the i-th
friendship is a connection between users friendships[i][0]
and friendships[i][1]
.
Task:
User x
is suggested as a friend to user y
if:
x
andy
are not friends.x
andy
have the maximum number of common friends (i.e., a friend of bothx
andy
).- If there are multiple possible users
x
, the one with the minimum index is suggested. - If no recommendation is available, report
-1
.
Example:
Input:
n = 5, m = 5
connections = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4]]
Graph representation:
0
/ \
1 2
\ /
3
\
4
Output:
[-1, 0, 0, 0, 3]
Explanation:
- User 0 has no recommendation, output
-1
. - User 1 is recommended to befriend user 0 (maximum common friends).
- User 2 is also recommended to befriend user 0.
- User 3 is recommended to befriend user 0.
- User 4 is recommended to befriend user 3.
Function Description:
Complete the function friendRecommendation
with the following parameters:
int n
: the number of users.int friendships[m][2]
: the friendships between users.
Returns:
- An integer array, where each element represents the recommended friend for each user.
我们长期稳定承接各大科技公司如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.