- bahii honii we have “Count the Number of Incremovable Subarrays I” —> bahiii honii we…
- User
[image: image.png] open
- bahii honii we have “Count the Number of Incremovable Subarrays I”
—> bahiii honii we have 0-indexed array of postive intergers “nums”
- A Subarray of “nums” is called “incremovable” if nums becomes strictly increasing on removing the subarray
- bahii ke exmple : the subarray [3,4] , is an incremovable subarray of [5,3,4,6,7] because removing this subarray changes the array [5,3,4,6,7] to [5,6,7] which is striclty increasing
- bahiii honii we need to return thr total number of “incremovable” subarrays of nums
- bahii awll 7aje “ an empty array is considered striclty increasing”
→ bahii the “subarray” is a contigous non-empty sequance of elements within an array
[image: image.png] open
Q- what is the input output & format ?
- input : List[int]
- output : int
Q- can you go through an exmple ?
nums=[1,2,3,4]
bahii awll 7aje we need to check if all the subarray and how to removing them will work yes or non ?
Q- let’s try to check the naive solution here ?
a naive solution will be just generate all the possible subarray
then remove them( vittualy ) and chekc if the remaining array is sorted okii yes or non ?
generate for me all the subarray of this [1,2,3,4]
Sure! Here are all the subarrays of the array
[1, 2, 3, 4]:[1][2][3][4][1, 2][2, 3][3, 4][1, 2, 3][2, 3, 4][1, 2, 3, 4]
These are all the possible contiguous subarrays of the given array.
next for each one remove the subarray form the orginal array and return it
generete all the reaming arrr after removing the subarray from the last generated ones
- Assistant