Boggle Word Finder
Updated
Problem statement
You are given a 4 by 4 grid of letters board and a list of dictionary words words. Return every word from words that can be traced on the board.
To trace a word, start on a cell with its first letter. Each next letter must be in a cell right next to the current one: up, down, left or right. Diagonal steps are not allowed, and the board does not wrap around its edges. A cell can be used at most once in the same word.
List each traced word once, even if it can be traced in more than one way. Return the words sorted in alphabetical order. If no word can be traced, return an empty list.
Function
findWords(board: char[][], words: String[]) → List<String>Examples
Example 1
board = [["b","o","n","d"],["e","a","t","y"],["r","s","i","e"],["k","l","d","p"]]words = ["tie","bear","bond","tat","boat","oat"]return = ["boat","bond","oat","tie"]"bond" runs along the top row. "boat" goes b, o, then down to a, then right to t. "oat" is the end of that path. "tie" goes t, down to i, right to e.
"bear" is missing: the a at row 1 and the r at row 2 touch only at a corner, and diagonal steps are not allowed. "tat" is missing because there is only one t next to the a, and a cell cannot be used twice.
The found words in alphabetical order are ["boat","bond","oat","tie"].
Example 2
board = [["a","a","a","a"],["a","a","a","a"],["a","a","a","a"],["a","a","a","b"]]words = ["bb","ba","aaaaa","ab"]return = ["aaaaa","ab","ba"]The board has fifteen a's and one b in the corner. "aaaaa" can be traced in many ways, but it is listed once. "ab" and "ba" use the b and an a next to it. "bb" would need the single b twice.
Example 3
board = [["z","y","x","w"],["v","u","t","s"],["r","q","p","o"],["n","m","l","k"]]words = ["cat","dog"]return = []The board has no c, d or g, so neither word can be traced. The answer is an empty list.
Constraints
board.length == 4andboard[i].length == 4board[i][j]is a lowercase English letter.1 <= words.length <= 10001 <= words[i].length <= 12- Each
words[i]is made of lowercase English letters, and all the words are different.
More Bloomberg LP Onsite Interview questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Currency Conversion RatePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Word Break IIAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Word Search IIKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
- Cats, Rabbits, and Snails Board GameAsana · ONSITE INTERVIEW
- Longest Word Containing Another InputMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Matrix Flower-House Planting PlansGoogle · ONSITE INTERVIEWGoogle interview questions
- Word SquaresInMobi · ONSITE INTERVIEWInMobi interview questions
- Keyboard Autocomplete SuggestionsLyft · ONSITE INTERVIEWLyft interview questions
- Insert Addition and Multiplication OperatorsPinterest · ONSITE INTERVIEWPinterest interview questions
- Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEWTesla interview questions
- Eight-Direction Word SearchMotive · ONSITE INTERVIEWMotive interview questions
Interview reports that mention this question
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)