Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Simplified Poker Winner
00:00
5 left

Simplified Poker Winner

HardPython

Problem

Samba TV's audience measurement pipelines may need deterministic ranking logic when multiple candidate records receive the same score. Implement a simplified poker evaluator that compares five-card hands and identifies the winning hand or hands.

Each card is represented by an integer rank from 2 through 14, where 14 represents an ace. Suits are irrelevant. Rank hands using these categories, from strongest to weakest: four of a kind, full house, three of a kind, two pair, one pair, and high card. A hand's category is determined by the frequency of its ranks.

Return a list containing the zero-based indices of every hand tied for the best result. Within the same category, compare the relevant repeated ranks first, then compare remaining cards in descending order. For example, a higher four-of-a-kind wins, and equal four-of-a-kind hands compare their kicker cards. Return the tied indices in ascending order.

Formal Specification

Input hands is a list of at least two five-element integer lists. Output is a list of integer indices. All hands are valid, and no hand contains duplicate physical cards. Suits are omitted, so identical ranks may appear in different hands.

Constraints

  • 2 <= len(hands) <= 10^5
  • Every hand contains exactly five ranks
  • 2 <= rank <= 14
  • Suits are irrelevant
  • All input hands are valid

Function Signature

def winning_hands(hands):
Interviewer

Your question is Simplified Poker Winner. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.