xxxxxxxxxx
// Java implementation of
// the above approach
import java.util.*;
class GFG{
// Function which returns
// the maximum number of
// isolated nodes
static int maxDisconnected(int N, int E)
{
// Used nodes
int curr = 1;
// Remaining edges
int rem = E;
// Count nodes used
while (rem > 0)
{
rem = rem - Math.min(
curr, rem);
curr++;
}
// If given edges are non-zero
if (curr > 1)
{
return N - curr;
}
else
{
return N;
}
}
// Driver Code
public static void main(String[] args)
{
// Given N and E
int N = 5, E = 1;
// Function call
System.out.print(maxDisconnected(N, E));
}
}
// This code is contributed by 29AjayKumar