I guess we are allowed to use the operation multiple times. I had thought of the solution, could you please look below and tell me whether I'm missing any case or not. I know the complexity of the solution is very bad(exponential). But if you have some other cool algorithm I would be happy to hear.
The only case which I was able to think of was 1) Generate all possible permutation of those 6 integers. 2) Generate repeated permutation of the 4 operands on 5 places. eg. +,+,+,*,/ etc 3) Do a Shuffle merge of these two lists (Every permutation of (1) with every permutation of (2)) 4) You get the inorder, convert it to post order and evaluate the expression. Thanks. On Thu, Apr 4, 2013 at 2:05 AM, atul anand <atul.87fri...@gmail.com> wrote: > are we allowed to use operation only once or multilpe times? > > > On Fri, Mar 22, 2013 at 6:27 AM, prankur gupta <duke.lnm...@gmail.com>wrote: > >> Hi All, >> >> Could you help me this question. >> This was asked at Yelp Interview. >> >> Given 6 integers and 1 target value, write a function to get the target >> value using 6 integers with any on these operations +,*,-,/ >> >> Thanks >> >> -- >> PRANKUR GUPTA >> >> Masters Student (CSE) >> State University of New York >> Stony Brook University >> prgu...@cs.stonybrook.edu >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to algogeeks+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to algogeeks+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- PRANKUR GUPTA Masters Student (CSE) State University of New York Stony Brook University prgu...@cs.stonybrook.edu -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.