Count Strictly Increasing Subarrays | GeeksforGeeks

Sdílet
Vložit
  • čas přidán 27. 07. 2024
  • Explanation for the article: www.geeksforgeeks.org/count-st...
    Know More: www.geeksforgeeks.org/count-s...
    This video is contributed by Harshit Jain.

Komentáře • 17

  • @tapanbhardwaj9675
    @tapanbhardwaj9675 Před 6 lety +3

    These videos are very helpful. Keep going.

  • @ShivaniSingh-us5iw
    @ShivaniSingh-us5iw Před 3 lety

    Thanks alot sir

  • @reyou7
    @reyou7 Před 7 lety +1

    nice video guys! keep going.

  • @168Abhinav
    @168Abhinav Před 5 lety

    Gud

  • @rohitpal36
    @rohitpal36 Před 4 lety +1

    have a look at my code ->
    int count(int *arr,int n){
    int temp_count=0,k,count=0;
    for(int i=0;i

  • @veerrajuyeleti8541
    @veerrajuyeleti8541 Před 7 lety

    sir could you explain with an example

    • @GeeksforGeeksVideos
      @GeeksforGeeksVideos  Před 7 lety +2

      Hi Veerraju,
      We've discussed examples from 0:50 to 2:20.
      Do you mean dry run of the code?

  • @indiacricket8238
    @indiacricket8238 Před 3 lety

    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;
    )

  • @Bhatonia_Jaat
    @Bhatonia_Jaat Před 3 lety

    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!

  • @wecan2729
    @wecan2729 Před 3 lety

    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;
    }
    };

  • @kaifahmad4131
    @kaifahmad4131 Před 3 lety

    // 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

  • @suryakantsapkal8242
    @suryakantsapkal8242 Před 4 lety

    I believe last algorithm does not produce correct result for input like 9, 1, 11, 10

    • @devanggupta9986
      @devanggupta9986 Před 4 lety

      i am not sure but first we will have to sort the array and then use the last algorithm

    • @devanggupta9986
      @devanggupta9986 Před 4 lety

      what about if we have a repeating element in the sub array

    • @insofcury
      @insofcury Před 4 lety +2

      well if you sort the array the whole array changes, the idea was to find increasing subarrays in the one we have here

    • @insofcury
      @insofcury Před 4 lety

      @@devanggupta9986 We will not consider it as it clearly says strictly increasing