media.net logo
Media.net· SDE intern

Media.net SDE intern question for technical round 1

Posted
26 May 2025
263 reads

Summary

I was asked the following coding problem during my technical round 1 for the SDE intern position at Media.net.

How it went

During my technical round 1 for the SDE intern position at Media.net, I was presented with the following problem:

Questions asked (1)

  1. 01

    Minimum Recolorings in 2D Grid

    Data Structures & Algorithms · Hard

    You are given a 2D grid of size m x n, where each cell contains a ball painted with a color, represented by a lowercase English letter ('a' to 'z'). Your goal is to recolor the balls such that:
    1. In each row, no color appears more than twice.
    2. No two adjacent balls (up, down, left, right) share the same color.

    You may recolor any ball using any lowercase letter from 'a' to 'z'

    Return the minimum number of recolorings required to make the grid valid according to the constraints.

    Example
        Input:
            grid = [
                ['a', 'a', 'a'],
                ['b', 'b', 'b']
            ]
        Output:
            2
    Explanation:

    In row 0: 'a' appears 3 times, which violates the "at most 2 per row" rule.

    Recolor one 'a' to another color (say 'c'), and ensure no two adjacent cells have the same color.

    Row 1 also needs 1 change.

    So, minimum 2 changes required.

    Constraints
    1. 1 ≤ m, n ≤ 10
    2. grid[i][j] is a lowercase English letter ('a' to 'z')

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Media.net recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!