Implemented the logic to get prefix interesection