Saturday, January 20, 2018

Maximum number of chunks

January 20, 2018


Introduction


It is so surprising to know the difference. I compared two people, one with over five years experience, with top four companies; another one is graduating and looking for job, with open source project experience. But the later on is studying in K.I.T. in German. How does those two to work on this maximum number of chunks algorithm.


Problem solving


The one with practice of one-third of elements of programming interviews handled the algorithm very quick and easily. He is really a good thinker, he did not need to write down anything, basically he just communicated with me his ideas using pure words. And then I had a short discussion with him, I asked him we do not need to sort the numbers.

I wrote down his thoughts on my paper:
In order to close the chunk, every number of smaller of max should be visited. Keep track max/ min elements.

And we discussed that sorting is not necessary, so he quickly came out the idea to preprocess the array with max/ min value for each index, one is called prefix, left to right iteration.


No comments:

Post a Comment