Subarray with distinct elements

what am i doing wrong in the code.

ide–>https://ide.codingblocks.com/s/189507

@mikkyimran hey your code might result in TLE, also what you are doing is counting the same element many times.
You need to use a map, with element and index.
Now keep on inserting the elements in map till a duplicate is found now as soon as duplicate is found, you can update your answer with all possible subarray count between the first element of map and the first occurrence of duplicate, and remove all these element and continue till the array ends in the do one final update.