Question Contribution - Numbers Round

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:

  • You have 6 numbers selected from the following set, with repeats: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 25, 50, 75, 100}. This is given to you as array numbers.
  • You are then given a target value to reach, which ranges between 101-999 inclusive. This is given as number target.
  • The goal is to reach the target value using arithmetic operations +, -, * and /, and the 6 numbers.
  • You may only use each number once. If you are given two or more numbers that have the same value, then you may use each value once.
  • You do not need to use all the numbers to get to the target value.
  • All intermediate numbers computed in your calculation must be positive integers. Furthermore, intermediate numbers you have computed can only be used once. If you were able to obtain multiple intermediate numbers with the same value in your calculations, then you may use each value once.

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 = 310

Example 2:

Input: numbers = [100, 7, 2, 7, 3, 7], target = 526
Output: false

Example 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 = 985

Constraints:

numbers.length == 6
numbers[i] is in set {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 25, 50, 75, 100}
101 <= target <= 999

Similar 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.

Comments (4)