Is a Popular Story Fake?
Updated
Problem statement
On a social network, fakePercent percent of all stories are fake and the rest are real.
- A fake story gets at least 100 likes with probability
fakePopularPercentpercent. - A real story gets at least 100 likes with probability
realPopularPercentpercent.
You see a story that has at least 100 likes. Return the probability that it is fake.
Your answer is accepted if its absolute error or its relative error is at most 10^-9.
Function
fakeNewsProbability(fakePercent: int, fakePopularPercent: int, realPopularPercent: int) → doubleExamples
Example 1
fakePercent = 30fakePopularPercent = 80realPopularPercent = 8return = 0.8108108108108109This is the interview case. Picture 10,000 stories: 3,000 are fake and 7,000 are real.
Of the fake ones, 80% are popular: 2,400. Of the real ones, 8% are popular: 560.
So 2,400 of the 2,960 popular stories are fake: 2400 / 2960 = 30/37, about 0.8108.
Example 2
fakePercent = 50fakePopularPercent = 40realPopularPercent = 40return = 0.5Fake and real stories are equally likely to be popular, so seeing 100 likes tells you nothing. The answer stays at the starting share, 0.5.
Example 3
fakePercent = 0fakePopularPercent = 90realPopularPercent = 10return = 0.0There are no fake stories at all, so the answer is 0.
Constraints
0 <= fakePercent <= 1001 <= fakePopularPercent <= 1001 <= realPopularPercent <= 100
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
- Knights, Knaves and Their StatementsOA · Seen Nov 2026
Similar questions at other companies
- Count Valid Square PairsAuxoAI · OA
- Server InvestmentRippling · OARippling interview questions
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Identification Number Check DigitAbridge · OAAbridge interview questions
- Count Substrings With Identical CharactersVirtu Financial · OAVirtu Financial interview questions
- Next Pascal Row CoefficientIntuit · OAIntuit interview questions
- Digit-Sum Sequence Join PointOpenAI · OAOpenAI interview questions
- Minimum Testers to Find the Poisoned BottleWalleye Capital · OA
- Address on Same PageNVIDIA · OANVIDIA interview questions
- Preorder of a Special Binary TreeNielsen · OA