From: Srijayanth Sridhar Date: 2008-06-19T18:31:30+09:00 Subject: Re: little problem (google hiring puzzle) Correct me if I am wrong, but it seems like when you use the range operator: input[0...index] + input[index+1..-1] Isn't it basically just iterating over the list and yielding? In which case, your original loop: input.each_index do |index| odd_man_out = input[0...index] + input[index+1..-1] starry_night = odd_man_out.join('*') output << eval(starry_night) end will be interpreted as having a nested loop inside. So essentially your running time is bound to n^2 - n, which is O(n^2) My thoughts... J On Thu, Jun 19, 2008 at 2:45 PM, Ragunathan Pattabiraman wrote: >> Each eval is O(n-1). You do n of them. > > I think eval I used in this case is constant time. Any other views? > > -- > Posted via http://www.ruby-forum.com/. > >