human
Subarray whose absolute sum is closest to K | Python Code to find sub - array whose sum shows the minimum deviation.
starting index , ending index , Deviation.
iterate i and j to get all subarrays.
found sub - array with less sum.
exactly same sum.
Driver Code.
Array to store return values"
How can the above be solved in Python?

=====
Can you provide a code to subarray whose absolute sum is closest to K and the other steps required?
assistant
#Here is code to subarray whose absolute sum is closest to K and the other steps required.
 def getSubArray ( arr , n , K ) :
	i = - 1
	j = - 1
	currSum = 0
	result = [ i , j , abs ( K - abs ( currSum ) ) ]
	for i in range ( 0 , n ) :
		currSum = 0
		for j in range ( i , n ) :
			currSum += arr [ j ]
			currDev = abs ( K - abs ( currSum ) )
			if ( currDev < result [ 2 ] ) :
				result = [ i , j , currDev ]
			if ( currDev == 0 ) :
				return result
	return result
def main ( ) :
	arr = [ 15 , - 3 , 5 , 2 , 7 , 6 , 34 , - 6 ]
	n = len ( arr )
	K = 50
	[ i , j , minDev ] = getSubArray ( arr , n , K )
	if ( i == - 1 ) :
		print ( " The ▁ empty ▁ array ▁ shows ▁ minimum ▁ Deviation " )
		return 0
	for i in range ( i , j + 1 ) :
		print arr [ i ] ,
main ( )