• + 0 comments

    Python Solution that runs on O(n) times only

    def solve(c):
        lyl = []
        c.sort(reverse=True)
        ii = 0
        n = len(c)
        prod = 1
        for i in c:
            if i < n:
                prod *= (n - i - ii)
            else:
                return 0
            ii += 1
        return prod % 1000000007