https://hack.codingblocks.com/contests/c/537/955
I couldn’t understand the solution on GFG.
I have derived a formula to calculate sum of length of subarray if all elements are different in the original array,
ie: n(n+1)(n+2)/6 , for eg n=3(distinct elements), ans=1.3 + 2.2 + 3.1=10, i have generalized it and derived the given formula.
I don’t know how to implement this if there are duplicates in the array. sliding window technique?