Homework: Identify a Suspect - Need Help

I’ve spent quite a bit of time on this question and still have no clue about how to reach the solution the question is asking for…

I’ve used for-loops to check if a person is contained in another building and then added that person to my output Set, but this solution only results in:

Your submission is overly complicated:
  The solution has 1 code paths, but your submission has 6.

I’ve also had other ideas of solving this, but they all end up with a similar error.

Did you look into the intersect and union objects? Those are both super useful in your code. Re-read the question and slow down while looking at it. Try to explore intersect and union, also examine if you have extra code.

i.e you wouldnt need to say if (student in building1, building2, building3). If you looked into intersect and are properly using it.

1 Like

Oh my god, thank you so much.
I understood how to use the addAll() and retainAll() function but after creating my new solution, I have no clue what the heck I was doing earlier lol.
Again, thanks a lot!