Code RoomCount employees by department
EasyPrep Room Coding #385

Count employees by department

CodingAlgorithms & data structuresEntry–Mid~10 min

An HR export lists one employee per row as a comma-delimited string "name,dept", for example "ava,eng". Write a function that returns a dictionary mapping each department name to the number of employees in it. For example, ["ava,eng", "raj,sales", "mia,eng"] gives {"eng": 2, "sales": 1}.

Implement
dept_headcount(rows: list[str]) → dict[str,int]
Examples
in[["ava,eng","raj,sales","mia,eng"]]out{"eng":2,"sales":1}
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 10 min
InputExpectedGot
[["ava,eng","raj,sales","mia,eng"]]{"eng":2,"sales":1}not run yetsample