Monday, March 9, 2020

HackWithInfy Problem | Animatter With Particles

“Animatter With Particles”

Given an integer(n) denoting the no. of particles initially.
Given an array of sizes of these particles.
These particles can go into any number of simulations (possibly none).
In one simulation two particles combines to give another particle with size as the difference between the size of them (possibly 0).

Find the smallest particle that can be formed.

Constraints
n<=1000
size<=10e9

Input 1
3
30 10 8

Output 1
2

Explanation- 
10 - 8 is the smallest we can achieve.

Input 2 
4
1 2 4 8

Output 2
1

Explanation 
We cannot make another 1 so as to get 0 so smallest without any simulation is 1.

Input 3 
5
30 27 26 10 6

Output 3
0

Explanation
30-26=4
10-6 =4
4-4 =0


No comments:

Post a Comment