There were three questions, one based on string, one on graph and one on array. I need solutions to the 1st and 3rd questions so please do share any ideas.
Example: A="abceda" B="bdecbo" C=1. Output: 3 operations. Explanation: set A[0]=B[0] so A becomes "bbceda", set A[5]=B[5] so A becomes "bbcedo" and then reverse A(1..4) so A becomes "bdecbo" which is B. So 3 operations.
Example : n=3 , edges : (0,1),(0,2) and values : v[0]=0, v[1]=1, v[2]=2. Output : mex[0]=3,mex[1]=0,mex[2]=0.
Example: for A = [3, 5, 4]. Output: 1. Swapping 5 and 4 gives array [3, 4, 5] which fulfills i%3==a[i]%3