EASYasked at 1 company

Existence of a Substring in a String and Its Reverse

A easy-tier problem at 66% community acceptance, tagged with Hash Table, String. Reported in interviews at Rubrik and 0 others.

Founder's read

You're asked to find if a substring exists in both a string and its reverse. Rubrik has asked this. It's an easy problem on paper, but the test cases hide a real catch: the naive string-search approach burns you on edge cases where the substring overlaps with its own reverse, or where you're not thinking about the actual reverse operation correctly. Your gut says O(n) string search. That works, but only if you catch what happens when the original string and its reverse share structure. If you blank on the exact comparison logic during the assessment, StealthCoder surfaces the solution in seconds, invisible to the proctor.

Companies asking
1
Difficulty
EASY
Acceptance
66%

Companies that ask "Existence of a Substring in a String and Its Reverse"

If this hits your live OA

Existence of a Substring in a String and Its Reverse is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround.

Get StealthCoder
What this means

The core trick is that you need to check if a given substring appears in the original string AND appears in the reversed string. Most candidates jump to two separate substring searches, which works, but they trip on the reverse itself. Do you reverse the entire input string, or just the substring, or both. The problem is also testing whether you catch the edge case where a palindromic substring trivially satisfies the condition on its own. The Hash Table topic suggests some solutions precompute presence in a set for speed, but string methods work fine. The real failure mode is misreading the problem and thinking you need to find a substring that reads the same forwards and backwards, which is a different problem entirely. When you're 15 minutes into an assessment and you're not sure if your logic is right, StealthCoder cuts through the ambiguity.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Existence of a Substring in a String and Its Reverse recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Existence of a Substring in a String and Its Reverse interview FAQ

Is this problem actually as easy as the difficulty tag says?+

The logic is straightforward, but the edge cases around reverse operations and palindromes trip up many candidates. The 65.7% acceptance rate suggests plenty of people submitted wrong answers on their first try. The catch is usually in the exact definition of what you're checking, not the algorithm itself.

Do I need a Hash Table, or can I just use string methods?+

String methods work fine and are faster to code. The Hash Table topic is mentioned because some solutions build a set of substrings for O(1) lookup, but that's overkill here. Use the substring-search method native to your language. Save time for edge cases instead.

What's the trick with palindromes and this problem?+

If the substring is a palindrome (reads the same forwards and backwards), it trivially appears in both the original and reversed string at the same position. Many candidates forget to handle this special case or fail to recognize it, leading to incorrect logic. Always test your solution with a palindromic input.

Should I reverse the entire string or just check membership?+

You reverse the entire input string once, then check if the substring appears in both the original and the reversed version. Don't reverse the substring separately; that's a common mistake that leads to wrong answers on certain test cases.

Why would Rubrik ask this if it's marked easy?+

Easy problems test fundamentals and attention to detail. Rubrik likely uses it as a warm-up or to catch candidates who code sloppily without thinking through edge cases. A careless submission fails even though the underlying idea is simple.

Want the actual problem statement? View "Existence of a Substring in a String and Its Reverse" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.