pieces and a digit string target. Count the ordered index pairs (i, j) with i ≠ j such that pieces[i] followed by pieces[j] is exactly target.
The pairs (i, j) and (j, i) count as different.pieces=["12", "3412", "1234", "12"], target="123412" → 4
Pairs (0, 1) and (3, 1) work: "12" + "3412". Pair (2, 0) also gives "123412" as "1234" + "12", and so does (2, 3). That is 4 in total.
pieces=["5", "5"], target="55" → 2
Pairs (0, 1) and (1, 0) count separately, even though they glue identical strings.
pieces=["7", "8", "9"], target="98" → 1
pieces=["12", "3412", "1234", "12"], target="123412"
4
Run checks the first 3 tests in your browser. Submit checks all 112 tests on the server, hidden ones included.