Count all subarrays whose sum can be split as difference of squares of two Integers | Function to count all the non - contiguous subarrays whose sum can be split as the difference of the squares ; Loop to iterate over all the possible subsequences of the array ; Finding the sum of all the possible subsequences ; Condition to check whether the number can be split as difference of squares ; Driver code
def Solve ( arr , n ) : NEW_LINE INDENT temp = 0 ; count = 0 ; NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT temp = 0 ; NEW_LINE for j in range ( i , n ) : NEW_LINE INDENT temp = temp + arr [ j ] ; NEW_LINE if ( ( temp + 2 ) % 4 != 0 ) : NEW_LINE INDENT count += 1 ; NEW_LINE DEDENT DEDENT DEDENT return count ; NEW_LINE DEDENT arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ; NEW_LINE N = len ( arr ) ; NEW_LINE print ( Solve ( arr , N ) ) ; NEW_LINE