Infosys Interview Question

asked to write a code for a search engine