TWO Sigma

  www.twosigma.com
Work in HR? Unlock Free Profile

TWO Sigma Software Engineer Interview Question

"print all the subsets of set"
Add Tags [?]
Answer

Part of a Software Engineer Interview Review - one of 84 TWO Sigma Interview Reviews

Answers & Comments

0
of 0
votes

on set of size n one can use binary representation of numbers from 0 to 2^n-1, where position of ones will tell you which elements to take. For example on 3 element set:
000 -empty set
001 -first element
010-second element
...
110-second and third element
111-the set itself.

- AlexB on Sep 21, 2012

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords that help categorize interview questions that have something in common.