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.
Suppose I give you prices of keyboards and drives such that if you purchased the highest cost keyboard and the highest cost usb, it would still be less than your spending amount. Your algorithm would go through every pairing of keyboards and usbs, which is the same as brute forcing.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Electronics Shop
You are viewing a single comment's thread. Return to all comments →
Your solution is still O(n*m).
Suppose I give you prices of keyboards and drives such that if you purchased the highest cost keyboard and the highest cost usb, it would still be less than your spending amount. Your algorithm would go through every pairing of keyboards and usbs, which is the same as brute forcing.