K25
Adjacency List Node Degrees
Problem Statement & Objective
Calculate the degree of each node in an undirected graph given its adjacency list representation.
Function Signature (Python)
adjacency_list_node_degrees(n: int, edges: list[list[int]]) -> list[int]Input & Output Contract
Output Rule:Her düğümün derecesini içeren n elemanlı liste.
System Constraints
1 <= n <= 10^5
0 <= kenarlar.length <= 10^5Example Execution Walkthrough
n = 4, kenarlar = [[0, 1], [0, 2], [1, 2], [2, 3]]
0: 2, 1: 2, 2: 3, 3: 1 -> cevap: [2, 2, 3, 1]Example Test Scenarios (3)
Example 1
Input:
[4,[[0,1],[0,2],[1,2],[2,3]]]Expected Output:
[2,2,3,1]Example 2: Kenarsız
Input:
[3,[]]Expected Output:
[0,0,0]Example 3: Tek Kenar
Input:
[2,[[0,1]]]Expected Output:
[1,1]