Message from C, C++ talks

June 2019

— Yes

— Oh, and also, I think the removement of elements can be eliminated here somehow. It can be faster without removement, also in real world situation you may want to keep the data immutable.

Message permanent page

— Also if I remove elements then step 1.2.3 messes up

— Not waiting for tommorow morning. I'm doing it now

— 

No, it shouldn't, because you don't need to save value of removed item (it doesn't matter what value the deleted item had)

— Ok, I'm trying.

— I tried and the code doesn't works😢.

— Ignore unnecessary declared variables.

— Thanks

— Welcome

— Welcome

— Oh, yeah, there's is a mistake in my previous algorithm.

The original algorithm can delete several consequent values in one iteration (I didn't consider this) but stops deleting values when it incounters one that was not bigger than previous one. Neighboring values change over iterations, but the good thing, that they change only from left to right.

So we need to find biggest count of small ranges of ascending values inside bigger ranges between the approved values (that will go to the final list).

Message permanent page

— Basically in 2 3 4 3 1 in this case we know that
2 1 going to be left
But in two iterations
2 3 5 4 1 = 2
2 4 1 = 1
2 1 = 0

Where this going to be unchsnged
3 2 1 = 0

Message permanent page

— Inside of if p[i] > pre we probably need to check that p[i] <= p[i-1] and only in this case increment count.

But then the result is going to be smaller by one if it's non-zero.

I think we can just do something like

if (count != 0) count++;

Before returning the value.

I think it can be made more elegantly than this, but I'm too lazy to think now.

Also, you need a check in case the vector is empty, not to crash.

Message permanent page

— Yes, my explanation is above this message, I still have no idea whether the new solution is working or not :D

Message permanent page