PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Walmart Labs

Find shared courses between student pairs

Last updated: Mar 29, 2026

Quick Overview

This problem set evaluates data structures and algorithms competencies, covering mapping and set intersection for pairwise course overlap, permutation and uniqueness constraints for Latin-square validation, and run-length pattern recognition for Nonogram clue matching.

  • medium
  • Walmart Labs
  • Coding & Algorithms
  • Software Engineer

Find shared courses between student pairs

Company: Walmart Labs

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

### Problem Set (Coding) You are given multiple coding questions from an interview. Implement each function as described. --- ## 1) Course Overlap You are given an array of pairs `(studentId, courseName)` describing which student took which course. **Task:** For every pair of distinct students `(idA, idB)` (where `idA < idB`), compute the list of course names that both students have taken. **Input:** - `String[][] enrollments`, where each element is `{studentId, courseName}`. **Output:** - A list of entries, one per student pair, each containing: - the pair key as a string like `"idA,idB"` - the list of common courses (order does not matter, but should be deterministic if you choose to sort) - Include pairs even if they share no courses (then the list is empty). **Example** Input: ```text [ ["17","Math"], ["17","English"], ["58","Math"], ["61","Physics"] ] ``` Output (one acceptable format): ```text ( "17,58" -> ["Math"], "17,61" -> [], "58,61" -> [] ) ``` --- ## 2) Validate Sudoku-like Grid Given an `n x n` integer grid, validate whether it is a valid **Latin-square style** grid: A grid is valid if: - `n >= 1` - Every value is an integer in `[1, n]` - Each row contains each number `1..n` exactly once - Each column contains each number `1..n` exactly once Return `true` if valid, otherwise `false`. **Examples** ```text grid = [ [1,2,3], [2,3,1], [3,1,2] ] => true ``` ```text grid = [ [0,2,3], [2,3,1], [3,1,2] ] => false (0 is out of range) ``` ```text grid = [ [1,3], [2,1] ] => false (3 is out of range for n=2) ``` --- ## 3) Validate Nonogram A **Nonogram** board is a `R x C` grid of characters where each cell is: - `'B'` = black - `'W'` = white You are also given: - `rowClues`: an array of length `R`, where `rowClues[i]` is a list of run-lengths of consecutive `'B'` groups in row `i` (left to right). - `colClues`: an array of length `C`, where `colClues[j]` is a list of run-lengths of consecutive `'B'` groups in column `j` (top to bottom). **Task:** Return `true` if the board matches *all* row and column clues; otherwise return `false`. Notes: - An empty clue list (e.g., `[]`) means there are **no** black cells in that row/column. **Example** ```text matrix = [ [W,W,W,W], [B,W,W,W], [B,W,B,B], [W,W,B,W], [B,B,W,W] ] rowClues = [ [], [1], [1,2], [1], [2] ] colClues = [ [2,1], [1], [2], [1] ] => true ``` If the clues do not match the derived runs, return `false`.

Quick Answer: This problem set evaluates data structures and algorithms competencies, covering mapping and set intersection for pairwise course overlap, permutation and uniqueness constraints for Latin-square validation, and run-length pattern recognition for Nonogram clue matching.

Related Interview Questions

  • Implement lexicographically smallest Two Sum - Walmart Labs (medium)
  • Check whether brackets are balanced - Walmart Labs (medium)
  • Compute days until plants stop dying - Walmart Labs (medium)
  • Count ways to make change (DP) - Walmart Labs (medium)
  • Merge two sorted arrays in-place - Walmart Labs (easy)
Walmart Labs logo
Walmart Labs
Jan 6, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
4
0
Loading...

Problem Set (Coding)

You are given multiple coding questions from an interview. Implement each function as described.

1) Course Overlap

You are given an array of pairs (studentId, courseName) describing which student took which course.

Task: For every pair of distinct students (idA, idB) (where idA < idB), compute the list of course names that both students have taken.

Input:

  • String[][] enrollments , where each element is {studentId, courseName} .

Output:

  • A list of entries, one per student pair, each containing:
    • the pair key as a string like "idA,idB"
    • the list of common courses (order does not matter, but should be deterministic if you choose to sort)
  • Include pairs even if they share no courses (then the list is empty).

Example

Input:

[ ["17","Math"], ["17","English"], ["58","Math"], ["61","Physics"] ]

Output (one acceptable format):

(
  "17,58" -> ["Math"],
  "17,61" -> [],
  "58,61" -> []
)

2) Validate Sudoku-like Grid

Given an n x n integer grid, validate whether it is a valid Latin-square style grid:

A grid is valid if:

  • n >= 1
  • Every value is an integer in [1, n]
  • Each row contains each number 1..n exactly once
  • Each column contains each number 1..n exactly once

Return true if valid, otherwise false.

Examples

grid = [
  [1,2,3],
  [2,3,1],
  [3,1,2]
]
=> true
grid = [
  [0,2,3],
  [2,3,1],
  [3,1,2]
]
=> false   (0 is out of range)
grid = [
  [1,3],
  [2,1]
]
=> false   (3 is out of range for n=2)

3) Validate Nonogram

A Nonogram board is a R x C grid of characters where each cell is:

  • 'B' = black
  • 'W' = white

You are also given:

  • rowClues : an array of length R , where rowClues[i] is a list of run-lengths of consecutive 'B' groups in row i (left to right).
  • colClues : an array of length C , where colClues[j] is a list of run-lengths of consecutive 'B' groups in column j (top to bottom).

Task: Return true if the board matches all row and column clues; otherwise return false.

Notes:

  • An empty clue list (e.g., [] ) means there are no black cells in that row/column.

Example

matrix = [
  [W,W,W,W],
  [B,W,W,W],
  [B,W,B,B],
  [W,W,B,W],
  [B,B,W,W]
]

rowClues = [ [], [1], [1,2], [1], [2] ]
colClues = [ [2,1], [1], [2], [1] ]
=> true

If the clues do not match the derived runs, return false.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Walmart Labs•More Software Engineer•Walmart Labs Software Engineer•Walmart Labs Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.