Longest consecutive 2 approach

I can’t able to understand can any one explain in short or any help ?

Hi,

First separate the array into segments of consecutive elements. Then three cases will arise.

  1. The new element is inserted on the basis of left boundary of segment
  2. The new element is inserted on the basis of right boundary of segment
    3 The new element is exactly between left boundary of one segment and right boundary of another segment so will take both.

Try to solve this problem int this way.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.