JavaScript Big Combination Problem

hk7math

hk7math

Posted on January 15, 2020

JavaScript Big Combination Problem

A recent CodeSignal Challenge was to calculate 1000C500 (mod 1e9+7) and I got defeated =(

All my trials exceeded the time limit.. Here is the best JS solution by psr
, could anyone explain what happens in this line??? I learnt ES6 but got no idea about this syntax...

f[o = n + 1/k] = o in f
Enter fullscreen mode Exit fullscreen mode

full solution for reference, please tell me to delete this if I violated any rule...

f = countWays = (n, k) => f[o = n + 1/k] = o in f
    ? f[o]
    : k 
        ? n && (f(--n, k) + f(n, k - 1)) % (1e9 + 7)
        : 1
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
hk7math
hk7math

Posted on January 15, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

JavaScript Big Combination Problem
javascript JavaScript Big Combination Problem

January 15, 2020