Company: Salesforce_8dec
Difficulty: medium
Salesforce data processing system Salesforce is designing an energy-efficient data processing system for its servers. Given a positive integer n , which represents the initial energy level of a server, the system can adjust the energy level in a single operation using one of the following actions: Increase the energy level by 2 i for any i ≥ 0 Decrease the energy level by 2 i for any i ≥ 0 The goal is to determine the minimum number of operations required to reduce the energy level n to 0, ensuring the system is efficiently shut down. Example 1 Input: n = 5 Output: 2 Explanation: n can be reduced to 0 using two operations. Choose i = 0, subtract 2 0 from 5. Current value: 5 - 1 = 4. Choose i = 2, subtract 2 2 from 4. Current value: 4 - 4 = 0. The answer is 2. It can be shown that the answer cannot be less than 2. Example 2 Input: n = 21 Output: 3 Explanation: Choose i = 0, subtract 2 0 = 1 from 21, converting it to 20. Choose i = 2, subtract 2 2 = 4 from 20, converting it to 16. Choose