Leetcode 1296 - Divide Array in Sets of K Consecutive Numbers

Note:

• Same question as Leetcode 846.
• However, avoiding using shift() cuz it’s too time consuming.
• Just use an index j to mark the position.

Question:

Given an array of integers nums and a positive integer k, find whether it is possible to divide this array into sets of k consecutive numbers.

Return true if it is possible. Otherwise, return false.

Example:

Code: