3252. Count the Number of Incremovable Subarrays I
My accepted Python solution to LeetCode problem 3252, Count the Number of Incremovable Subarrays I, running in 194ms.
- Difficulty: Easy
- Python
- Runtime 194ms
- Memory 17.3MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 194ms, memory 17.3MB, accepted 2026-01-02.
class Solution:
def incremovableSubarrayCount(self, nums: List[int]) -> int:
n = len(nums)
count = 0
for i in range(n):
for j in range(i, n):
# Remove subarray from i to j
remaining = nums[:i] + nums[j+1:]
if len(remaining) == 0:
count += 1
else:
is_strictly_increasing = True
for k in range(1, len(remaining)):
if remaining[k] <= remaining[k-1]:
is_strictly_increasing = False
break
if is_strictly_increasing:
count += 1
return count