Disney+ Hotstar Interview Question

Q. Subarray problem to get pairs in array.