Sort by

recency

|

938 Discussions

|

  • + 0 comments
    public static long taumBday(long noOfBlackGifts, long noOfWhiteGifts, long blackGiftPrice, long whiteGiftPrice, int conversionCost) {
        if(conversionCost < Math.abs(blackGiftPrice-whiteGiftPrice)) {
            if(blackGiftPrice < whiteGiftPrice) {
                whiteGiftPrice = blackGiftPrice + conversionCost;
            } else if(whiteGiftPrice < blackGiftPrice){
                blackGiftPrice = whiteGiftPrice + conversionCost;
            }
        }
        return (noOfBlackGifts * blackGiftPrice) + (noOfWhiteGifts * whiteGiftPrice);
    }
    
  • + 0 comments

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

  • + 1 comment

    Here is my simple c++ solution, you can watch the explanation here : https://youtu.be/T9sxEzAbp-M

    long taumBday(int b, int w, int bc, int wc, int z) {
        long bp = min(bc, wc + z);
        long wp = min(wc, bc + z);
        return bp * b + wp * w;
    }
    
  • + 0 comments
    def taumBday(b, w, bc, wc, z):
        if(bc>wc+z):
            w=b+w
            return (w*wc)+(b*z)
        elif(wc>bc+z):
            wc=bc+z
            return (w*wc)+(b*bc)
        else:
            return (b*bc)+(w*wc)
    
  • + 1 comment

    For typescript this exercise as it is designed will not have a correct answer as the type of the function for this exercise would be BigInt and not number