Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
Sorry to say, but you are completely off track. I suspect your understanding of adjacency matrices is wrong, so my advice is to read more about that, preferably with an example matrix, and also about graphs (directed/undirected) and how an adjacency matrix represents a graph All need to do to solve the task is count the number of ones in the row (or column since the matrix is symmetric (i.e. the graph is undirected) ) given by input. It is given as a 1-based index, so subtract 1 like in the add/remove methods. So for n=3 count the number of ones in the third row (index 2)
6th May 2021, 9:51 AM
Benjamin Jürgens
Benjamin Jürgens - avatar