Limited time: AI code review, hints, mock interviews, whiteboard analysis, and all Pro features are unlocked. Enroll

Hand of Straights

Medium

Topics
ArrayGreedyHash TableSorting

Given an array hand of card values and a group size k (LeetCode: groupSize), return true if the cards can be rearranged into groups of k consecutive cards.

Example 1

Input:  hand = [1,2,3,6,2,3,4,7,8], k = 3
Output: true

Example 2

Input:  hand = [1,2,3,4,5], k = 4
Output: false

Constraints

  • 1 <= hand.length <= 10^4
  • 0 <= hand[i] <= 10^9
  • 1 <= k
Run ⌘' · Submit ⌘⏎
SensAI SensAI
Beta
Listening...
Tap mic to stop voice mode

Unlock AI Features

One click to activate - no payment, no credit card. Just sign in and you're in.

AI code review and hints
SensAI chat assistant
AI mock interviews
Whiteboard analysis
100% free during early access