- Published on
Google Phone Screen | Jul 2024
- Author
- Shared Anonymously
The question was as follows :
Given an array of objects group the objects in a single group if they have any property same.
Object : {
id, p1, p2, p3;
}
p1, p2, p3 are properties and can be same while id will be unique for each object
For Example:
Input :
E1 : id1, p1, p2, p3
E2 : id2, p1, p4, p5
E3 : id3, p6, p7, p8
E4 : id4, p9, p10, p5
Output :
{{id1, id2, id4}, {id3}}
Do upvote if it helps you.
Report • Mark as Helpful