Leetcode #1121: Divide Array Into Increasing Sequences
In this guide, we solve Leetcode #1121 Divide Array Into Increasing Sequences in Python and focus on the core idea that makes the solution efficient.
You will see the intuition, the step-by-step method, and a clean Python implementation you can use in interviews.

Problem Statement
Given an integer array nums sorted in non-decreasing order and an integer k, return true if this array can be divided into one or more disjoint increasing subsequences of length at least k, or false otherwise. Example 1: Input: nums = [1,2,2,3,3,4,4], k = 3 Output: true Explanation: The array can be divided into two subsequences [1,2,3,4] and [2,3,4] with lengths at least 3 each.
Quick Facts
- Difficulty: Hard
- Premium: Yes
- Tags: Array, Counting
Intuition
The output depends on how often values appear.
Counting frequencies lets us answer queries in constant time afterward.
Approach
Count occurrences with a map or array, then compute the result from those counts.
This avoids repeated scans of the input.
Steps:
- Count frequencies.
- Use counts to compute result.
- Return the computed value.
Example
Input: nums = [1,2,2,3,3,4,4], k = 3
Output: true
Explanation: The array can be divided into two subsequences [1,2,3,4] and [2,3,4] with lengths at least 3 each.
Python Solution
class Solution:
def canDivideIntoSubsequences(self, nums: List[int], k: int) -> bool:
mx = max(len(list(x)) for _, x in groupby(nums))
return mx * k <= len(nums)
Complexity
The time complexity is , and the space complexity is . The space complexity is .
Edge Cases and Pitfalls
Watch for boundary values, empty inputs, and duplicate values where applicable. If the problem involves ordering or constraints, confirm the invariant is preserved at every step.
Summary
This Python solution focuses on the essential structure of the problem and keeps the implementation interview-friendly while meeting the constraints.