Test duration 75 mins
No. of questions 5 questions
1. Table of Contents
Task: Create a table of contents for a simple markup language. It must follow two rules:
- If a line starts with a single
#
followed by a space, then it's a chapter title. - If a line starts with a double
##
followed by a space, then it's a section title.
The table of contents should be displayed in the following format:
1. Title of the first chapter
1.1. Title of the first section of the first chapter
1.2. Title of the second section of the first chapter
2. Title of the second chapter
2.1. Title of the first section of the second chapter
2.2. Title of the second section of the second chapter
Note that each number is followed by a period and the last period is followed by 1 space.
Sample Input:
10
# Cars
Cars came into global use during the 20th century.
Most definitions of car say they run primarily on roads.
## Sedan
Sedan's first recorded use as a name for a car body was in 1912.
## Coupe
A coupe is a passenger car with a sloping rear roofline and generally two doors.
## SUV
The predecessors to SUVs date back to military and low-volume models from the late 1930s.
There is no commonly agreed definition of an SUV, and usage varies between countries.
Sample Output:
1. Cars
1.1. Sedan
1.2. Coupe
1.3. SUV
Explanation:
- The first line of input indicates there are
n = 10
lines of text. - There is only 1 chapter in the input, and it contains 3 sections.
- All the lines that don't begin with
#
or##
are ignored in the table of contents.
2. Python: Fixed Size Warehouse
Task: Implement a Product
class and an exception class that represent a warehouse that can house a limited number of products. After the limit is reached, if there is an attempt to add an additional product instance, it throws a custom error.
Class Requirements:
Product
:__init__(self, name)
: Initialize the instance variable with itsname
attribute.__del__(self)
: Delete the instance.- Track the number of
Product
instances. - The number of allowed products can be changed dynamically. It is retrieved by calling
Limit.get_limit()
. - If the number of
Product
instances is less than the current limit, create a new product instance. - Otherwise, throw a
UserLimitExceeded
exception with the message"Product {name} cannot be created. Maximum {limit} products allowed."
. Do not create a new instance.
UserLimitExceeded(Exception)
:- This is an exception class. It accepts an error message in its constructor and throws an exception.
The Limit
class and its operations are implemented in the template. Please read the code to understand the application.
Constraints:
- The maximum number of instructions is 100.
- The maximum number of products is 50.
- The limit will never be changed to less than the current number of Product instances.
Sample Input:
3
10
new laptop
new bag
new LCD
print laptop
new keyboard
new chair
del laptop
del keyboard
print keyboard
del laptop
Sample Output:
laptop created
bag created
LCD created
laptop found
Product keyboard cannot be created. Maximum 3 products allowed.
laptop deleted successfully
chair created
keyboard not found
keyboard not found
laptop not found
Explanation:
- Initially, the limit is 3. New products are created.
- When the limit is reached, the new product is not added, and an error is thrown.
- Note that once a product is deleted, it is no longer found.
3. Number of Topological Sorts II
Task: Find the total number of topological sortings in the following graph.
Graph:
1 → 4 → 6
2 → 4 → 5
3 → 5 → 6
Pick ONE option:
- 14
- 17
- 10
- 15
4. Heapify Operation
Task: Given array = [6, 15, 2, 4, 3, 8, 19]
. After applying heapify operation on the array, the array will look like:
Pick ONE option:
[19, 15, 6, 4, 3, 8, 2]
[19, 6, 15, 4, 3, 8, 2]
[19, 15, 4, 6, 3, 8, 2]
[19, 6, 15, 8, 4, 3, 2]
5. MySQL: Substring Extraction
Task: Choose the expression that retrieves the base domain "domain.com"
.
Pick ONE option:
SELECT SUBSTRING_INDEX('my.subdomain.domain.com', '.', -2)
SELECT SUBSTRING_INDEX('my.subdomain.domain.com', 'my.subdomain.', 1)
SELECT SUBSTRING_INDEX('my.subdomain.domain.com', '.', 2, 2)
All expressions are correct
我们长期稳定承接各大科技公司如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.