Maximum Area of Triangle! InterviewBit Solution
Problem: Maximum Area of Triangle
Problem Description:
Given a character matrix of size N x M in the form of a string array A of size N where A[i] denotes ith row.
Each character in the matrix consists of any one of the following three characters {'r', 'g', 'b'} where 'r' denotes red colour similarly 'g' denotes a green colour and 'b' denotes blue colour.
You have to find the area of the largest triangle that has one side parallel to the y-axis i.e vertical and the colour of all three vertices are different.
NOTE:
If the area comes out to be a real number then return the ceil of that number.
Problem Constraints:
2 <= N, M <= 10^3
A[i][j] = 'r' or A[i][j] = 'g' or A[i][j] = 'b'
Input Format:
The first and only argument is a string array A of size N denoting the 2D character matrix.
Output Format:
Return a single integer denoting the area of the largest triangle that has one side parallel to the y-axis i.e vertical and the colour of all three vertices are different.
If the area comes out to be a real number then return the ceil of that number.
Example Input:
Input 1:
A = ["rrrrr", "rrrrg", "rrrrr", "bbbbb"]
Input 2:
A = ["rrr", "rrr", "rrr", "rrr"]