Validate grid complete

Last updated: January 15, 2026

Quick Overview

Given a 2D grid of characters, write a function to validate whether the grid is complete, meaning that each row and each column contains all the characters from a specified set without any missing elements. The function should return a boolean value: true if the grid is complete, and false otherwise.

MongoDB
Coding & Algorithms
Software Engineer
MongoDB
January 15, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

23

11

4,921 solved


Given a 2D grid of characters, write a function to validate whether the grid is complete, meaning that each row and each column contains all the characters from a specified set without any missing elements. The function should return a boolean value: true if the grid is complete, and false otherwise.

MongoDB uses this problem in the Onsite to evaluate your algorithmic thinking. They expect you to discuss multiple approaches, analyze trade-offs between them, and implement the optimal solution with clean, readable code.

What the Interviewer Expects
  • Recognize the underlying problem pattern (sliding window, two pointers, BFS/DFS, etc.)
  • Discuss multiple approaches and trade-offs before coding
  • Implement an optimal solution with clean, production-quality code
  • Handle all edge cases including boundary conditions and invalid input
  • Optimize both time and space complexity with clear justification
  • Test your solution systematically with well-chosen examples
Key Topics to Cover
Graph algorithms and traversal
Binary search and divide and conquer
Sorting and searching
Dynamic programming and memoization
Time and space complexity analysis
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you test this solution thoroughly?
  • Can you solve this in a single pass?
  • How would your solution change if the input was sorted?
  • How would you modify your solution to handle streaming input?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Problem Analysis

To validate whether a grid is complete, we need to ensure that each row and each column contains all the characters from a defined set without any missing elements. This problem can be analyzed using ...

Approach
  1. Define the Set: Identify the set of characters that should be present in each row and column. For example, if the set is {'A', 'B', 'C'}, then each row and each column must contain exactly thes...

Submit Your Answer
Markdown supported

Related Questions