• + 0 comments
        int maxPrice = -1;
        for(int i=keyboards.length-1; i>=0; i--) {
            int keyboardprice = keyboards[i];
            for(int j=drives.length-1; j>=0; j--) {
                int driveprice = drives[j];
                if(keyboardprice + driveprice <= b) {
                    if(keyboardprice + driveprice > maxPrice) {
                        maxPrice = keyboardprice + driveprice;
                    }
                }
            }
        }
        return maxPrice;