Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Solve Boggle Match Search

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Solve Boggle Match Search. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Etsy is experimenting with a Boggle-style word discovery feature for search suggestions. Given a character board and a dictionary of candidate words, return every dictionary word that can be formed by traversing adjacent cells.

A cell may connect to any of its 8 neighbors, including diagonals, but each cell can be used at most once for a single word. Return each matching word once, sorted in lexicographic order.

Formal Specification

Implement find_boggle_words(board, words), where board is a non-empty rectangular list of lists containing lowercase one-character strings, and words is a list of lowercase strings. Return a list of matching dictionary words in ascending lexicographic order. Duplicate dictionary entries must appear only once.

Constraints

  • 1 <= rows, cols <= 12
  • 1 <= rows * cols <= 144
  • 1 <= len(words) <= 30,000
  • 1 <= len(word) <= 15
  • All board characters and words contain lowercase English letters
  • The board is rectangular

Function Signature

def find_boggle_words(board, words):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output