Maximize count of nodes disconnected from all other nodes in a Graph | Function which returns the maximum number of isolated nodes ; Used nodes ; Remaining edges ; Count nodes used ; If given edges are non - zero ; Given N and E ; Function call
function maxDisconnected ( N , E ) { let curr = 1 ; let rem = E ; while ( rem > 0 ) { rem = rem - Math . min ( curr , rem ) ; curr ++ ; } if ( curr > 1 ) { return N - curr ; } else { return N ; } } let N = 5 , E = 1 ; document . write ( maxDisconnected ( N , E ) ) ;