Search Box

0

0 votes
Problem

Sameer is an intern in an e-commerce startup, which is planning to develop its own web portal. One of the most common actions to be performed by the users of the portal would be using the search box to query for a brand or product. The search box then returns the best matching product web page which it can find.

To start with, they have 5 web pages of products and most of the search queries by the user should end up on one of them. Sameer is given the task to program a basic working system on these lines.

The product web pages are :

nikon camera samsung smartphone dell inspiron titan watch axe deodorant

Sameer is told that he would be provided with N one-line search queries which should point to the related product web pages, without compromising on search quality. Sameer has written a piece of code (provided below) filled with bugs which he is not able to debug. Can you help him debug and improve his code?

Input : First line contains an integer N. This would be followed by N lines each a search query.

Constraints : 1 <= N <= 50 Each query will not exceed 200 characters in length.

Output : Output should contain exactly N lines. Each line should either point to the best possible product web page or should print 'WHOOPS' (without quotes) if no match is possible.

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?