Check if any valid sequence is divisible by M |  ; Base case ; Check if sum is divisible by M ; 1. Try placing ' + ' ; 2. Try placing ' - '
function isPossible ( index , sum ) { if ( index == n ) { if ( ( sum % M ) == 0 ) return true ; return false ; } let placeAdd = isPossible ( index + 1 , sum + arr [ index ] ) ; let placeMinus = isPossible ( index + 1 , sum - arr [ index ] ) ; if ( placeAdd placeMinus ) return true ; return false ; }