TWO Sigma
Work in HR? Unlock Free Profile

TWO Sigma Software Engineer Interview Question

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

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

Answers & Comments

of 0

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.