Standard Bar Heaps · Medium Problems O(n log n) · O(n)
A hotel allocates room blocks to tour groups: each block must be k consecutive room numbers, and every room number in the inventory list must be used exactly once. The allocator walks room numbers in ascending order, and whenever it opens a new block at a room, it must be able to claim the next k-1 rooms without conflict.
Input: An integer array nums of room numbers and an integer k, the block size.
Output: Return true if the inventory can be partitioned into sets of k consecutive numbers, false otherwise.
1 <= k <= nums.length <= 10^50 <= nums[i] < 10^9nums.length is divisible by k for a valid partitionInput: {"nums":[1,2,3,3,4,4,5,6],"k":4}
Output: true
Blocks [1,2,3,4] and [3,4,5,6] consume every room exactly once.
Input: {"nums":[1,2,3,4],"k":3}
Output: false
Four rooms cannot split into blocks of three.