Hero has a simple undirected graph.
(*Simple* means that each edge connects two different vertices, and each pair of vertices is connected by at most one edge.)
A graph is considered pretty if it is a simple undirected graph in which each connected component contains an even number of edges.
You are given the adjacency matrix of Hero's graph as a String[] **graph**.
('Y' means that the two vertices are connected by an edge, 'N' means that they aren't.)
Change Hero's graph into a pretty graph by adding as few edges as possible.
Return the minimum number of edges you have to add, or -1 if Hero's graph cannot be changed into a pretty graph. |