Given Array A of Size N,

Select any two adjacent indices, say, i and i + 1.

If A[i] == A[i+1], then you can remove A[i] and A[i+1], and put a single number in their place with value A[i] + 1.

You want to maximize the maximum number that is left in the array after applying the operation 0 or more times.

Find and return this maximum number.

Online Judge: https://www.interviewbit.com/problems/combine-maximum

How to Solve this problem? I can’t find a similar problem or editorial.

I can think of brute-force that is iterate over the array, whenever find i and i+1 equal, replace it and recur or don’t replace and continue iterating.