Arya
BAN USER- 0of 0 votes
AnswersWe have a class as follows:
public class People{ String name; String position; String sex; ... ... public String getAttribute(String attrName){ /** * This is a generic getter method that will give you * any attribute value based on the passed attribute * Name; * for eg: getAttribute("name") => will return the * attriute(Name) value of the current object. */ } }
I now give you two List:
- Arya in United States
list1<People> friends;
list2<String> attributes;
Using the generic getter method, we have to group "friends" on "attributes". Think of this as an implementation of GROUP BY function to be implemented on objects in list1 and to be grouped on entries in list2.
eg: list2 = {sex, occupation}
So objects in list1 will be grouped such that all Male-doctors together, Female-cops together, male-cops together, etc.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm