Pergunta de entrevista da empresa EY

Find the Number or sub-string occurrences in string with first and last character being same. Interviewer mentioned to use some data structure type to optimize the approach apart from normal approach which i couldn't find anywhere later as well.

Resposta da entrevista

Sigiloso

13 de dez. de 2024

We can use the sliding window algorithm with the size of 2 as you said the first and last characters should have to be there in the substring and an additional variable to track if we entered the substring in the traversing.