From: Paul McMahon Date: 2008-06-20T11:11:40+09:00 Subject: Re: little problem (google hiring puzzle) Kevin Compton wrote: > how bad is this? > > inp = [4, 3, 2, 1, 2] > outp = [] > inp.each_with_index {|val, idx| inp[idx] = 1; outp << inp.inject(1) { |prod, > val2| prod * val2 }; inp[idx] = val} > > O(n^2). You are iterating through inp within inp (inject will iterate through each element).