Sort by

recency

|

2 Discussions

|

  • + 0 comments

    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
    
  • + 1 comment

    I guess editorial solution is not the best. It takes O(n) space which is not necessary

No more comments