Twitter Interview Question
32 Interview Reviews |
Back to all Twitter Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Software Engineer at Twitter:
Given n sets of choices: (1,2,3), (2,3,4), (4,5) You pick one element from each set of choices. Generate all possible picking.
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (6)
Helpful Answer?
Yes |
No
Inappropriate?
The following gives all possible pickings in list.
A=[1,2,3]; B= [2,3,4], C=[4,5]
list=[]
for a in A:
for b in B:
for c in C:
list.append([a,b,c])
Helpful Answer?
Yes |
No
Inappropriate?
n set of choices are given and we don't know them in advance.
That was just an example..
Helpful Answer?
Yes |
No
Inappropriate?
Helpful Answer?
Yes |
No
Inappropriate?
list1 = [1,2,3]
list2 = [2,3,4]
list3 = [4,5]
print [(x,y,z) for x in list1 for y in list2 for z in list3]
Helpful Answer?
Yes |
No
Inappropriate?
To comment on this
question,
Sign In with Facebook or
Sign Up
0 of 1 people found this helpful
by Interview Candidate: