Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are given a maze with N cells. Each cell may have multiple entry points but not more than one exit (ie. entry/exit points are

image text in transcribed

image text in transcribed

You are given a maze with N cells. Each cell may have multiple entry points but not more than one exit (ie. entry/exit points are unidirectional doors like valves). The cells are named with an integer value from 0 to N1. Function Description: The sum of the largest sum cycle in the maze. Return - 1 if there are no cycles. Sum of a cycle is the sum of node number of all nodes in that cycle. INPUT FORMAT 1. An integer T, denoting the number of testcases, followed by 2T lines, as each testcase will contain 2 lines. 2. The first line of each testcase has the number of cells N. 3. The second line of each testcase has a list of N values of the edge[] array. edge[i] contains the cell number that can be reached from cell 'i' in one step. edge[i] is 1 if the 'i'th cell doesn't have an exit. OUTPUT FORMAT For each testcase given, output a single line that denotes the sum of the largest sum cycle. SAMPLE INPUT 1 23 44141388808149151111015222222222221 SAMPLE OUTPUT 45

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Finance Help Question

Answered: 1 week ago