https://practice.geeksforgeeks.org/problems/valid-substring0624/1