Taken from Execute Program
Write a
SocialGraph
class with a constructor and two methods.
- The constructor creates an empty
Map
.- The
addFollow
method records thatuser1
followsuser2
by updating the map. Note that order matters here- The
follows
method checks for whetheruser1
followsuser2
, returning aboolean
.
Solution
This is the answer I came up with: