← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Poker Straight Detection is a common coding interview problem involving arrays, sorting, and sets (or unique values) to check if a hand of cards forms a straight in poker.
Given an array of integers representing card ranks (typically 2-14, where 11=Jack, 12=Queen, 13=King, 14=Ace), determine if there exists a subsequence of exactly 5 consecutive ranks (a straight). Cards may have duplicates, so first remove them to get unique ranks. A valid straight requires 5 distinct ranks where each is exactly one more than the previous after sorting.[1][2][5]
[12, 5, 6, 7, 4, 11, 3] → Unique sorted: [3,4,5,6,7,11,12] → Output: true (straight: 3-4-5-6-7)[1][10, 9, 8, 7, 6] → Unique sorted: [6,7,8,9,10] → Output: true (full straight)[2][5][2, 3, 5] → Unique sorted: [2,3,5] → Output: false (fewer than 5, gap between 3-5)[14, 2, 3, 4, 5] → Unique sorted: [2,3,4,5,14] → Output: true (straight: 2-3-4-5, Ace high variant possible but basic checks 2-5 as partial; standard requires full 5 consecutive)[5][1, 1, 2, 3, 4] → Unique sorted: [1,2,3,4] → Output: false (only 4 cards after dedup)[1]