From: ex Date: 2008-06-17T11:29:05+09:00 Subject: Re: little problem (google hiring puzzle) I wasn't aware of the unshift overload, here I think I got O(n), however this looks more like C++ than ruby imho: vals = [4, 3, 2, 1, 2] ans = Array.new(vals.size) mp = 1 for k in 0...vals.length ans[k] = mp mp *= vals[k] end mp = 1 for k in 0...vals.length ans[vals.length - 1 - k] *= mp mp *= vals[vals.length - 1 - k] end p vals p ans