Disney+ Hotstar interview question

Q. Subarray problem to get pairs in array.