Design a team directory that tracks employees and the teams they work with. Each employee is hired once, then any number of teams may refer to that same employee object.
The provided TeamDirectory class supports these operations:
TeamDirectory() creates a directory with no employees and no teams.boolean hire(String name) hires an employee and returns true. A name already hired is refused with false.boolean createTeam(String name) creates an empty team and returns true. A name already used is refused with false.boolean assign(String teamName, String employeeName) puts that employee on that team and returns true. It changes nothing and returns false when the team does not exist, when the employee was never hired, or when they are already on that team.boolean dissolveTeam(String name) removes the team and returns true, or returns false when it does not exist. Everyone who was on it stays employed.int employeeCount() returns how many people are employed.String[] teamsOf(String employeeName) returns that employee's current teams in team-creation order. An unknown employee returns an empty result.int teamSize(String name) returns how many people are on that team, or 0 when it does not exist.A team aggregates employees but does not own them. Dissolving a team removes only that group: its members remain employed and keep their memberships in any other teams.
Your task is to implement the Employee and Team classes expected by the provided directory. Do not modify TeamDirectory. Employee represents one directory-owned employee, while Team stores references to existing Employee objects and rejects duplicate memberships.
Input:
Output:
Explanation: Ada is hired before Core refers to her. The team's member count and Ada's team list are two queries over the same membership.
Input:
Output:
Explanation: Core and UI both refer to the same employee. Ada appears in both teams, but the directory still stores one employee record.
1 <= name.length <= 40100 calls will be made across all methods.Full marks when employees are created by and owned by the directory, and a team holds references to existing employees rather than copies of their names. Lose points heavily when a team stores names as strings, or when assigning creates an employee that was never hired.
Full marks when dissolving a team removes only the team and leaves every employee employed, and when one employee can sit on several teams at once. Lose points when dissolving reduces the employee count, or when an employee can belong to only one team.
Full marks when membership is stored once and read from both directions, assigning an unknown employee is refused, and teamsOf reports teams in creation order. Lose points for keeping a second copy of membership on the employee, for sorting the result, or for printing to stdout.
Passing every test is not enough on its own. A submission is accepted only when the design also clears the bar.
| Call | Returns |
|---|---|
| new TeamDirectory() | null |
| hire("ada") | true |
| createTeam("core") | true |
| assign("core", "ada") | true |
| teamsOf("ada") | ["core"] |
| teamSize("core") | 1 |
| employeeCount() | 1 |
An employee and a team are created separately, then linked. The link reads the same from either side.
Run checks these cases. Submit also runs a larger hidden set.

