We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Implementation
  4. Electronics Shop
  5. Discussions

Electronics Shop

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 2181 Discussions, By:

recency

Please Login in order to post a comment

  • emil_chemencedji
    2 days ago+ 0 comments

    Python

    def sum_cartez(p):
        return p[0] + p[1]
    
    def getMoneySpent(keyboards, drives, b):
        sorted_pairs = sorted(product(keyboards, drives), key=sum_cartez, reverse=True)
        for el in sorted_pairs:
            total_cost = sum_cartez(el)
            if total_cost <= b:
                return sum_cartez(el)
        return -1
    
    0|
    Permalink
  • brunosherdina
    4 days ago+ 0 comments

    python 3 one-liner

    def getMoneySpent(keyboards, drives, b):
        return(max([x+y if x+y<=b else -1 for x in keyboards for y in drives]))
    
    0|
    Permalink
  • vamshik2894
    5 days ago+ 0 comments

    def getMoneySpent(keyboards, drives, b): lst = [-1] for i in keyboards: for j in drives: if (i + j) <= b: lst.append(i+j) return max(lst)

    0|
    Permalink
  • vamshik2894
    5 days ago+ 0 comments

    now they think i am a spammer

    0|
    Permalink
  • vamshik2894
    5 days ago+ 0 comments

    The computer thinks i am a bot for some reason

    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy