Google|Phone screen|Cut a cake vertically without destroying toppings

I had google phone screen last week and below question was asked.

Question : For given toppings , if the cake can have atleast one vertical cut without destryoing any topping return true , otherwise false.

All toppings are in rectangular shape

input:
aaaaaaaa bbb
aaaaaaaa bbb
cc ........... bbb
cc ............bbb
cc ........... bbb
cc ddddddddd
cc ddddddddd

Comments (4)