2010. The Number of Seniors and Juniors to Join the Company II

https://leetcode.com/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii

Description

Table: Candidates

+-------------+------+
| Column Name | Type |
+-------------+------+
| employee\_id | int  |
| experience  | enum |
| salary      | int  |
+-------------+------+
employee\_id is the primary key column for this table.
experience is an enum with one of the values ('Senior', 'Junior').
Each row of this table indicates the id of a candidate, their monthly salary, and their experience.
The salary of each candidate is guaranteed to be **unique**.

A company wants to hire new employees. The budget of the company for the salaries is $70000. The company's criteria for hiring are:

  1. Keep hiring the senior with the smallest salary until you cannot hire any more seniors.

  2. Use the remaining budget to hire the junior with the smallest salary.

  3. Keep hiring the junior with the smallest salary until you cannot hire any more juniors.

Write an SQL query to find the ids of seniors and juniors hired under the mentioned criteria.

Return the result table in any order.

The query result format is in the following example.

Example 1:

Example 2:

ac

Last updated

Was this helpful?