2

This was an interview problem and I'm curious about it.

For example, if you were given: {1,2}, You would expect:

[[1], [2]], [[1, 2]]

If you are given: {7,3,5}, you would expect:

[[7], [3], [5]],[[7, 3], [5]], [[7], [3, 5]], [[7, 3, 5]].

Order does not matter, as long as you include everything. How would you guys solve this?

I already tried making an arraylist of arraylists, and appending each list to a final string. Interviewer pushed me to solve part of this recursively, but I guess making the sublists doesn't have to be recursive, so I figure just adding everything together would be recursive.

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
Alim2
  • 41
  • 3

0 Answers0