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.
The problem description is kind of misleading. It implies substring search but in fact what is needed is test if any single character from the first string is contained in the second one.
This is the only solution that can pass all tests, because it seems all tests have 2 seconds time limit and the later tests apparently include quite long strings.
My multiple attempts to optimize the C++ code I wrote all failed at the later tests due to timeouts. Only when I succumbed to write the code that looks for single char, only then all tests passed.
I feel kind of tricked, but it was good practice anyway.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Two Strings
You are viewing a single comment's thread. Return to all comments →
The problem description is kind of misleading. It implies substring search but in fact what is needed is test if any single character from the first string is contained in the second one.
This is the only solution that can pass all tests, because it seems all tests have 2 seconds time limit and the later tests apparently include quite long strings.
My multiple attempts to optimize the C++ code I wrote all failed at the later tests due to timeouts. Only when I succumbed to write the code that looks for single char, only then all tests passed.
I feel kind of tricked, but it was good practice anyway.