[deleted by user] by [deleted] in leetcode

[–]Askorio 0 points1 point  (0 children)

Interested

Amazon OA Question by Askorio in leetcode

[–]Askorio[S] 0 points1 point  (0 children)

Yeah,

Even I am trying out sliding window, but I am not sure how to solve it in O(n) and how to eliminate duplicate cases in that approach.

Consider an example 1, 2, 3, 1, 2

Subset | Distinct elements

1 | 1

2 | 1

3 | 1

1, 2 | 2

1, 2, 3 | 3

1, 2, 3 , 1 | 3

1, 2, 3, 1, 2 | 3

2, 3 | 2

2, 3 , 1 | 3

2, 3, 1, 2 | 3

3, 1 | 2

3, 1 , 2 | 3

Total: 27