Sort by

recency

|

2412 Discussions

|

  • + 0 comments

    Here is problem solution in Python, Java, C++, C and Javascript - https://programmingoneonone.com/hackerrank-electronics-shop-problem-solution.html

  • + 0 comments

    static int getMoneySpent(int[] keyboards, int[] drives, int b) { /* * Write your code here. */ int ans=-1; Arrays.sort(keyboards); Arrays.sort(drives); int i=keyboards.length-1,j=0; int curr=-1; System.out.println(keyboards); System.out.println(drives); while(i>-1 && jb){ i--; }

            else{
                curr=keyboards[i]+drives[j];
                 j++;
            }
    
            if(curr>ans)
            ans=curr;
         }
    
    
         return ans;
    
    }
    
  • + 0 comments

    Here is problem solution in Python, Java, C++, C and Javascript - https://programmingoneonone.com/hackerrank-electronics-shop-problem-solution.html

  • + 0 comments

    Question details could have been simpler

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