There exists an input with expected output based on a string search/match on the table:
Example 1:
input = [ A, B, C, D, E ]
expected_output => [ Y1, X4, X5 ]
Explanation:
We're. What we are trying to do is match the input with a combination of rows from the tabledatabase. From each row we take allThe only portion of the row that we use for matching is from wiw1
entriesto (iw4
is from 1 to 4), except the ones which have no data. We then represent this row using itsuse the v
entrycolumn to identify the row. So, not itsfor example, the input string idE
would produce output X5
, while input A, B
would produce output Y0
.
We In the case that there is no exact match, we want the elements closer to find the longest match forfront of the inputlist to represent as long a string as possible. For example, so we look forwith input A, B, C, D, E
.
This is nowhere to be found, so we checkcould match a number of ways, notably A, BY1, CX4, DX5
.
Still no luck, so we look for AX1, BY2, CX5
.
This matches Y1
, so that is We prefer the first part of our resultformer, assuming it results in a complete match. Next we need to findbecause DA, EB, C
(the rest of the input), but there is no match.
We look for D
, and findfrom Y4Y1
. Our partial solution) is longer than Y1, Y4A
.
Finally we look for E
and find(from Y5X1
). We want the first item in the output to represent as long a string as possible, completingand only when two potential outputs have the match. The full solution then is Y1, Y4, Y5
same length for the initial item do we try to get the longest second item we can.
input = [A, B, C, D, F ]A, B, C, D, F
expected_output => [ Y0, Y3 ] Y0, Y3