← All problemsSign in

Merge Companies

There are $N$ companies in your area. Let $A_i$ be the net-worth of the $ith$ company. After the pandemic, they start acquiring each other. A company can only acquire its adjacent company (the nearest company to its left or to its right, provided it exists). Let’s say, if company-1 of net-worth $x$ acquires its adjacent company-2 of net-worth $y$ then company-2 disappears and company-1 net-

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