Google onsite interview

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2025-03-11Added By Anonymous
Source: Link
🧭 Experience: unknown
✅ Outcome: unknown
💰 Compensation: unknown
📍 Location: unknown
🏢 Company: Google
🎓 Education: unknown
🎁 Benefits: unknown
📅 Offer Date: unknown

Can't disclose the exact question but something like this
Find the minimum value of m such that n objects can be placed in an m times m matrix while satisfying the following condition:

For any two objects placed at positions (r1, c1) and (r2, c2) , the absolute difference in their row or column indices must be at least k . In other words:
|r1 - r2|>= k or |c1 - c2|>= k .

You are given n (number of objects) and k (minimum distance constraint). Find the minimum m for which this arrangement is possible.
Ex

``` |1 * 2 * 3| |* * * * *| |4 * * * *| |* * * * *| |5 * * * *| ```

if n=5 and k=2 then m=5 similary
``` |1 * 2| |* * *| |3 * 4| ```
if n=4 and k=2 m will be 3.

Can anyone share the optimal approach!
Comments