info@meritcampus.com    +91-85006-22255
...

Write a program to identify the minimum set of weights which are required for weighing any weight. Assume that pan balance is used for weighing and we can put weights in either of the pans. By just using the weights from the returned list, we should be able to weigh any weight till the maximum weight. If the maximum weight is 15, we should be able to weigh 4 or 7 or 8 or 15, just using those weights returned.

Input (Integer) Output List
5 [1, 3, 1]
81 [1, 3, 9, 27, 41]
121 [1, 3, 9, 27, 81]
200 [1, 3, 9, 27, 81, 79]
5116 [1, 3, 9, 27, 81, 243, 729, 2187, 1836]
0 null

``` import java.util.*; class GetMinimumSetOfWeights {     public static void main(String s[])    {        List<Integer> output = getRequiredWeights(15);        System.out.println("The minimum set of weights required are : " + output);    }     public static List<Integer> getRequiredWeights(int maximumWeight) { ```
```     } } ```

Topic: Java ArrayList

0
Wrong
Score more than 2 points