Valid Permutations for DI Sequence

Valid Permutations for DI Sequence - Coding Problem | K5kC