Company: PhonePe

Difficulty: medium

Problem Statement

Twin Support Towers A stage crew is raising a banner over an outdoor arena. The banner must hang from two support towers , one at each end, and the banner can only be mounted if the two towers end up exactly the same height . The crew has a pile of n straight metal segments. Segments can be welded end to end, so any group of segments forms a tower whose height is the sum of the lengths in that group. A segment may be welded into at most one of the two towers, and the crew is free to leave any number of segments unused. Build the two towers so that they have equal height and that common height is as large as possible. Print that height. If it is impossible to build two equal-height towers out of at least one segment each, print 0 . Input Format Line 1: an integer n — the number of metal segments. Line 2: n space-separated integers l[1], l[2], ..., l[n] — the segment lengths. Output Format A single line containing one integer: the largest height at which both towers can be built, or 0 if

More PhonePe OA questionsInterview experiences