Section Lists to Map
Write a method called
sectionListsToMap that, given a
Strings, parses it into a
Map<String, MutableSet<String>> as follows.
String in the passed list contains a comma-separated list of names of people in a discussion section.
The first name is the section leader, and the rest are students.
Your map should map each section leader to the set of students in their section.
No section leader or student will appear twice in the data set.
For example, given the
Strings "challen,student1", "ruisong4,student2, student3" and "friendly,student4, student5",
your map would have keys "challen", "ruisong4", and "friendly".
"challen" would map to a set containing "student1", "ruisong4" would map to a set containing "student2" and
"student3", and so on.
A few hints for approaching this problem.
First, consider how to use
.trim appropriately to parse the input
You should get this part to work before proceeding.
Then consider when you need to create the map and each set, and how to populate them.
You should not need
import statements to solve this problem.
Rather, create your maps and sets using
mutableSetOf() where appropriate.