The TransCompilator

Solved LeetCode program · 618 of 1,000

#0846 · Hand of Straights

Medium Array chunk-13.md

Original English source

Keep a shared hand holding 1, 2, 3, 6, 2, 3, 4, 7, and 8. Keep a shared used holding 0, 0, 0, 0, 0, 0, 0, 0, and 0. Keep a shared last of 0. Keep a shared hit of 0.

To seek from look (a whole number) with want (a whole number). If look is more than last, return. If item look of used is 0 and item look of hand is want, set hit to look, return. Seek from look plus 1 with want.

Set last to 8. Sort hand. The possible is 1. The group is 3.
For every spot from 0 to last.
If possible is 0, stop.
If item spot of used is 0.
The base is item spot of hand. The need is 0.
Repeat while need is less than group and possible is 1.
Set hit to -1. Seek from spot with base plus need. If hit is less than 0, set possible to 0. If hit is at least 0, set item hit of used to 1. Add 1 to need.

If possible is 1, show true, otherwise show false.

Open in Playground Browse all 1,000 problems

Expected stdout

true