1
var isNStraightHand = function (hand, groupSize) {2
if (hand.length % groupSize !== 0) return false;6
map.set(h, map.get(h) + 1 || 1);9
// sort based on the key in asc order10
const sortedMap = new Map([...map.entries()].sort((a, b) => a[0] - b[0]));12
while (sortedMap.size) {13
// getting the first key14
const firstKey = sortedMap.keys().next().value;15
for (let i = firstKey; i < firstKey + groupSize; ++i) {16
if (!sortedMap.has(i)) {19
const freq = sortedMap.get(i);23
sortedMap.set(i, sortedMap.get(i) - 1);