We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This is a terribly written question. In any real interview, you would be expected to ask clarifying questions, such as:
1. Do you want me to print the first string that has a prefix among the earlier strings in the array, or the first string that is a prefix of another string in the array?
2. If a string encountered later in the array is the prefix of a string encountered earlier in the array, which should be printed?
3. What should you print if there is only one element in the array?
This question, as posed, relies on you exercising an essential skill (seeking clarification for unclear requirements) that is impossible to exercise in the format given.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
No Prefix Set
You are viewing a single comment's thread. Return to all comments →
This is a terribly written question. In any real interview, you would be expected to ask clarifying questions, such as: 1. Do you want me to print the first string that has a prefix among the earlier strings in the array, or the first string that is a prefix of another string in the array? 2. If a string encountered later in the array is the prefix of a string encountered earlier in the array, which should be printed? 3. What should you print if there is only one element in the array? This question, as posed, relies on you exercising an essential skill (seeking clarification for unclear requirements) that is impossible to exercise in the format given.