PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates a candidate's ability to map and manipulate encoded card ranks, reason about consecutive sequences with Ace-as-low or Ace-as-high semantics, and identify a missing element within a constrained set.

  • easy
  • Pinduoduo
  • Coding & Algorithms
  • Software Engineer

Find missing rank in a straight

Company: Pinduoduo

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Onsite

You are given a list of **4 distinct characters** representing card ranks from a **5-card straight** (5 consecutive ranks) with **exactly one rank missing**. Ranks come from the set `{A,2,3,4,5,6,7,8,9,10,J,Q,K}`. To keep each rank as a single character, the input uses this encoding: - `'0'` represents **Ace** (`A`). - `'2'`–`'9'` represent ranks 2–9. - `'T'` represents 10. - `'J'`, `'Q'`, `'K'` represent Jack/Queen/King. Aces can be used as **low** in the straight `A-2-3-4-5` (treat Ace as value 1 in this case). Otherwise Ace is high above King. Return the **missing rank** using the same encoding (i.e., return `'0'` if the missing rank is Ace). Example: - Input: `['3','4','5','6']` → missing is `'2'` (straight `2-3-4-5-6`) - Input: `['0','2','3','5']` → missing is `'4'` (straight `A-2-3-4-5`)

Quick Answer: This question evaluates a candidate's ability to map and manipulate encoded card ranks, reason about consecutive sequences with Ace-as-low or Ace-as-high semantics, and identify a missing element within a constrained set.

Given four distinct encoded ranks from a five-card straight, return the missing encoded rank.

Constraints

  • Input ranks are distinct
  • A valid unique straight exists for the tests

Examples

Input: (['3', '4', '5', '6'],)

Expected Output: '2'

Explanation: Straight 2-6 is missing 2.

Input: (['0', '2', '3', '5'],)

Expected Output: '4'

Explanation: Ace-low straight is missing 4.

Input: (['9', 'T', 'J', 'Q'],)

Expected Output: '8'

Explanation: 9-K straight is missing K.

Input: (['T', 'J', 'Q', '0'],)

Expected Output: 'K'

Explanation: High-ace straight is missing K.

Hints

  1. Enumerate the valid five-rank straights and find the one containing all four input ranks.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Find Shortest Square-Sum Path - Pinduoduo (hard)
  • Compute User Login Streaks - Pinduoduo (easy)
  • Determine Straight Flush - Pinduoduo (easy)
  • Design a Recency-Eviction Cache - Pinduoduo (medium)
  • Find next greater element for subset - Pinduoduo (easy)