This problem is based on the numbers round in TV game show "Des chiffres et des lettres", which has spawned several international versions across the globe. You may know this as "Countdown" if you are from UK, or as "Letters and Numbers" if you are from Australia.
The rules of the game are this:
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 25, 50, 75, 100}. This is given to you as array numbers.target.+, -, * and /, and the 6 numbers.The question is this: Can you determine if there is a sequence of operations you can perform on the numbers to get the target value? If so, return true. Otherwise, return false.
Example 1:
Input: numbers = [4, 50, 7, 5, 75, 25], target = 310
Output: true
Explanation:
50 + 4 = 54
54 - 7 = 47
47 * 5 = 235
235 + 75 = 310Example 2:
Input: numbers = [100, 7, 2, 7, 3, 7], target = 526
Output: falseExample 3:
Input: numbers = [25, 6, 1, 10, 100, 50], target = 985
Output: true
Explanation:
100 + 6 = 106
106 * 10 = 1060
50 + 25 = 75
1060 - 75 = 985Constraints:
numbers.length == 6
numbers[i] is in set {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 25, 50, 75, 100}
101 <= target <= 999Similar questions:
Why not post this in https://leetcode.com/contribute?
I have in the last few days. However, after examining Leetcode discussion forums, it seems that some questions are not being rejected explicitly for months. It would be nice if LeetCode provides some feedback regardless of whether a question has been accepted or not.