Source: https://www.geeksforgeeks.org/media-net-interview-experience-for-sde-on-campus/
There is some line missing in the problem statement so I am writing here. Also the code for solution is provided but I am not able to understand
We are given strings containing 1 and 2.
When is string a good ? If we are at index i then we can either move a[i] units left or a[i] units right. We have to start at first index and reach last index such that every index is visited once. If we are able to do the it is a good string
Give 2 strings a, b which are initially good. You can select an array of indexes and for each index i, swap(a[i], b[i]). How many ways are there of selecting an array of indexes such that both strings remain good
Can someone explain the solution please?