Solución

@eduahg·25/5/2026TypeScript
solution.tsTypeScript
function wordInMatrix(matrix: string[][], word: string): boolean {
  let newWordY:string = ''
  let newWordX: string = ''


  for(let i = 0; i < matrix.length; i++) {

    newWordY = ''

    for(let k = 0; k < matrix.length; k++){
      newWordY += matrix[k][i]
      if(newWordY === word){
        return true;
      }
    }
  }


  for(let o =0; o < matrix.length; o++) {
    newWordX = ''

    for(let j = 0; j < matrix[o].length; j++) {
      newWordX += matrix[o][j]

      if(newWordX === word) {
        return true;
      }

    }
  }


  return false;
}

// No modificar: necesario para evaluar el resultado.
export { wordInMatrix };
0respuestas
Respuestas

Aún no hay respuestas

¡Sé el primero en responder!

Escribir un comentario

Recuerda ser amable. Estás comentando la solución de otra persona. Comparte tu perspectiva de forma constructiva y respetuosa.

Debes iniciar sesión para publicar un comentario.