How to solve questions of type maximize result/best combination /highest total possible etc?

Friends, how does one solve questions that require us to find maximum possible value or the one that tells us to find the best way of doing things in the shortest time and other such types of questions which basically require us to do the same thing; find the best combination. (if you think the description is unclear or vague please tell me in comments,I will do my best to be as clear and possible)

I am trying to improve myself as a programmer and I have encountered these type of questions many times. Kindly share your valuable answers, suggestions and advice :blush: .
And thanks for your time :star_struck: