MLE: Google Preliminary

google logo
google
April 28, 20252 reads

Summary

I attended a preliminary interview at Google and was presented with a problem to group elements based on common properties.

Full Experience

Questions was we have n elements with 3 properties each we need to group the elements. If any one of the property is common those two element should be in same group.

e.g.:

elements = {
            "e1": ['red',   'circle',    'small'],
            "e2": ['blue',  'square',    'small'],
            "e3": ['green', 'triangle',  'large'],
            "e4": ['black',   'triangle',  'large'],            
            }
Output: [["e1", "e2"], ["e3", "e4"]]

Interview Questions (1)

Q1
Group Elements by Common Properties
Data Structures & Algorithms

We have n elements with 3 properties each. We need to group the elements. If any one of the property is common, those two elements should be in the same group.

e.g.:

elements = {
            "e1": ['red',   'circle',    'small'],
            "e2": ['blue',  'square',    'small'],
            "e3": ['green', 'triangle',  'large'],
            "e4": ['black',   'triangle',  'large'],            
            }
Output: [["e1", "e2"], ["e3", "e4"]]
Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!