Google L4 Onsite Interview Question

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2025-06-07Added By Anonymous
Source: Link
1You are given two N-sided dice, P and Q, where each die has N integer values (not necessarily unique or standard). 2 3When rolled, each side is equally likely to appear. 4 5Given the values on each side of dice P and Q, determine: 6 7The number of outcomes where P's roll is greater than Q's roll (i.e., P wins). 8 9Follow up 1: The number of outcomes where Q wins. 10 11Follow up 2: The number of outcomes where both rolls are equal (tie). 12 13Example: (N=3) 14 15P = [1, 2, 4] 16Q = [2, 2, 5] 17 18 19Edit 1: Forgot to add that P and Q are always in non-decreasing sorted order. 20^ This information was not provided, I had to ask clarifying questions to get it. 21So if you start coding without asking this, you probably end up with a non-optimal solution.
Comments