We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

Brute force approach will not be sufficient to solve this problem.because time complexity of brute force algorithm is O(n * m) which is very high, for given time constraint, so you need better approach which beats O(nm).

If interested to know why your solution did not work out.

If you are thinking that you are saving your time just by seeing the code then you are missing alot. this tutorial is definately half an hour but you will learn something new. I have not taken half an hour just to explain the code,instead shows my approach towards the problem.

My code only help to solve this problem but tutorial will help to solve problems which is based on this pattern.

After 2 days I was finally able to watch your video, plus the 2 videos explaining the Prefix sum algorithm, and I want to say thank you.
Your video is very detailed and simple to understand, I didn't even know the existence of the Prefix sum algorithm until now.

I have subscribed to your youtube channel because I like the way you explain the concepts of an algorithm. I can't wait to see more videos from your channel.

Thanks @Simone_starace93 for your feedback and appreciating the effort which i have put in for my videos. It really motivate me to do more for you all.

We need people like you who provide detailed feedback. it does not matter whether the feedback is positive or negative. but it always helps creators to understand more about the audience and their taste.

## Array Manipulation

You are viewing a single comment's thread. Return to all comments →

Hello friends,

Brute force approach will not be sufficient to solve this problem.because time complexity of brute force algorithm is O(n * m) which is very high, for given time constraint, so you need better approach which beats O(nm).

If interested to know why your solution did not work out.

click here for the

video explanation of generic algorithmwith complexity analysis.or you can click on the image too to follow youtube tutorial.

Here is the working solution with O(n+m) complexity:-source code :Would really appreciate your feedback like, dislike , comment etc. on my video.

## Do not forget to upvote, if you find it useful.

thanks brother

most welcome. It would be great if you can provide your feedback like, dislike , comment etc. on my video. It motivate me to do more for you all

I dont understand why you do this

outputArray[b+1] -= k;

Watch the tutorial, you will come to know the reason behind this and why nomral algorithm will not be able to pass all test cases.

half an hour is too long :(

If you are thinking that you are saving your time just by seeing the code then you are missing alot. this tutorial is definately half an hour but you will learn something new. I have not taken half an hour just to explain the code,instead shows my approach towards the problem.

My code only help to solve this problem but tutorial will help to solve problems which is based on this pattern.

After 2 days I was finally able to watch your video, plus the 2 videos explaining the

Prefix sum algorithm, and I want to say thank you. Your video is very detailed and simple to understand, I didn't even know the existence of the Prefix sum algorithm until now.I have subscribed to your youtube channel because I like the way you explain the concepts of an algorithm. I can't wait to see more videos from your channel.

Thanks @Simone_starace93 for your feedback and appreciating the effort which i have put in for my videos. It really motivate me to do more for you all.

We need people like you who provide detailed feedback. it does not matter whether the feedback is positive or negative. but it always helps creators to understand more about the audience and their taste.

**still Im getting segment error for testcase 7 **

long arr[n+2]; for(long i=0;i

Did you watch the complete video ?

thank you brother