Is there an O(n) solution to this problem I just got? I made an O(n^2) solution and timed out.
Given an array of integers, count the number of contiguous subarrays where each element in the subarray appears 2 or more times.
[0, 0, 0] -> 3
[1, 2, 1, 2, 3] -> 1Maybe some sort of DP? I just don't know how to get it without nested loops