[AirTable] OA 2025 start – 20 Apr (generic)

1. Employee Hydration

Problem Description

Given a tree-like graph representing a company structure, where each node is an employee or a manager. Every person has an associated hydration level. A manager's subtree includes themselves and all their direct and indirect reports.

Determine the manager with the maximum average hydration level, where average hydration is calculated as the sum of hydration values in the subtree divided by the number of nodes (people) in the subtree.

You need to traverse the tree using DFS or BFS and return the manager with the highest average hydration in their subtree. Leaf nodes (employees with no reports) should not be considered as valid managers for this result.

Example Input and Output

Input:
employee_data = {
    1: {"hydration": 10, "reports": [2, 3]},
    2: {"hydration": 20, "reports": [4]},
    3: {"hydration": 30, "reports": []},
    4: {"hydration": 40, "reports": []}
}

Output:
Manager with max average hydration: 2

2. Table and Data Manipulation

Problem Description

Implement a data structure to simulate a table where each cell can be accessed and modified. Each cell can either store a value or reference another cell. The following operations must be supported:

  • edit_cell(row, col, value): Set a value to a cell.
  • get_cell(row, col): Retrieve the value of a cell, resolving references recursively.
  • delete_cell(row, col): Clear the value or reference in a cell.
  • reference_cell(row1, col1, row2, col2): Make one cell reference another.

Use DFS to resolve references and prevent infinite loops (e.g., cyclic references).

Example Input and Output

Input:
edit_cell(0, 0, 5)
edit_cell(0, 1, 10)
reference_cell(1, 0, 0, 1)
get_cell(1, 0)

Output:
10

3. Percentile Approximator

Problem Description

Implement a class that efficiently approximates percentiles using a histogram-based approach. The class should support the following methods:

  • constructor(bucket_size: int): Initialize a histogram with the given bucket size.
  • report_data(value: int): Add a new data point to the histogram.
  • percentile(p: float): Estimate the p-th percentile from the data using histogram approximation.

This is useful when handling large data streams where storing all values is infeasible.

Example Input and Output

Input:
hist = PercentileApproximator(bucket_size=10)
hist.report_data(15)
hist.report_data(25)
hist.report_data(35)
hist.report_data(45)
hist.percentile(50.0)

Output:
30.0

我们长期稳定承接各大科技公司如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.

Leave a Reply

Your email address will not be published. Required fields are marked *