Comments

Can someone please suggest where I might be going wrong with my code? Thanks!

363959696

For B, what I thought was this:

Family-1: a[1], a[2], a[4], ... should have values among 1,2,4,... only (and in any order)

Family-2: a[3], a[6], a[12], ... should have values among 3,6,12,... only (and in any order) and so on...

The lowest value of each family is an odd number. Now, if index 'i' from some family has value from other family, the array cannot be rearranged in increasing order. The values allotted to each of the indices in the family must be reducible to the corresponding lowest index of that family, only then that array can be rearranged to increasing order. Can someone suggest the time complexity of this solution? Thank you!

My solution: 363142713