FastPrepTarget Cells in One Block per Row and Column
Problems/Target Cells in One Block per Row and Column

Target Cells in One Block per Row and Column

WhatNot logoWhatNot● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Whatnot new grad Karat screen as the second of three parts. The task: pick one value and check that, in each row and each column of a grid, its cells form one unbroken run.

The report gives no input format and does not say what happens when a row or column has none of that value. Here, the grid holds integers, the value comes in as target, and a row or column without it passes.

Our version is about 80% the same as the reported question.

Given an m x n integer matrix grid and an integer target, return true if, in every row and in every column, all the cells equal to target sit next to each other with no other value between them. Otherwise, return false.

  • A row or column with a single target cell passes.
  • A row or column that has no target cell at all also passes.
  • Each row and each column is checked on its own. The blocks in different rows do not need to line up.

Function

isTargetContiguous(grid: int[][], target: int) → boolean

Examples

Example 1

grid = [[1,2,2],[3,2,2],[3,3,1]]target = 2return = true
grid
012012213222331

Row 0 has 2 in columns 1 and 2, and row 1 has the same. Columns 1 and 2 each have 2 in rows 0 and 1. Every block is unbroken, and the other lines have no 2.

Example 2

grid = [[2,1,2],[1,1,1]]target = 2return = false
grid
01202121111

Row 0 is [2,1,2]. Its two 2 cells have a 1 between them.

Example 3

grid = [[5,0],[0,0],[5,0]]target = 5return = false
grid
01050100250

Each row has at most one 5, so the rows pass. Column 0 is [5,0,5], and the 0 splits it.

Example 4

grid = [[1,2],[3,4]]target = 7return = true
grid
01012134

No cell holds 7, so no row or column breaks the rule.

Constraints

  • m == grid.length
  • n == grid[i].length
  • 1 <= m, n <= 100
  • -109 <= grid[i][j], target <= 109

More WhatNot Phone Screen questions

  • Merge Sorted Squares of Two ArraysPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Adjacent Pair and Run RemovalPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • User Journey PathsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • User Journey Paths from a Log StreamPHONE SCREEN · Seen Nov 2026
  • Reachable Exits in an Obstacle GridPHONE SCREEN · Seen Oct 2026
  • Palindrome with One DeletionPHONE SCREEN · Seen Oct 2026
  • Search a 2D MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Attraction Route Without Reusing TrailsPHONE SCREEN · Seen Sep 2026
  • Earliest Car for Each PassengerPHONE SCREEN · Seen Sep 2026
  • Minimum Stores for a Shopping ListPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Validate a Chess Bishop, Rook, or Queen MoveGlean · PHONE SCREENGlean interview questions
  • One-Nearest-Neighbor Classification with Manhattan DistanceOpenAI · PHONE SCREENOpenAI interview questions
  • Unique Pairs in a 2D Matrix Summing to TargetAmazon · PHONE SCREEN
  • Map Black Cells to Covering 2x2 BlocksSquare · PHONE SCREEN
  • Trace an Eight-Direction Robot Until BlockedPinterest · PHONE SCREENPinterest interview questions
  • Excel Training Data and Model Response AuditMicrosoft · PHONE SCREENMicrosoft interview questions
  • Count Connect-Four Scoring LinesBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Completely Passable Grid LinesSplunk · PHONE SCREENSplunk interview questions
  • Mark a Queen’s Attack BoardMotive · PHONE SCREENMotive interview questions
  • Multiply Two MatricesAdobe · PHONE SCREENAdobe interview questions

Interview reports that mention this question

  • Whatnot interviews · October 2025

WhatNot interview experiences

  • Whatnot OA · 2024
  • Whatnot OA · November 2023
  • Whatnot interviews · November 2023
  • Whatnot interviews · February 2024
  • Whatnot interviews · March 2024
All WhatNot interview questionsSee WhatNot hiring insights
Saved
class Solution {
    public boolean isTargetContiguous(int[][] grid, int target) {
        // write your code here
    }
}
Checking account…