bars[i]. Bars can be welded end to end, so a pillar is as tall as the total length of the bars it is made of.
Each bar can be used at most once: in one of the pillars, or not at all.
Return the greatest height two equal pillars can have. If they cannot be built, return 0.bars=[2, 4, 5, 7] → 9
2 + 7 = 4 + 5 = 9: all four bars are used, and both pillars are 9 tall.
bars=[3, 3, 10] → 3
Nothing can balance the 10, so it is left aside; the two 3s make pillars of height 3.
bars=[4, 9] → 0
No two equal pillars can be built, so the answer is 0.
bars=[2, 4, 5, 7]
9
Run checks the first 3 tests in your browser. Submit checks all 73 tests on the server, hidden ones included.