VALGIFT-Editorial

PROBLEM LINK:

VALGIFT

Author: mehul_dholiya

Editorialist: mehul_dholiya

Prerequisite:

None

Difficulty:

Easy

EXPLANATION:

In this problem we have to find the maximum length substring which starts and ends with the same type of character.
We will store first occurrence position of every pearl in one array and last occurrence position of every pearl in second array. Then we will simply subtract last position from first position of every pearl. At the end we will get total 5 lengths and the maximum length is the required answer.

Author’s Solution:

Setter’s Solution

1 Like