1

I have a problem I need to solve efficiently.

PROBLEM: I have a 1 collection of integers of length(n). There could be duplicates. I want to get all the possible combinations of those integers. The result is not a fixed length.

ie.

Given the collection of integers: [1,2,2,3]

The expected output should be: [1] [1,2] [1,3] [1,2,2] [1,2,2,3] [1,2,3] [2,2] [2,3] [2,2,3]

How to do this in c#, I would prefer a linq version, but other solutions are welcome.

Thanks

Luka
  • 4,075
  • 3
  • 35
  • 61
  • 1
    Does this answer your question? [All Possible Combinations of a list of Values](https://stackoverflow.com/questions/7802822/all-possible-combinations-of-a-list-of-values) – canton7 Jan 25 '21 at 10:58
  • Yes, that solves it. thanks. – Luka Jan 25 '21 at 11:10
  • Your solution leaves out [], [2], [3]. The first may not be valid. The other two are. – rossum Jan 25 '21 at 16:21

0 Answers0