Skip to content

2979. Most Expensive Item That Can Not Be Bought 👎

  • Time: $O(1)$
  • Space: $O(1)$
1
2
3
4
5
6
7
class Solution {
 public:
  int mostExpensiveItem(int primeOne, int primeTwo) {
    // https://en.wikipedia.org/wiki/Coin_problem
    return primeOne * primeTwo - primeOne - primeTwo;
  }
};
1
2
3
4
5
6
class Solution {
  public int mostExpensiveItem(int primeOne, int primeTwo) {
    // https://en.wikipedia.org/wiki/Coin_problem
    return primeOne * primeTwo - primeOne - primeTwo;
  }
}
1
2
3
4
class Solution:
  def mostExpensiveItem(self, primeOne: int, primeTwo: int) -> int:
    # https://en.wikipedia.org/wiki/Coin_problem
    return primeOne * primeTwo - primeOne - primeTwo