In this post, we are going to discuss leetcode 1296 — Divide Array in Sets of K Consecutive Numbers, which is recently asked in Google interviews.
Problem Analysis
Given an array of integers
nums
and a positive integerk
, check whether it is possible to divide this array into sets ofk
consecutive numbers.Return
true
if it is possible. Otherwise, returnfalse
.
Example 1:
Input: nums = [1,2,3,3,4,4,5,6], k = 4
Output: true
Explanation: Array can…