Please Login in order to post a comment
Can anyone tell me why this times out on the last 6 test cases? It's in Ruby. I'm not sure how to make it quicker.
tot, mod = 1, 10**9+7 (1..[m,n].min).each do |j| tot *= j**(1+(m-n).abs + 2*([m,n].min-j)) % mod tot %= mod end puts tot % mod
I guess editorial solution is not the best. It takes O(n) space which is not necessary
No more comments
Seems like cookies are disabled on this browser, please enable them to open this website
Can anyone tell me why this times out on the last 6 test cases? It's in Ruby. I'm not sure how to make it quicker.
I guess editorial solution is not the best. It takes O(n) space which is not necessary