# Flipkart Interview Experience | Set 15B

Flipkart recently visited our campus for the written test for December placements.

• Hosted on: cocubes.com
• Time: 90 mins
• No objective questions.
• Two coding questions only. We have to complete the function only.

Ques:
Given a mxn grid, each of it’s element be either ‘.’, ‘R’, ‘G’ or ‘B’,
where ‘.’ → empty, ‘R’ → Red, ‘G’ → Green, ‘B’ → Blue
A Blue strip has width 1 and length greater or equal to one.
A Red strip has length 1 and width greater or equal to one.
If a Red strip and a Blue strip overlap, the overlapped portion will become ‘G’.
Find the minimum number of strips required to cover the whole grid.

1 ≤ m, n ≤ 100

```Ex.
Input
2 4
..B.
..B.
Output
1

Input
5 5
..B..
..GRR
..B..
R....
R....
Output
4

Input
5 5
..B..
..GRR
..B..
B....
B...G
Output
5```

Explanation:

Blue stripes are vertical.
Red stripes are horizontal.

1. Ex 1:
Only 1 vertical strip from (0,2) to (1,2). [Indexing from (0,0)]

2. Ex 2:
1 vertical strip from (0,2) to (2,2)
1 horizontal strip from (1,2) to (1,4)
1 horizontal strip from (3,0) to (3,0)
1 horizontal strip from (4,0) to (4,0)
so total — 4

3. Ex 3:
1 vertical strip from (0,2) to (2,2)
1 horizontal strip from (1,2) to (1,4)
1 vertical strip from (3,0) to (4,0)
1 horizontal strip from (4,4) to (4,4)
1 vertical strip from (4,4) to (4,4)
so total — 5

If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Write your Interview Experience or mail it to contribute@geeksforgeeks.org

My Personal Notes arrow_drop_up
Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.