only one test case is not running can you please check my code and tell me what is wrong, if possible can you tell me the testcase
R9 -- found at the last
Hello @WARHEAD,
You code will fail for the testcases like:
7
86 77 65 45 77 66 28
77
Expected Output:
4
Your Output:
1
Reason:
As you are incrementing and decrementing start and end resp. for each execution of the function.
Thus, it will return the index which encounters first.
77 at index=1 is closer from start than 77 at index=4 from end
Solution:
Only use the end variable and decrement it, as you have to find the last occurrence of m.
Hope, this would help.
Give a like if you are satisfied.