Skip to content

Practice Find Consistently Improving Employees

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#3580
LeetCode Problem

Find Consistently Improving Employees

Problem Statement

Tables: employees(employee_id INT, name VARCHAR) and performance_reviews(review_id INT, employee_id INT, review_date DATE, rating INT). Consider employees with at least three reviews. Their three most recent reviews by date must have strictly increasing ratings in chronological order. Return employee_id, name, and improvement_score, calculated as latest minus earliest rating within those three. Sort by score descending, then name ascending. Practice approach: Number each employee's reviews newest first and keep exactly three before checking increases. Older reviews do not contribute to the improvement score. Equal ratings fail the strict comparison; comparing only first and last misses a decrease in between.

Source: Find Consistently Improving Employees on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
{
  "employees": [
    {
      "employee_id": 1,
      "name": "Ava"
    },
    {
      "employee_id": 2,
      "name": "Bo"
    },
    {
      "employee_id": 3,
      "name": "Cy"
    }
  ],
  "performance_reviews": [
    {
      "review_id": 1,
      "employee_id": 1,
      "review_date": "2026-01-01",
      "rating": 5
    },
    {
      "review_id": 2,
      "employee_id": 1,
      "review_date": "2026-02-01",
      "rating": 1
    },
    {
      "review_id": 3,
      "employee_id": 1,
      "review_date": "2026-03-01",
      "rating": 3
    },
    {
      "review_id": 4,
      "employee_id": 1,
      "review_date": "2026-04-01",
      "rating": 5
    },
    {
      "review_id": 5,
      "employee_id": 2,
      "review_date": "2026-01-01",
      "rating": 1
    },
    {
      "review_id": 6,
      "employee_id": 2,
      "review_date": "2026-02-01",
      "rating": 1
    },
    {
      "review_id": 7,
      "employee_id": 2,
      "review_date": "2026-03-01",
      "rating": 4
    },
    {
      "review_id": 8,
      "employee_id": 3,
      "review_date": "2026-01-01",
      "rating": 1
    },
    {
      "review_id": 9,
      "employee_id": 3,
      "review_date": "2026-02-01",
      "rating": 5
    }
  ]
}
Output
[
  {
    "employee_id": 1,
    "name": "Ava",
    "improvement_score": 4
  }
]
Explanation

Ava's last three ratings are 1,3,5; the older 5 is irrelevant. Bo has an equal pair, and Cy has too few reviews.

Constraints

employees has key employee_id; reviews have key review_id.
Ratings are integers from 1 to 5.

Related LeetCode Problems

Practice more problems similar to Find Consistently Improving Employees.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.