← All problemsSign in

Maximum Sum Subgraph

You are given a tree with **N** nodes. Each node **i** has value **Vi** associated with it, the values can be **negative** as well. You have to find the subgraph which consists of nodes **(U1 ,U2 ... Um) where m>=1**, and value of **(Vu1 + Vu2 + Vu3 + .... + Vum)** is **maximum**. ###Input: -First line contains total number of testcases. 1st line of each testcase contains N total number of nodes

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start