Message from C, C++ talks

June 2019

— 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.

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

Message permanent page

— Why we get floating point error in c?
Searched google but didn't understand

— I read that

— This doesn't works for 4 5 3 2 1 6

— User Evil has 2/3 warnings; be careful!
The latest warn was because:
spam

— Ah, shi.. yes, incrementing one with that condition was a stupid inea.

Then.. we can create a new bool flag, representing whether the last processed item was good or going to be deleted. Set it to true, when we in p[i] > pre block and set it to false in the else block of this if.
And in the beginning of the block where we setting it to false do

if (isValueWasBad) count++;


So we will still increment the value in case we shold have one as the answer.

Message permanent page

— Remove value from vector is too inefficient. try to build a new vector only from required values. without removing elements by one

Message permanent page

— So what’s your problem

— Suggest best IDE for C++

— If you about what I wrote, I used "removing" to refer to part of the original alghoritm, that is being analyzed. So no removement is needed now. You can find the task and some code examples above, if you're interested.

Message permanent page