Java program for the above approach
import java . util . * ; class Solution { public static void main ( String [ ] args ) { int arr [ ] = { 10 , 2 , - 2 , - 20 , 10 } ; int k = - 10 ; int n = arr . length ; int res = 0 ;