Marks :10
: 10 | : 0
You are given a string $$$s$$$ and a character $$$x$$$. Return the maximum distance between any two occurences of $$$x$$$ in the string $$$y$$$. The distance between $$$2$$$ occurences of a character is defined as the total number of distinct characters between them excluding white spaces and the character itself. Output $$$-1$$$ if the $$$x$$$ doesn't exist in the string $$$s$$$ or occurs only once.
The string $$$s$$$ consists only of lowercase latin letters and white spaces.
The first line contains a string $$$s(1 \leq |s| \leq 10^6)$$$.
The second line contains a character $$$x$$$. It is guaranteed that $$$x$$$ is a lowercase latin letter.
Output a single integer - the max distance between $$$2$$$ occurences of $$$x$$$ or $$$-1$$$ if it is not possible.
my name is granar a
7
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.