java.lang.Object
g2701_2800.s2749_minimum_operations_to_make_the_integer_zero.Solution

public class Solution extends Object
2749 - Minimum Operations to Make the Integer Zero.<p>Medium</p> <p>You are given two integers <code>num1</code> and <code>num2</code>.</p> <p>In one operation, you can choose integer <code>i</code> in the range <code>[0, 60]</code> and subtract <code>2<sup>i</sup> + num2</code> from <code>num1</code>.</p> <p>Return <em>the integer denoting the <strong>minimum</strong> number of operations needed to make</em> <code>num1</code> <em>equal to</em> <code>0</code>.</p> <p>If it is impossible to make <code>num1</code> equal to <code>0</code>, return <code>-1</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> num1 = 3, num2 = -2</p> <p><strong>Output:</strong> 3</p> <p><strong>Explanation:</strong> We can make 3 equal to 0 with the following operations:</p> <ul> <li>We choose i = 2 and substract 2<sup>2</sup> + (-2) from 3, 3 - (4 + (-2)) = 1.</li> <li>We choose i = 2 and substract 2<sup>2</sup> + (-2) from 1, 1 - (4 + (-2)) = -1.</li> <li>We choose i = 0 and substract 2<sup>0</sup> + (-2) from -1, (-1) - (1 + (-2)) = 0.</li> </ul> <p>It can be proven, that 3 is the minimum number of operations that we need to perform.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> num1 = 5, num2 = 7</p> <p><strong>Output:</strong> -1</p> <p><strong>Explanation:</strong> It can be proven, that it is impossible to make 5 equal to 0 with the given operation.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= num1 <= 10<sup>9</sup></code></li> <li><code>-10<sup>9</sup> <= num2 <= 10<sup>9</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • makeTheIntegerZero

      public int makeTheIntegerZero(int num1, int num2)