Count the Leaves

Computer Science Level pending

Here is the adjacency matrix of a (undirected) tree.

A vertex of a tree is a leaf, iff there is only one edge connected to it.

What is the number of leaves in the given tree?

Input Format and Constraints

  • The given tree is of 100 vertices.
  • There are 100 lines in the file with 100 space separated integers on each line.
  • If the \(j^\text{th}\) integer in the \(i^\text{th}\) line is 1, there is an edge connecting \(i\) and \(j\). Otherwise, there is no such edge.

Problem Loading...

Note Loading...

Set Loading...