Skip to the editor
JSGroundwork
JSGroundwork handwritten · web dev
←Back to Tries

Ready to read

JSJavaScript⑂Git◎Interview prepΣDSA in JSSDSystem Design
More topics15›
</>HTML{ }CSS⚛ReactNNext.jsNeNest.jsTSTypeScriptNoNode.js🐳DockerDBSQL & Databases✓Testing🔒Web Security☁Cloud & DevOps◈GraphQL◆Redis☸Kubernetes
☰‹›
Description
All topics›JavaScript›Tries

Word Search II

advancedlayer A5 · Tries5 tests

Given a character grid board and a list of words, return every word that can be spelled by walking through adjacent cells.

  • Adjacent means horizontally or vertically neighbouring; a cell may not be reused within one word
  • Each found word appears in the result once, in any order
  • Running the single-word search once per word is far too slow — build a trie of the words and walk the board once, abandoning a path as soon as it leaves the trie
  • The board must be left exactly as you found it

Stuck?

All exercisesPlayground
1234567891011121314
loading the editor…

Nothing yet — hit Run and whatever you log shows up here.

Submit to see how you did.

⌘/Ctrl + Enter run⌘/Ctrl + S save⌘/Ctrl + / comment⌘/Ctrl + F find/replace⌘/Ctrl + D select next matchAlt + click multi-cursorTab indent · ⇧Tab outdentEsc leave fullscreen