Show problems as
Classic problem #2094EasyArrayHash TableRecursionSortingEnumeration

Finding 3-Digit Even Numbers

Real-world version: Three-Digit Even Numbers From the Tiles
Tracked in this browser only
Read Finding 3-Digit Even Numbers on LeetCode(opens in a new tab)

The statement here is our own: the same inputs, outputs and technique.

A tray holds tiles, each stamped with a single digit, given as tiles.

Form three-digit numbers by choosing three tiles and laying them out in some order. No tile may be used more often than the tray holds it, the number may not begin with a zero, and the number must be even.

Return every distinct number obtainable, in increasing order.

Examples

Example 1

Input
tiles = [1, 2, 4]
Output
[124, 142, 214, 412]

The three tiles must all be used. Of the six orders, only those ending on 2 or 4 are even, which gives four numbers.

Example 2

Input
tiles = [0, 0, 0]
Output
[]

Every tile is a zero, so any three-tile number would begin with a zero.

Example 3

Input
tiles = [4, 4, 4]
Output
[444]

Three tiles all stamped 4, so the only number is 444, which is even and does not begin with a zero.

Constraints

  • 3 <= tiles.length <= 100
  • 0 <= tiles[i] <= 9

The signature

The editor starts with this. It matches the parent problem's shape, so a solution that works here works on a standard judge unchanged.

Python
def find_even_numbers(tiles: list[int]) -> list[int]:
Java
public int[] findEvenNumbers(int[] tiles)