Fraudulent Activity Notifications

  • + 1 comment

    @raghav_prakash, Every thing is fine in your code, except this portion of calculating count array // subArrayAsList size is d(0<=d<=n) which leads to O(n*n). for(int elem : subArrayAsList)
    countArray[elem]++;

    So do not create countArray every time.

    create countArray[] of size 201 first time with give d for say 5

    d1, d2, d3, d4, d5

    from next iteration onwards use same countArray which is created earleir with d6 insertion and d1 removal.