VMware Interview Question: Given a list of integers L an... | Glassdoor

Interview Question

Member of Technical Staff II Interview Palo Alto, CA

Given a list of integers L and a number X, find 3 numbers

  in L that sum-up to X.

Interview Answer

1 Answer


x = [1,2,3,4,5,6,7,8]
z = 10
y = []
for i in range(len(x)):
    for j in range(len(x)):
        for k in range(len(x)):
            if (i!=j) and (j!=k) and (i!=k):
                if set([x[i],x[j],x[k]]) not in y:
for i in y:
    if sum(i) == z:
        print i

Raviteja Ainampudi on Jan 23, 2017

Add Answers or Comments

To comment on this, Sign In or Sign Up.