Number of Dice Rolls With Target Sum
Updated
Problem statement
Given dice, faces, and target, return the number of ordered dice outcomes whose sum equals target.
Roll dice identical dice, each with faces numbered from 1 through faces. Outcomes that differ in the order of the rolls count separately.
Return the count modulo 1,000,000,007.
Function
numRollsToTarget(dice: int, faces: int, target: int) → intExamples
Example 1
dice = 2faces = 6target = 7return = 6Each first roll has exactly one matching second roll, giving the ordered pairs from (1,6) through (6,1).
Constraints
1 <= dice, faces <= 30.1 <= target <= 1000.
More Bloomberg LP Onsite Interview questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Currency Conversion RatePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Count Complete Tic-Tac-Toe GamesDecagon · PHONE SCREEN · ONSITE INTERVIEWDecagon interview questions
- Maximal SquareAmazon · ONSITE INTERVIEW
- Distinct Subset SumsGoogle · ONSITE INTERVIEWGoogle interview questions
- Count Subsets With a Target SumSafe Security · ONSITE INTERVIEW
- Minimum Coins for a TargetInfosys · ONSITE INTERVIEWInfosys interview questions
- Knight Probability in ChessboardGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
- Maximum Subarray Sum with One DeletionOracle · ONSITE INTERVIEWOracle interview questions
- Best Time to Buy and Sell Stock IIKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
- Coin ChangeMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Count Staircases with Strictly Increasing StepseBay · ONSITE INTERVIEWeBay interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)