Facebook Interview Question: Given an array of distinct in... | Glassdoor

Interview Question

Software Engineer Interview(Student Candidate)

Given an array of distinct integers, and a target integer

  t, compute all of the subsets of the array that sum to t, where order matters. (I was given ~20 minutes to solve this)
Answer

Interview Answer

2 Answers

0

Simple - use divide et impera to create the list for number N as (1, Listfor(N-1)), (2, listfor(N-2)) ... etc

Alex on Feb 7, 2013
0

https://github.com/alonsovidales/interview_questions/blob/master/subset_that_sums_n.py

Python answer on Feb 17, 2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.