Coding problem
Who knows each skill
The task
The staffing page answers "who here knows this skill?", so it needs the team's skill lists turned around.
Complete WhoKnows(List<Person> people). Person is a record with a Name and a list of Skills. Return one SkillPeople for each skill that anyone has, with the names of the people who have it, in the order of the people list. Sort the skills in ascending ordinal order, which compares characters by their numeric values. A person who lists a skill twice appears once for it, and a person with no skills adds nothing. Skills match exactly. The lists and their items are never null, and names are unique.
Signature
public record Person(string Name, List<string> Skills); public record SkillPeople(string Skill, List<string> People); public static List<SkillPeople> WhoKnows(List<Person> people)
Examples
[("amy", ["sql", "csharp"]), ("ben", ["csharp"]), ("cara", ["go", "sql"])]→[("csharp", ["amy", "ben"]), ("go", ["cara"]), ("sql", ["amy", "cara"])]. Each skill lists the people who have it, in the order of the people list.[("dev", [])]→[]. dev lists no skills, so there is nothing to show.
Limits: Up to 100,000 people with up to 10 skills each, and up to 50,000 different skills.
The tests check: no people, a person without skills, skills sorted A to Z, people in their list order, a skill listed twice by one person, one person with many skills, and 100,000 people in time.
Hints
Your code
Already included: using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http; using System.Threading; using System.Threading.Tasks;
public record Person(string Name, List<string> Skills);
public record SkillPeople(string Skill, List<string> People);
public static class Solution
{
// Skill to people: each skill A to Z with the people who have it, in people-list order.
public static List<SkillPeople> WhoKnows(List<Person> people)
{
throw new NotImplementedException();
}
}This problem comes with TechInterviewNotes Full Access
Unlock all paid content on TechInterviewNotes.