Construir y deconstruir

Dada una cadena, crea una función que devuelva un arreglo, construyendo y deconstruyendo la cadena letra por letra. Consulta los siguientes ejemplos como guía.

Ejemplos

constructDeconstruct("Hello") ➞ [
  "H",
  "He",
  "Hel",
  "Hell",
  "Hello",
  "Hell",
  "Hel",
  "He",
  "H"
]

constructDeconstruct("edabit") ➞ [
  "e",
  "ed",
  "eda",
  "edab",
  "edabi",
  "edabit",
  "edabi",
  "edab",
  "eda",
  "ed",
  "e"
]

constructDeconstruct("the sun") ➞ [
  "t",
  "th",
  "the",
  "the ",
  "the s",
  "the su",
  "the sun",
  "the su",
  "the s",
  "the ",
  "the",
  "th",
  "t"
]

Notas

Incluye los espacios (consulta el ejemplo n.º 3).

Ejemplo en Java

assertArrayEquals(new String[]{"H", "He", "Hel", "Hell", "Hello", "Hell", "Hel", "He", "H"}, Program.constructDeconstruct("Hello"));