FastPrepBayesian Posterior From Error Rates
Problems/Bayesian Posterior From Error Rates

Bayesian Posterior From Error Rates

Microsoft logoMicrosoft● MediumFULLTIMEPHONE SCREEN

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report says the interviewer supplied error rates and asked for a Bayesian posterior, but omits the exact events, rates and answer format. This single-positive-test practice case matches the visible mathematical core at about 65%.

A binary condition has prevalence priorPercent among the population. A test has a falsePositivePercent chance of returning positive when the condition is absent, and a falseNegativePercent chance of returning negative when the condition is present. A randomly selected person tests positive.

Compute the probability that the person has the condition given this positive result. Return that probability exactly as an integer array [numerator, denominator] in lowest terms, with a positive denominator. For example, a posterior of one half is [1,2]. All rates are integer percentages.

Function

posteriorAfterPositive(priorPercent: int, falsePositivePercent: int, falseNegativePercent: int) → int[]

Examples

Example 1

priorPercent = 1falsePositivePercent = 1falseNegativePercent = 0return = [100,199]

A rare condition with one percent false positives has a posterior just above one half after a positive result.

Example 2

priorPercent = 10falsePositivePercent = 5falseNegativePercent = 20return = [16,25]

Of the positive tests in a 10,000-person cohort, 800 are true positives and 450 are false positives.

Example 3

priorPercent = 50falsePositivePercent = 0falseNegativePercent = 25return = [1,1]

With no false positives, every observed positive comes from an affected person.

Constraints

  • 1 <= priorPercent <= 99.
  • 0 <= falsePositivePercent <= 100.
  • 0 <= falseNegativePercent <= 99.
  • The probability of a positive result is nonzero under these bounds.

More Microsoft Phone Screen questions

  • Config Store with Priority OverridesPHONE SCREEN · Seen Nov 2026
  • Corporation Reporting LinesPHONE SCREEN · Seen Oct 2026
  • Random Forest Classifier from ScratchPHONE SCREEN · Seen Oct 2026
  • Least Recently Used CacheOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Greedy and Beam Sentence DecodingPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Top K Frequent ElementsPHONE SCREEN · Seen Sep 2026
  • 3SumPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Arithmetic Expression EvaluatorPHONE SCREEN · Seen Sep 2026
  • Employee Hierarchy Cycle and Depth AnalysisPHONE SCREEN · Seen Sep 2026
  • Most Visited String SectorsPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Sliding Window Attention over a KV CacheNVIDIA · PHONE SCREENNVIDIA interview questions
  • Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
  • Monthly Calendar with Custom Week StartStripe · PHONE SCREENStripe interview questions
  • Fractional Share Inventory FlatteningRobinhood · PHONE SCREEN · ONSITE INTERVIEWRobinhood interview questions
  • Logistic Regression DiagnosticsLinkedIn · PHONE SCREENLinkedIn interview questions
  • Evenly Schedule Vehicle InspectionsAmazon · PHONE SCREEN
  • Implement Cross-Entropy LossOpenAI · PHONE SCREENOpenAI interview questions
  • Cumulative No-Intercept Regression BetasCitadel · PHONE SCREENCitadel interview questions
  • Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
  • Per-Segment SpeedingOnePay · PHONE SCREENOnePay interview questions

Interview reports that mention this question

  • Microsoft AI/ML Intern Interviews: 114 Experiences (Part 1 of 2)

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public int[] posteriorAfterPositive(int priorPercent, int falsePositivePercent, int falseNegativePercent) {
        // Return the exact reduced posterior fraction.
    }
}
Checking account…