Why am i getting wrong answer fro two test cases?
Subarrays with distinct elements
Use the algorithm :
1.Find the longest subarray starting from 0 with all elements distinct. Use mathematical formula to calculate all possible subarrays within it(They would definately contain all distinct elements)
2. keep removing from the start and adding infront an element and repeat above step.
Click here for better understanding .