Google | Onsite | Good Subarray
Anonymous User
6167

An array is good if all subarrays have atleast 1 element in them whose frequency is 1.

For Example :

Good : 1,2,1
Good: 1,2,5,2,4,3,4
Bad: 1,2,3,1,2,3

Since all subarrays [1], [1,2], [2,1], [1,2,1] have atleast 1 element that occurs once.
Expected Time Complexity : O(NlogN)
How to solve this ?

Comments (17)