Problem · Array

Employee Training Status

Learn this problem
EasyVanta logoVantaFULLTIMEPHONE SCREEN

Problem statement

A training requirement service stores due days for required employees and completion days for employees who finished the training. Given a shared checkDay, return one status for every employee in queryEmployeeIds.

Build the requirement and completion records from the parallel input arrays, then classify each queried employee using these rules:

  1. If the employee does not appear in requiredEmployeeIds, return "NOT_REQUIRED".
  2. If the employee has a completion day less than or equal to checkDay, return "COMPLETED". Completion takes precedence even when it happened after the due day.
  3. If the employee is required, has not completed by checkDay, and checkDay is greater than the due day, return "OVERDUE".
  4. Otherwise, return "PENDING". An incomplete training is still pending on its due day.

Return the statuses in the same order as queryEmployeeIds; repeated query IDs produce repeated output entries.

Function

trainingStatuses(queryEmployeeIds: String[], requiredEmployeeIds: String[], dueDays: int[], completedEmployeeIds: String[], completionDays: int[], checkDay: int) → String[]

Examples

Example 1

queryEmployeeIds = ["amy","ben","cy","dia"]requiredEmployeeIds = ["amy","ben","cy"]dueDays = [10,12,8]completedEmployeeIds = ["amy","cy"]completionDays = [9,13]checkDay = 12return = ["COMPLETED","PENDING","OVERDUE","NOT_REQUIRED"]

amy completed before the check day. ben is incomplete exactly on the due day, so the status is pending. cy has a future completion record and is already past due on the check day. dia is not required.

Example 2

queryEmployeeIds = ["late","future"]requiredEmployeeIds = ["late","future"]dueDays = [3,20]completedEmployeeIds = ["late"]completionDays = [8]checkDay = 10return = ["COMPLETED","PENDING"]

A late completion is still completed by the check day. The second employee has not reached the due day.

Constraints

  • requiredEmployeeIds.length == dueDays.length.
  • completedEmployeeIds.length == completionDays.length.
  • Every employee ID is a non-empty string. IDs are unique within requiredEmployeeIds and within completedEmployeeIds; query IDs may repeat.
  • All due days, completion days, and checkDay are nonnegative integers.
  • A completion record may name an employee who is not required; that employee still resolves to "NOT_REQUIRED".

More Vanta problems

drafts saved locally
public String[] trainingStatuses(String[] queryEmployeeIds, String[] requiredEmployeeIds, int[] dueDays, String[] completedEmployeeIds, int[] completionDays, int checkDay) {
    // write your code here
}
queryEmployeeIds["amy","ben","cy","dia"]
requiredEmployeeIds["amy","ben","cy"]
dueDays[10,12,8]
completedEmployeeIds["amy","cy"]
completionDays[9,13]
checkDay12
expected["COMPLETED", "PENDING", "OVERDUE", "NOT_REQUIRED"]
checking account