Sir can you explain In problem D why we will count no of submasks present in an array.Basically I didn't understand the getmaxlength() function

Problem B can also be solved by dp. My submission we create most optimal string and then apply dp for how many ways we can create this string.(Basically number of paths). Can anyone tell why my sol gives wrong answer

Still I didn't understand it

Can anyone explain the concept behind problem D.I didnt understand the editorial

can anyone give the implementation of problem "D".It will be really helpful.