human
Smallest subset with sum greater than all other elements | function to find minimum elements needed ..
calculating HALF of array sum.
sort the array in descending order ..
current sum greater than sum.
driver code"
How can the above be solved in Python?
 What is a code to smallest subset with sum greater than all other elements and the other steps required?
assistant
#Here is code to smallest subset with sum greater than all other elements and the other steps required.
 def minElements ( arr , n ) :
	halfSum = 0
	for i in range ( n ) :
		halfSum = halfSum + arr [ i ]
	halfSum = int ( halfSum / 2 )
	arr . sort ( reverse = True )
	res = 0
	curr_sum = 0
	for i in range ( n ) :
		curr_sum += arr [ i ]
		res += 1
		if curr_sum > halfSum :
			return res
	return res
arr = [ 3 , 1 , 7 , 1 ]
n = len ( arr )
print ( minElements ( arr , n ) )