You have an input array of size m*n. Each cell in the array is populated with either P or T. The only operation you can do on the array is flip columns. When you flip a column, the letters in all the cells of that column switch (P becomes T and viceversa). If you have 'x' number of rows with same letter (e.g. PPPP) then you get a point. Design an algorithm that takes in the array and returns a solution (which columns to flip) such that the resulting array has maximum number of points possible.
Note: In case there are multiple solutions that yield the highest score, choose the one with lowest number of flips. Example:
PPTPP PPTPP PPTTP PPPTT PPPTT
A solution that yields the highest points: Flip column no. 3
Then the original array would be:
PPPPP // 1 point PPPPP // 1 point PPPTP PPTTT PPTTT //Total: 2 points
Note that one could also flip columns 4 and 5 to get a score of two, but that needs an additional flip.
You may use any convenient input format to represent the two dimensional array, and you may also any two distinct, but fixed, values to represent
This is code golf, so the shortest answer (in bytes) wins.