3898. Find the Degree of Each Vertex
You are given a 2D integer array
matrixof sizen x nrepresenting the adjacency matrix of an undirected graph withnvertices labeled from 0 ton - 1.
matrix[i][j] = 1indicates that there is an edge between verticesiandj.matrix[i][j] = 0indicates that there is no edge between verticesiandj.The degree of a vertex is the number of edges connected to it.
Return an integer array
ansof sizenwhereans[i]represents the degree of vertexi.
1 | class Solution { |