Sort by

recency

|

47 Discussions

|

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

    Start a yard sign business can be extremely effective simply because of where they are positioned. When you are trying to generate traffic to your website, or your brick-and-mortar store, the number of people that see your advertisement is really the key to your success.

  • + 0 comments

    Java 8 Solution:

    public static int solve(List<Integer> c) 
        {
            TreeMap<Integer,Integer> card_count = new TreeMap<>();
            int i;
            for(i=0;i<c.size();++i)
            {
                if(card_count.containsKey(c.get(i))==false)
                {
                    card_count.put(c.get(i), 1);
                }
                else
                {
                    card_count.put(c.get(i), card_count.get(c.get(i))+1);
                }
            }
            if(card_count.containsKey(0)==false)
            {
                return 0;
            }
            int last_key=card_count.lastKey();
            int remaining_card=0;
            long temp;
            long ans=1;
            for(i=0;i<=last_key;++i)
            {
                if(card_count.containsKey(i)==true)
                {
                    remaining_card=remaining_card+card_count.get(i);
                }
                if(remaining_card==0)
                {
                    return 0;
                }
                ans=(ans*remaining_card)%1000000007;
                --remaining_card;
            }
            for(i=remaining_card;i>0;--i)
            {
                ans=(ans*i)%1000000007;
            }
            ans=ans%1000000007;
            return (int)ans;
        }