All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : July 29, 2024
Last updated : July 29, 2024
Related Topics : Math, Dynamic Programming, Number Theory
Acceptance Rate : 79.85 %
This boils down to an induction proof for the postage problem. After a certain point, you can generate any value since you can fill in all the values between two values somehow, then just add the smaller denomination from a starting point.
This is solvable via the chicken mcnugget theorem
int mostExpensiveItem(int primeOne, int primeTwo) {
return primeOne * primeTwo - primeOne - primeTwo;
}
class Solution {
public:
int mostExpensiveItem(int primeOne, int primeTwo) {
return primeOne * primeTwo - primeOne - primeTwo;
}
};
func mostExpensiveItem(primeOne int, primeTwo int) int {
return primeOne * primeTwo - primeOne - primeTwo;
}
class Solution {
public int mostExpensiveItem(int primeOne, int primeTwo) {
return primeOne * primeTwo - primeOne - primeTwo;
}
}
/**
* @param {number} primeOne
* @param {number} primeTwo
* @return {number}
*/
var mostExpensiveItem = function(primeOne, primeTwo) {
return primeOne * primeTwo - primeOne - primeTwo;
};
class Solution {
fun mostExpensiveItem(primeOne: Int, primeTwo: Int): Int {
return primeOne * primeTwo - primeOne - primeTwo;
}
}
class Solution:
def mostExpensiveItem(self, primeOne: int, primeTwo: int) -> int:
return primeOne * primeTwo - primeOne - primeTwo
impl Solution {
pub fn most_expensive_item(prime_one: i32, prime_two: i32) -> i32 {
return prime_one * prime_two - prime_one - prime_two;
}
}
class Solution {
func mostExpensiveItem(_ primeOne: Int, _ primeTwo: Int) -> Int {
return primeOne * primeTwo - primeOne - primeTwo;
}
}
function mostExpensiveItem(primeOne: number, primeTwo: number): number {
return primeOne * primeTwo - primeOne - primeTwo;
};