All problems
Subword Reconstruction
Problem
Reconstruct words from subword tokens. A token starting with '##' continues the previous word, and any other token starts a new word.
Return the list of reconstructed words.
Hint
Accumulate continuation pieces into the current word and flush before starting a new one.
Test cases
case 1
in: [["play","##ing"]]
expected: ["playing"]
case 2
in: [["un","##want","##ed"]]
expected: ["unwanted"]
case 3
in: [["hello","world"]]
expected: ["hello","world"]
case 4
in: [["##ed"]]
expected: ["ed"]
case 5
in: [[]]
expected: []
Starter codePython
def subword_reconstruction(tokens):
# Your code here
pass5 test cases · run your code against them in the editor