FastPrepCount Winning Dice Face Pairs
Problems/Count Winning Dice Face Pairs

Count Winning Dice Face Pairs

Google logoGoogle● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks "in how many ways does A win?"

It says A wins with a strictly larger face value. Here, repeated face values count separately, the dice may have different numbers of faces, and we supply input limits. We kept the reported example and the follow-up for sorted input.

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

Two custom dice have face values listed in dieA and dieB. Count the pairs of face occurrences (i, j) for which dieA[i] > dieB[j].

Repeated face values are separate occurrences. Equal values do not count as wins. For this exercise, the dice may have different numbers of faces and values may be negative. Return the exact count as a 64-bit integer.

Interview follow-up

If both input arrays are already sorted, solve the count in linear time.

Function

countWinningDicePairs(dieA: int[], dieB: int[]) → long

Examples

Example 1

dieA = [2,2,4]dieB = [1,2,3]return = 5

Each occurrence of 2 beats the 1, contributing two wins. The 4 beats all three B faces, contributing three more.

Example 2

dieA = [-1,0]dieB = [-2,-1,1]return = 3

The -1 face beats only -2. The 0 face beats -2 and -1. Equality does not win.

Constraints

  • 1 <= dieA.length, dieB.length <= 10^5
  • -10^9 <= dieA[i], dieB[j] <= 10^9

More Google Phone Screen questions

  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 2026
  • Minimum Total Layover WaitPHONE SCREEN · Seen Nov 2026
  • Reach a Destination Through Scheduled FlightsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Count Centaur Friend RequestsMeta · PHONE SCREENMeta interview questions
  • Count Triples That Can Form a TriangleAdobe · PHONE SCREENAdobe interview questions
  • 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • 3SumAmazon · PHONE SCREEN
  • Sort Ones, Twos, and Threes In PlaceAgoda · PHONE SCREEN · ONSITE INTERVIEWAgoda interview questions
  • Find All Pythagorean TripletsDell Technologies · PHONE SCREENDell Technologies interview questions
  • Meeting Rooms IIUber · PHONE SCREENUber interview questions
  • Sort a Quadratic-Transformed ArrayLinkedIn · PHONE SCREENLinkedIn interview questions
  • Find K Closest Elements in a Sorted ArrayNavi · PHONE SCREEN
  • Sort ColorsVisa · PHONE SCREENVisa interview questions

Interview reports that mention this question

  • Google SWE III ML Experienced Loops: 10 Experiences (Part 3 of 4)

Google interview experiences

  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
  • Google AI Coding Interview and AI OA: 2 Experiences
  • Google SWE Intern Interview Results Timeline: 13 Experiences
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public long countWinningDicePairs(int[] dieA, int[] dieB) {
        // Write your code here.
    }
}
Checking account…