Skip to main content

Word Search II

Find all words from word_list that appear in the grid via adjacent cells Return them in any order

Word Search II rewards structured search and good pruning more than raw cleverness. It's a hard one for a reason: it stresses structured exploration when the rules pile up. If you can explain your pruning, this stops feeling like brute force.

Examples

You write

find_words(board: List[List[str]], word_list: List[str])

  1. Example 1

    Input
    board = [["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]], words = ["oath","pea","eat","rain"]
    returns
    ["eat","oath"]
  2. Example 2

    Input
    board = [["a","b"],["c","d"]], words = ["abcb"]
    returns
    []

The pattern behind it

Arrays & Hashing

I reach for it when

  • You catch yourself scanning the array again for every element.
  • The problem asks about duplicates, pairs, counts or groups.

Say this before you type. Say what the key is and what the value remembers, before you write the loop.

All 127 Arrays & Hashing problems

Strings

I reach for it when

  • The input is text and the answer is a count, a substring or a new string.
  • You need to compare, reverse or rebuild characters.

Say this before you type. Say which array pattern the string is hiding before you touch a character.

All 51 Strings problems

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Sign in free to type with Coco, up to a daily limit. The editor and Run stay open without an account. Anyone can open the editor and run their code.

1Find Words in Gridhard