I came across this question in an interview with a php development engineer, which was the last one in the written exam
there is a service platform. Users need to charge a service fee for providing services, but there is a ladder relationship between the service charge and the number of orders. Please calculate the total service charge for a specified number of orders according to the following charging standard. How much service fee does the user need to pay if the user places 8 orders?
shows the given column:
because the user needs to pay a service charge of RMB 245
because he / she needs to pay RMB 551, 330, 15590, 245.
ideas for solving problems at that time
I didn"t think of a better way during the interview at that time. My idea of solving the problem was to generate a large array of this ladder relationship according to the corresponding price of solving the problem. If there are 8 orders, it is calculated by calculating the sum of array elements with subscript 0 to subscript 7, and if it is greater than the maximum number of ladders, then judge and calculate separately. If there is a better way to solve the problem, I hope you will actively share
purpose
the reason why I want to contribute to this problem is that I want to find more solutions through your wisdom, so that I can learn new solutions from them. Welcome to write an algorithm using php code