Sort by

recency

|

49 Discussions

|

  • + 0 comments
    def solve(c):
        # By sorting the cards, we ensure that we handle the smallest constraints first, which simplifies checking validity and calculating permutations
        c.sort()
    
        result = 1
    
        for i in range(len(c)):
    
            # For each card at index i, the value must be at most i. If any card's value exceeds its index, it can't be placed in a valid position, resulting in 0 permutations
            if c[i] > i:
                return 0
    
            # Permutations Calculation: For each valid card, the number of available positions is determined by (i + 1 - c[i]), where i is the index (0-based). The product of these values for all cards gives the total number of valid permutations
            result = (result * (i + 1 - c[i])) % 1000000007
    
        return result
    
  • + 0 comments

    Meet all your printing needs swiftly with our Quick Printing services in Abu Dhabi at https://quickprinting.ae/. Our 24-hour print shop in AD guarantees an exceptionally fast turnaround time.

  • + 0 comments

    3 line Python solution, 100%

    cnt, mod = [0] * max(len(c), max(c)+1), 1000000007
    for i in c: cnt[i]+=1
    return math.prod(x-i for i,x in enumerate(accumulate(cnt)))%mod
    

    Could get it down to 1 line with using collections.Counter instead of building the counter array cnt manully in the first 2 lines of code here, but gets a bit too ugly for 1 liner.

    ¯_(ツ)_/¯

  • + 0 comments

    Selecting a car involves assessing your needs, budget, and preferences. Consider factors like size, fuel efficiency, safety, and features. Research makes and models, read reviews, and test drive to make an informed choice. Balance your desires with practicality to find the perfect car for your lifestyle. luxurysportcarsdubai

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