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)
Problem Link: www.codechef.com/problems/ONETOTHREE
In this can't we just from left to right twice it should be able to give the same answer or am i wrong
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)
Got it thanks