FastPrepGrid Laid Over Its Own Turn
Problems/Grid Laid Over Its Own Turn

Grid Laid Over Its Own Turn

Susquehanna International Group (SIG) logoSusquehanna International Group (SIG)● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A new grad report from December 2023 describes four SIG quant rounds. The last round opened with a clear square cut into a 3 by 3 grid, where each small square is painted black with chance one half. A copy of the painted square is turned 90 degrees clockwise and laid on top of the original, and the question is the chance that the whole square then looks black. The author solved it by counting cases.

The report fixes the grid size and the chance and gives no input format. Here, the grid size n (1 to 1000) and the chance that a cell is black, p in whole percent, are inputs. The function returns the chance that the overlay is all black. The interview case n = 3, p = 50 is the first example. Answers within 10^-9 (absolute or relative) are accepted.

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

Take a clear sheet with an n × n grid of cells. Each cell is painted black with probability p percent, independently of the others; unpainted cells stay clear.

Make an exact copy of the painted sheet, turn the copy 90 degrees clockwise, and lay it exactly on top of the original. A cell position looks black if it is black on the original, on the turned copy, or on both.

Return the probability that every cell position looks black.

Your answer is accepted if its absolute error or its relative error is at most 10^-9.

Function

allBlackProbability(n: int, p: int) → double

Examples

Example 1

n = 3p = 50return = 0.095703125

This is the interview case. Turning the grid moves each corner to the next corner and each edge cell to the next edge cell, while the center stays put. So the cells form three groups that can be checked separately: the 4 corners, the 4 edge cells, and the center.

A group of 4 is fully covered with chance 7/16 (see the table in the editorial), and the center must be black on its own, chance 1/2. The answer is 7/16 × 7/16 × 1/2 = 49/512, about 0.0957.

Example 2

n = 2p = 50return = 0.4375

The four cells form one group. The overlay misses a position only when that cell and the cell that turns onto it are both clear. Of the 16 equally likely paintings, 7 avoid that: all black (1), one clear cell (4), or two clear cells on a diagonal (2). The answer is 7/16 = 0.4375.

Example 3

n = 4p = 90return = 0.8632327748323041

A 4 by 4 grid has 16 cells and no center, so it splits into 4 groups of 4. With black chance 0.9, one group is covered with chance 0.9^4 + 4 × 0.9^3 × 0.1 + 2 × 0.9^2 × 0.1^2 = 0.6561 + 0.2916 + 0.0162 = 0.9639.

The groups are independent, so the answer is 0.9639^4, about 0.8632.

Constraints

  • 1 <= n <= 1000
  • 0 <= p <= 100

More Susquehanna International Group (SIG) Phone Screen questions

  • Dice Sum That Is a Multiple of mPHONE SCREEN · Seen Nov 2026
  • Find Median from Data StreamPHONE SCREEN · Seen Nov 2026
  • Painting Arcs to Nearest Neighbors on a CirclePHONE SCREEN · Seen Sep 2026
  • Filter Movies by Inclusive Year RangePHONE SCREEN · Seen Jul 2026
  • Best Single Reroll for Five DicePHONE SCREEN · Seen Feb 2026
  • Catching the Bus to the MoviePHONE SCREEN · Seen Jan 2026
  • Two Dice Summing to a TargetPHONE SCREEN · Seen Jan 2026
  • Median of Uniform Draws in an IntervalPHONE SCREEN · Seen Oct 2025
  • One Number Is the Average of the Other TwoPHONE SCREEN · Seen Jun 2025
  • Which Coin Pattern Shows Up FirstPHONE SCREEN · Seen May 2025

Similar questions at other companies

  • Count Array DerangementsInMobi · PHONE SCREENInMobi interview questions
  • Biased Coin: Probability of Exactly h HeadsAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Revolver: Will the Next Shot Fire?Tower Research Capital · PHONE SCREEN
  • Probability of Consecutive HeadsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Expected Fake-Name CollisionsMercor · PHONE SCREENMercor interview questions
  • Election District Budget Allocation AnalysisIMC Trading · PHONE SCREENIMC Trading interview questions
  • Count Clean Attendance LogsRippling · PHONE SCREENRippling interview questions
  • Extra Coin Win ProbabilityMicrosoft · PHONE SCREENMicrosoft interview questions
  • Count Staircases with Strictly Increasing StepseBay · ONSITE INTERVIEWeBay interview questions
  • Get Triplet CountIBM · OAIBM interview questions

Interview reports that mention this question

  • SIG Quant Researcher New Grad Interviews: 49 Experiences

Susquehanna International Group (SIG) interview experiences

  • SIG Quant Researcher Experienced Hire Interviews: 11 Experiences
  • SIG Quant Research Intern Interviews: 60 Experiences
  • SIG Quant Researcher Intern Interviews: 1 Experience
  • SIG Quant Second-Round Tech Screen: 1 Experience
All Susquehanna International Group (SIG) interview questionsSee Susquehanna International Group (SIG) hiring insights
Saved
class Solution {
    public double allBlackProbability(int n, int p) {
        // Write your code here.
    }
}
Checking account…