sir method 2 is not working as it is not counting all the subsets of increasing sub array set correct me if i am wrong!
have a look at my code -> int count(int *arr,int n){ int temp_count=0,k,count=0; for(int i=0;i
These videos are very helpful. Keep going.
Thanks alot sir
sir could you explain with an example
Hi Veerraju, We've discussed examples from 0:50 to 2:20. Do you mean dry run of the code?
I believe last algorithm does not produce correct result for input like 9, 1, 11, 10
i am not sure but first we will have to sort the array and then use the last algorithm
what about if we have a repeating element in the sub array
well if you sort the array the whole array changes, the idea was to find increasing subarrays in the one we have here
@@devanggupta9986 We will not consider it as it clearly says strictly increasing
nice video guys! keep going.
We're glad that you like the video :)
// Count Strictly Increasing Subarrays | GeeksforGeeks //In an array function countSubArrays(arr) { let count = 0; let ind1 = 0; for(let i=1; i arr[i-1] ) { count++; console.log('Set: ',arr[i-1],arr[i]); if( (i-ind1) > 1) { count = count + (i-ind1-1); } console.log('count: ',count); } else { ind1 = i; } } return count; } let arr = [70, 74, 99, 32, 62, 30, 32, 35]; let count = countSubArrays(arr); console.log('Array: ',arr); console.log("No. of Sub Arrays: ", count); //My Solution in JS
Check it Int sum=0; Int Count=0; For(int i=1;iarr(i-1)) ( Count++; ) Else ( Count=0; ) If(Count>0) ( Sum=Sum+Count; ) ) return Sum; )
class Solution{ public: int countIncreasing(int arr[], int n) { int len=1; int count=0; for(int i=0;iarr[i]) { len++; } else { count+=len*(len-1)/2; len=1; } } if(len>1) { count+=len*(len-1)/2; } return count; } };
Gud
Пікірлер: 17
sir method 2 is not working as it is not counting all the subsets of increasing sub array set correct me if i am wrong!
have a look at my code -> int count(int *arr,int n){ int temp_count=0,k,count=0; for(int i=0;i
These videos are very helpful. Keep going.
Thanks alot sir
sir could you explain with an example
@GeeksforGeeksVideos
7 жыл бұрын
Hi Veerraju, We've discussed examples from 0:50 to 2:20. Do you mean dry run of the code?
I believe last algorithm does not produce correct result for input like 9, 1, 11, 10
@devanggupta9986
4 жыл бұрын
i am not sure but first we will have to sort the array and then use the last algorithm
@devanggupta9986
4 жыл бұрын
what about if we have a repeating element in the sub array
@insofcury
4 жыл бұрын
well if you sort the array the whole array changes, the idea was to find increasing subarrays in the one we have here
@insofcury
4 жыл бұрын
@@devanggupta9986 We will not consider it as it clearly says strictly increasing
nice video guys! keep going.
@GeeksforGeeksVideos
7 жыл бұрын
We're glad that you like the video :)
// Count Strictly Increasing Subarrays | GeeksforGeeks //In an array function countSubArrays(arr) { let count = 0; let ind1 = 0; for(let i=1; i arr[i-1] ) { count++; console.log('Set: ',arr[i-1],arr[i]); if( (i-ind1) > 1) { count = count + (i-ind1-1); } console.log('count: ',count); } else { ind1 = i; } } return count; } let arr = [70, 74, 99, 32, 62, 30, 32, 35]; let count = countSubArrays(arr); console.log('Array: ',arr); console.log("No. of Sub Arrays: ", count); //My Solution in JS
Check it Int sum=0; Int Count=0; For(int i=1;iarr(i-1)) ( Count++; ) Else ( Count=0; ) If(Count>0) ( Sum=Sum+Count; ) ) return Sum; )
class Solution{ public: int countIncreasing(int arr[], int n) { int len=1; int count=0; for(int i=0;iarr[i]) { len++; } else { count+=len*(len-1)/2; len=1; } } if(len>1) { count+=len*(len-1)/2; } return count; } };
Gud