You are on page 1of 1

General 1

You are given 2 bottles, a 3-liter bottle and a 5-liter bottle. You are asked to measure 4 liters of water
with 2 bottles. You have unlimited water sources. Explain in detail your steps to get 4 liters of water?

General 2

There are N sticks, with various lengths. Then do the bulk cutting of the N stick along the smallest
stick that is there. After that, the cutting of the remaining stick along the smallest stick is done, and
so on until it runs out.

Input as follows:

N = Number of sticks (positive integers)

arr = An array containing the length of each stick (the size of the array is N)

Write down the program to find out how many times the cut is needed so that it cannot be cut back.
Example:

N=4

arr = [5, 3, 1, 6]

Cutting:

5 3 1 6 (cut 1)

4 2 5 (cut 2)

2 3 (cut 2)

1 (cut 1), done. Answer = 4

You might also like