Google
More Experiences
MLE: Google Preliminary
April 28, 2025 • 2 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"]]