Mid From PDF Coding C# Coding Interview

Find All Subsets (Power Set)?

Short answer: List<List<int>> Subsets(int[] nums)

Example code

{
List<List<int>> result = new List<List<int>>(); GenerateSubsets(nums, 0, new List<int>(), result); return result;
} void GenerateSubsets(int[] nums, int index, List<int> current, List<List<int>> result)
{
if (index == nums.Length)
{ result.Add(new List<int>(current)); return;
} // Exclude nums[index] GenerateSubsets(nums, index + 1, current, result); // Include nums[index] current.Add(nums[index]); GenerateSubsets(nums, index + 1, current, result); current.RemoveAt(current.Count - 1); Follow on: } Explanation: Backtracking approach includes/excludes each element.

Real-world example (ShopNest)

In coding rounds, state complexity aloud, write a clear ShopNest-flavored example (orders, carts), then handle edge cases (empty list, null, overflow).

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details