Sort by

recency

|

2395 Discussions

|

  • + 0 comments

    What is the best time complexity that can be achieved?

  • + 0 comments

    Here is my c++ solution, you can find the video here : https://youtu.be/yC-TXToDbD0

    int getMoneySpent(vector<int> keyboards, vector<int> drives, int b) {
        int ans = -1;
        for(int k : keyboards){
            for(int d : drives){
                if(k + d > ans && k + d <= b) ans = k + d;
            }
        }
        return ans;
    }
    
  • + 0 comments

    Very simple python solution here

    def getMoneySpent(keyboards, drives, b):
        sortedKeyBoards = sorted(keyboards, reverse=True)
        drives = sorted(drives, reverse=True)
        sumMax = 0
        
        for i in range(len(sortedKeyBoards)):
            for j in range(len(drives)):
                sumTemp = sortedKeyBoards[i] + drives[j]
                if ( sumTemp >= sumMax and sumTemp <= b):
                    sumMax = sumTemp
                    
        return -1 if sumMax == 0 else sumMax
    
  • + 0 comments

    I run a car dealership shop in arizona that sells new and used cars. I want to apply this code on my website. I want to sue this code on my magento based website built with magento 2.1 version

  • + 0 comments

    def getMoneySpent(keyboards, drives, b): # # Write your code here. # sums = [keyboards[i]+ drives[j] if (keyboards[i]+ drives[j]) <= b else -1 for i in range(len(keyboards)) for j in range(len(drives))] return max(sums)