Tap here to switch tabs
Problem
Submissions

Problem: Find the Degree of Each Vertex

Try to solve the Find the Degree of Each Vertex problem.

Statement

You are given an nimesnn imes n symmetric binary adjacency matrix matrix representing an undirected graph with nn vertices labeled from 00 to n−1n - 1.

The entry matrix[i][j] is 11 if an undirected edge connects vertex i and vertex j, and 00 otherwise.

Return an array containing the degree of each vertex, where the degree of vertex i is the total number of edges connected to it.

Constraints:

  • 1≤n==1 \leq n == matrix.length ==== matrix[i].length ≤100\leq 100

  • matrix[i][i] =0= 0

  • matrix[i][j] is either 00 or 11

  • matrix[i][j] ==== matrix[j][i]

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Degree of Each Vertex

Try to solve the Find the Degree of Each Vertex problem.

Statement

You are given an nimesnn imes n symmetric binary adjacency matrix matrix representing an undirected graph with nn vertices labeled from 00 to n−1n - 1.

The entry matrix[i][j] is 11 if an undirected edge connects vertex i and vertex j, and 00 otherwise.

Return an array containing the degree of each vertex, where the degree of vertex i is the total number of edges connected to it.

Constraints:

  • 1≤n==1 \leq n == matrix.length ==== matrix[i].length ≤100\leq 100

  • matrix[i][i] =0= 0

  • matrix[i][j] is either 00 or 11

  • matrix[i][j] ==== matrix[j][i]