Problem Link: www.codechef.com/problems/ONETOTHREE
@samwilder61994 күн бұрын
In this can't we just from left to right twice it should be able to give the same answer or am i wrong
@codeNLearnNCode4 күн бұрын
no that will not help why let's see one example 2 3 3 3 3 1 once you iterated from left to right 2 3 3 3 1 1 second time you did 2 3 3 1 1 1 but still you need to one more time in order to minimize the sum that is why it is better to iterate from right after left iteration as it will get sorted out in one loop (from right)