I solved the problem by taking the maximum weight first and then further checking if one more child can be fit into the same gondola. As per the question, atmost 2 children can only sit in one gondola but I was thinking if this constraint was not present then will the same solution work i.e first try to make sit all the heavy weights children till weight does not exceed x and then add new children of small weights till we did not exceed the limit. I am confused will the same solution will work or not Question link