Subarray with distinct Elements

I am getting segmentation fault.
cant get the problem