Accenture interview question

Logic for Bubble search