Panda Guru LogoPanda
Guru

Amazon OA

Round 1

Questions: The question was about finding the longest self-contained proper substring, which is available on LeetCode. Link: Find Longest Self-Contained Substring
Discuss: LeetCode Discuss

Here is the image of the question to understand it properly:
image
image

The code I wrote worked perfectly and passed all the test cases (15/15).

However, when I ran my code for a custom input, the output was not the same as expected.
See this
image

For input: abcba
Output should be: 3 (the substring will be bcb), but the expected output is 0.

Solve this and tell what could be the reason.

PS: This solution is also giving the same answer as mine (failing the abcba testcase): GitHub Solution

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.