FastPrepLargest Opening After Removing Bars
Problems/Largest Opening After Removing Bars

Largest Opening After Removing Bars

Roblox logoRoblox● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The candidate describes removed horizontal and vertical bars and the largest gap left. Another report names Prison Break. We chose a spacing of one unit, fixed outer edges, an area as the output, the interface, and the limits. Our version is about 85% the same as the reported question.

For this exercise, assume a rectangular grid of bars has n removable horizontal bars numbered 1..n and m removable vertical bars numbered 1..m. Each bar crosses the whole grid, adjacent bars are one unit apart, and fixed outer boundaries lie at horizontal positions 0 and n+1 and vertical positions 0 and m+1.

Remove exactly the horizontal bars listed in horizontal and vertical bars listed in vertical. Return the area of the largest rectangular opening formed between remaining bars or outer boundaries. Do not remove any additional bars or change the input arrays. If no bars are removed, every opening is a unit square.

Function

largestOpeningArea(n: int, m: int, horizontal: int[], vertical: int[]) → long

Examples

Example 1

n = 3m = 3horizontal = [1,2]vertical = [2]return = 6

Removing horizontal bars 1 and 2 creates a 3-unit height; removing vertical bar 2 creates a 2-unit width.

Example 2

n = 4m = 5horizontal = []vertical = []return = 1

No bars are removed, so all openings stay 1 by 1.

Example 3

n = 2m = 2horizontal = [2,1]vertical = [1,2]return = 9

All internal bars disappear, leaving a 3 by 3 opening.

Constraints

  • 1 <= n, m <= 1000000000.
  • 0 <= horizontal.length <= min(n, 100000) and 0 <= vertical.length <= min(m, 100000).
  • Horizontal IDs are distinct integers in 1..n; vertical IDs are distinct integers in 1..m. Either list may be unsorted.
  • Return a signed 64-bit integer area.

More Roblox Online Assessment questions

  • Centered Block Placement QueriesOA · Seen Oct 2026
  • Robot Navigation Around LasersOA · Seen Oct 2026
  • Factory Batch Profit (Game Adaptation)OA · Seen Sep 2026
  • Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
  • Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
  • Track Received Byte RangesOA · Seen Sep 2026
  • Inventory Discount TrackerOA · Seen Sep 2026
  • Break a PalindromeOA · Seen Jun 2026
  • Count Pairs Differing in One DigitOA · Seen Oct 2025
  • Find Zero Cells in a 2×2 GridOA · Seen Oct 2025

Similar questions at other companies

  • API Rate Limit Violation DetectionTekion · OATekion interview questions
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Minimum Distinct Prefix CostChubb · OAChubb interview questions
  • Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
  • Convert Sparse Records to a Filled TableNetflix · OANetflix interview questions
  • Rearrange Songs by AuthorZomato / Eternal · OAZomato / Eternal interview questions
  • Aggregate Paginated Project Run RecordsReplit · OA
  • Rank Teams by VotesAtlassian · OAAtlassian interview questions

Interview reports that mention this question

  • Roblox OA: What It Tests (2026)
  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)

Roblox interview experiences

  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public long largestOpeningArea(int n, int m, int[] horizontal, int[] vertical) {
        // write your code here
    }

}
Checking account…