👉「包含 SQL, REST API, Counting Pairs, Increasing Array, BFS Traversal, Time Complexity 等经典题目」
1. Election
Problem:
Given a database of the results of an election, find the number of seats won by each party.
- There are many constituencies in a state and many candidates contesting the election from each constituency.
- Each candidate belongs to a party.
- The candidate with the maximum number of votes in a given constituency wins for that constituency.
Output format:Party Seats_won
Ordering:
Seats won in descending order.
Example :
Output format shown in query result:
party | seats_won
X | 2
Y | 1

2. REST API: City Weather Station
Problem:
Retrieve information from a database using HTTP GET request.
Each request record has:
- name (city name)
- weather (temperature)
- status (wind and humidity)
Return the result as:City,Temperature,Wind,Humidity
Example :
Input:
"Adelaide"
Output:
Adelaide,15,8,61
Another case:
Input: "all"
Output:
Dallas,12,2,5
Dallapura,19,9,14
Vallejo,1,24,56
3. Counting Pairs
Problem:
Given an integer k
and a list of integers, determine the number of unique pairs (a, b)
in the list where a + k = b
.
- Pairs are distinct if at least one element differs.
- A pair may contain the same element twice when
k = 0
.
Examples :
Example 1
Input: numbers = [1,1,1,2], k = 1
Output: 1
Explanation: The list has three unique pairs: (1,1), (1,2), (2,2). For k=1, only (1,2) satisfies.
Example 2
Input: numbers = [1,2], k = 0
Output: 2
Explanation: The list has three unique pairs: (1,1), (2,2), (1,2). For k=0, pairs (1,1) and (2,2) satisfy.

4. Increasing Array
Problem:
You are given an array arr[] of size n. You have to convert the array into a non-decreasing array.
You can only remove numbers from the ends of the array.
Example (from image):
arr = [4,3,3,8,4,5,2]
Options:
- Remove 4,3,3,8 from the beginning
- Remove 8,4,5,2 from the end
- Remove 4 from the beginning and 4,5,2 from the end
- None of the above
Correct option in image was 3.
5. BFS Traversal
Problem:
In a tree where 2 & 3
are children of 1
, and 4 & 5
are children of 2
, what will be the BFS traversal of that tree starting from 1
?
Example (from image options):
Correct BFS traversal:
1 -> 2 -> 3 -> 4 -> 5
6. Time Complexity 1
Problem:
What is the time complexity of this code?
int temp = 0;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j += i) {
for(int k = 1; k <= n; k += 2) {
temp++;
}
}
}
Options (from image):
- O(n log(n))
- O(n log²(n))
- O(n² log(n)) ✅
- O(n² log²(n))
我们长期稳定承接各大科技公司如Flexport Sde I OA、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.
