package leetcode;

/**
 * https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array/
 */
public class Problem1558 {
    public int minOperations(int[] nums) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1558 prob = new Problem1558();
        System.out.println(prob.minOperations(new int[]{1,5})); // 5
        System.out.println(prob.minOperations(new int[]{2,2})); // 3
        System.out.println(prob.minOperations(new int[]{4,2,5})); // 6
        System.out.println(prob.minOperations(new int[]{3,2,2,4})); // 7
        System.out.println(prob.minOperations(new int[]{2,4,8,16})); // 8
        System.out.println(prob.minOperations(new int[]{2,3,10})); // 8
    }
}

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -217,32 +217,507 @@
     
-// TODO%0A        return 0
+int answer = nums.length;%0A        int max = Arrays.stream(nums).max().getAsInt();%0A        int val = (int) (Math.log(max) / Math.log(2));%0A        answer += val;%0A        answer += max %25 val;%0A        for (int num : nums) %7B%0A            if (num == 0) %7B%0A                answer--;%0A                continue;%0A            %7D%0A            if (num == 1 %7C%7C num == max) %7B%0A                continue;%0A            %7D%0A            if (num %25 2 != 0) %7B%0A                answer++;%0A            %7D%0A        %7D%0A        return answer
 ;%0A  
@@ -1164,24 +1164,24 @@
 16%7D)); // 8%0A
-
         Syst
@@ -1236,20 +1236,96 @@
 10%7D)); // 8%0A
+        System.out.println(prob.minOperations(new int%5B%5D%7B2,3,10,89%7D)); // 15%0A
     %7D%0A%7D%0A

Update problem 1558