Message from C, C++ talks

June 2019

— It can be solved just by using array indexing and deleting

— How can it be solved in one iteration

— I will post my code to this tomorrow in python 3

— The test codes have around 100000 integers as input


I'm not sure I understand it either :)
I mean that complexity can be something like O(n), if I'm right

— Yeah if it works with one loop

— No problem at all

— Python can easily handle big data

— 👌 will wait for your code... Maybe I can convert it into c++ , i know a little python

— Yep

— Exactly.
My idea is, you have one loop
Before it you remember the first value as previous and start the loop from the second item
Also have count and max_count values set to 0
In the loop
1) you check that the value is bigger than previous
1.1) if 1) is true, you increment count and remove the value
1.2) if not, you check that count bigger than max_count
1.2.1) if 1.2.1) true then max_count = count
1.2.2) set count to zero
1.2.3) set previous to current value

max_count (or -1) probably would be the answer

Message permanent page

— Numbering is broken by the way :)

— Hope you get the idea, but not sure if it works :)

— After removing the larger values , I will be left with another small array of levels of pesticides and this again needs to be sorted out by removing the rightside value if it's bigger

Message permanent page

— So doing it again will need an another loop