FastPrepMaximum Reservoir Power
Problems/Maximum Reservoir Power

Maximum Reservoir Power

Wells Fargo logoWells Fargo● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The photos in the report give the goal, the input fields, and the limits. The promise of no cycle in the conflicts, the arrays you get, and a 64-bit return are stated so the answer is always the same. Our version is about 96% the same as the reported question.

A hydropower plant is connected to n water reservoirs. Opening reservoir i generates capacity[i] units of electricity.

Some pairs of reservoirs conflict and cannot be opened together. The undirected conflict graph is guaranteed to be a forest.

Choose a set of reservoirs with no conflicting pair and return the maximum total electricity they can generate.

The arrays conflictFrom and conflictTo have equal length. Their values are 1-indexed reservoir numbers, and pair j connects conflictFrom[j] with conflictTo[j].

Function

maxReservoirPower(capacity: int[], conflictFrom: int[], conflictTo: int[]) → long

Examples

Example 1

capacity = [5,1,4,3]conflictFrom = [1,2,3]conflictTo = [2,3,4]return = 9

Open reservoirs 1 and 3 for 5 + 4 = 9 units.

Example 2

capacity = [10,1,1,10]conflictFrom = [1,2,3]conflictTo = [2,3,4]return = 20

Reservoirs 1 and 4 are not adjacent, so both can be opened for 20 units.

Example 3

capacity = [8,5,6,4,7,3]conflictFrom = [1,2,4]conflictTo = [2,3,5]return = 24

Choose reservoirs 1 and 3 from the first component, reservoir 5 from the second component, and isolated reservoir 6: 8 + 6 + 7 + 3 = 24.

Constraints

  • 1 <= capacity.length <= 10^5.
  • 1 <= capacity[i] <= 10^5.
  • conflictFrom.length == conflictTo.length.
  • 0 <= conflictFrom.length <= capacity.length - 1.
  • Every conflict endpoint is between 1 and capacity.length, endpoints in a pair are different, and pairs are unique.
  • The conflict graph is a forest.

More Wells Fargo Online Assessment questions

  • Server Upgrade PlanningOA · Seen Nov 2026
  • Student and Course EnrollmentOA · Seen Nov 2026
  • Bond Interest Summary Above 3%OA · Seen Oct 2026
  • Count Phrases Formed by Anagram ReplacementOA · Seen Oct 2026
  • Event Statistics AggregatorOA · Seen Sep 2026
  • Ordered Deployment Configuration ValidatorOA · Seen Sep 2026
  • Longest Subsequence That Is a SubstringOA · Seen Jul 2026
  • Overloaded Game Account InventoriesOA · Seen Jul 2026
  • Count Server ReplacementsOA · PHONE SCREEN · Seen Feb 2026
  • Minimum Remaining LengthOA · PHONE SCREEN · Seen Feb 2026

Similar questions at other companies

  • Minimum Leaf Path Sum over All RootsInfosys · OAInfosys interview questions
  • Maximum Strength of Every NeuronMicrosoft · OAMicrosoft interview questions
  • Tree Node With Maximum BeautyC3.ai · OAC3.ai interview questions
  • Distance Sums to Special Nodes in a Weighted TreeNutanix · ONSITE INTERVIEWNutanix interview questions
  • Sum of Weighted Distances in a TreeGoogle · ONSITE INTERVIEWGoogle interview questions
  • Base Unit ConversionsAdobe · OAAdobe interview questions
  • Part 1: The Narrowest KeyScale AI · OAScale AI interview questions
  • Best Sum Downward Tree PathCitadel · OACitadel interview questions
  • Longest Transfer Time in a Server TreeRippling · OARippling interview questions
  • Longest Alternating a/b Path in a TreeHudson River Trading · OAHudson River Trading interview questions

Interview reports that mention this question

  • Wells Fargo OA: What It Tests (2026)

Wells Fargo interview experiences

  • Wells Fargo SWE Intern OA and Interview Questions: 18 Experiences
All Wells Fargo interview questionsSee Wells Fargo hiring insights
Saved
class Solution {
    public long maxReservoirPower(int[] capacity, int[] conflictFrom, int[] conflictTo) {
      // write your code here
    }
}
Checking account…