anil gurung
1 min readJan 4, 2021


In this blog post, I will be giving a brief introduction about another important pattern for technical interview. This pattern is called Subsets.This pattern is very useful to solve problems that involve dealing with Permutations and Combinations of a given set of elements. This data structure pattern describes an efficient Breadth First Search approach to handle all the problems.

The pattern looks like this;

Let assume that we are given a set of [1,9,2]

  1. First step , we start with an empty set :[[]]
  2. Then, we add the first number (1) to all the existing subsets to create new subsets: [[], [1]];
  3. Then, add the second number (9) to all the existing subsets: [[], [1], [9], [1,9]];
  4. Lastly, we add the third number (2) to all the existing subsets: [[], [1], [9], [1,9], [2], [1,2], [9,2], [1,9,2]].