Need help in a Problem(Hiring Challenge)

Given a matrix of characters find whether it is possible to rearrange the characters so that all rows and columns are palindromic.

PS:Hiring challenge finished

Anyone knew how to approach the problem please explain

If there is no restriction on how to rearrange then it is pretty easy.
Any matrix with even number of rows and columns can only be rearranged so that all rows and columns are palindrome when all the characters occurs in multiple of 4 and if the matrix has odd dimension you can always reduce it to even matrix and can handle 1 row/col separately with the same counting approach with n-1 characters occur in mutiple of 2 and a single any character.

This is the problem is simply of counting the occurences of characters in matrix.

1 Like