Skip to content
Related Articles

Related Articles

Improve Article

Flipkart Interview Experience | Set 15B

  • Last Updated : 27 May, 2019

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.
  1. Input 2 4 ..B. ..B. Output 1
  2. Input 5 5 ..B.. ..GRR ..B.. R.... R.... Output 4
  3. 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.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. In case you are prepared, test your skills using TCS, Wipro, AmazonGoogle and Microsoft Test Serieses.

My Personal Notes arrow_drop_up
Recommended Articles
Page :