you give array n pair pair pairsi lefti righti lefti rightiA pair p2 c d follow pair p1 b b c a chain pair form fashionreturn length long chain formedYou need use give interval you select pair order example 1input pair 122334output 2explanation the long chain 12 34example 2input pair 127845output 3explanation the long chain 12 45 78 Constraintsn pairslength1 n 10001000 lefti righti 1000