FastPrepDepartment Seating Metrics
Problems/Department Seating Metrics

Department Seating Metrics

Citadel logoCitadel● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Citadel new grad onsite interview. The interviewer asked to compare two seating matrices. More groups should have all employees from one department connected, and employees in the same department should be closer.

The report leaves the distance measure to the candidate. Here, connected means touching on four sides. Distance is the sum over every pair of employees in the same department, using Manhattan distance. The number of people in each department stays equal. Both measures are returned separately, and we do not combine them into one final score.

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

Each cell in a rectangular seating grid contains the department ID of its employee. Compare the layouts before and after a move by returning four values:

  1. The number of departments whose entire membership forms one four-neighbor connected group in before.
  2. The sum of Manhattan distances over all unordered pairs of employees in the same department in before.
  3. The connected-department count in after.
  4. The same-department pair-distance sum in after.

A singleton department is connected. Diagonals do not connect cells. Manhattan distance between (r1,c1) and (r2,c2) is |r1-r2|+|c1-c2|. Count each unordered pair once.

More fully connected departments is better on the first metric; a smaller distance sum is better on the second. Return both metrics without combining them into a final score. Both layouts have the same department membership counts.

Function

seatingMetrics(before: int[][], after: int[][]) → long[]

Examples

Example 1

before = [[1,2],[2,1]]after = [[1,1],[2,2]]return = [0,4,2,2]

Before the move, neither department is connected and each contributes distance 2. After the move, both departments are connected and each pair has distance 1.

Example 2

before = [[7,7,7]]after = [[7,7,7]]return = [1,4,1,4]

The one department is connected in both layouts. Its three unordered pair distances are 1, 2, and 1, summing to 4.

Constraints

  • 1 <= before.length, after.length <= 60
  • 1 <= each row length <= 60
  • Both grids are rectangular and have the same dimensions.
  • 0 <= each department ID <= 1000000
  • Both grids contain the same multiset of department IDs.

More Citadel Onsite Interview questions

  • Maximize Workday EarningsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Minimum Changes for Palindromic BlocksOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Removal PoolONSITE INTERVIEW · Seen Sep 2026
  • Centered K-by-K Submatrix SumsONSITE INTERVIEW · Seen Aug 2026
  • Search Suggestions with a Prefix TreeONSITE INTERVIEW · Seen Aug 2026
  • Traverse Interior Matrix Cells in Row-Major OrderONSITE INTERVIEW · Seen Aug 2026
  • Time-Based Key-Value StorePHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2026
  • 2048 Simulation and Board CodecONSITE INTERVIEW · Seen Jan 2026
  • Cancellable Priority Task QueueONSITE INTERVIEW · Seen Jan 2026
  • Dynamic Weighted SamplingONSITE INTERVIEW · Seen Jan 2026

Similar questions at other companies

  • Number of IslandsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Explore an Unknown Grid and Find a PathLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Nearest Charging Station on a GridSpotify · ONSITE INTERVIEW
  • Longest Matrix Walk with Two-Step ComparisonsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Island Count and Maximum AreaOracle · ONSITE INTERVIEWOracle interview questions
  • Shortest Increasing Path to a TargetUber · ONSITE INTERVIEWUber interview questions
  • Mouse and Cheese ReachabilityMeta · ONSITE INTERVIEWMeta interview questions
  • Number of IslandsTripjack · ONSITE INTERVIEWTripjack interview questions
  • Number of IslandsTekion · ONSITE INTERVIEWTekion interview questions
  • Grid Pathfinding with Obstacles (DFS)Roblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions

Interview reports that mention this question

  • Citadel SWE Intern Later Rounds and Superday: 13 Experiences

Citadel interview experiences

  • Citadel Securities Quant Researcher Intern Loop: 1 Experience
  • Citadel Securities Research Engineer Interview: 1 Experience
  • Citadel Securities SWE Intern First Round: 2 Experiences
  • Citadel Securities Experienced SWE Interviews: 1 Experience
  • Citadel SWE Intern First-Round Questions: 20 Experiences
All Citadel interview questionsSee Citadel hiring insights
Saved
class Solution {
    public long[] seatingMetrics(int[][] before, int[][] after) {
        // write your code here
    }
}
Checking account…