Survey Table: Group Given an Answer
Updated
Problem statement
A survey asked people one question. counts[i][j] is the number of people who gave answer i and belong to group j (for example, an age band). Every row has the same number of groups.
You meet a person from the survey who gave answer row. Every such person is equally likely to be the one you met. Return the probability that this person belongs to group col.
Your answer is accepted if its absolute error or its relative error is at most 10^-9.
Function
conditionalShare(counts: int[][], row: int, col: int) → doubleExamples
Example 1
counts = [[54,40,42,66],[77,68,90,70],[28,43,50,52],[90,78,71,81]]row = 2col = 1return = 0.24855491329479767This is the interview survey: answers run, bike, swim and other, groups aged 18-22, 23-27, 28-32 and 33-37. The person prefers swimming (row 2), and we want ages 23-27 (column 1).
The swim row has 28 + 43 + 50 + 52 = 173 people, and 43 of them are 23-27. The answer is 43/173, about 0.2486.
Example 2
counts = [[1,3],[2,2]]row = 0col = 1return = 0.75Row 0 has 1 + 3 = 4 people and 3 of them are in group 1, so the answer is 3/4 = 0.75. The other row does not matter.
Example 3
counts = [[5]]row = 0col = 0return = 1.0There is only one group, so everyone with answer 0 is in group 0. The answer is 1.
Constraints
1 <= counts.length <= 501 <= counts[i].length <= 50, and every row has the same length1 <= counts[i][j] <= 10^60 <= row < counts.length0 <= col < counts[0].length
More Susquehanna International Group (SIG) Online Assessment questions
- Catch Fish with Reusable BaitsOA · Seen Nov 2026
- Bold Play to Reach a GoalOA · Seen Nov 2026
- Cats, Truth and Who Has MoreOA · Seen Nov 2026
- Counting Cows by Their LegsOA · Seen Nov 2026
- Enough Muffins for the LineOA · Seen Nov 2026
- Expected Consecutive Pairs Among Chosen NumbersOA · Seen Nov 2026
- Four-by-Four Boundary GridOA · Seen Nov 2026
- Frog Paths Without Long RunsOA · Seen Nov 2026
- Higher Roll, or Lose the SumOA · Seen Nov 2026
- Is a Popular Story Fake?OA · Seen Nov 2026
Similar questions at other companies
- Build a Gaussian Blur KernelLuma AI · OALuma AI interview questions
- Rotate a Square Matrix 90 Degrees ClockwiseZipRecruiter · OAZipRecruiter interview questions
- Rotate a Flat Image ClockwiseGoogle · ONSITE INTERVIEWGoogle interview questions
- Matrix MultiplicationeBay · ONSITE INTERVIEWeBay interview questions
- One-Nearest-Neighbor Classification with Manhattan DistanceOpenAI · PHONE SCREENOpenAI interview questions
- Multiply Two MatricesAdobe · PHONE SCREENAdobe interview questions
- Matrix Multiplication With and Without NumPyNVIDIA · PHONE SCREENNVIDIA interview questions
- Adjacent Order-Statistic Gap DistributionsScale AI · PHONE SCREENScale AI interview questions
- Linear Layer Forward and Backward PassesMeta · ONSITE INTERVIEWMeta interview questions
- Scaled Dot-Product AttentionAmazon · PHONE SCREEN