MLE: Google Preliminary
- Posted
- 28 Apr 2025
Summary
I attended a preliminary interview at Google and was presented with a problem to group elements based on common properties.
How it went
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"]]
Questions asked (1)
- 01
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"]]