FastPrepWord Search with Eight-Direction Adjacency
Problems/Word Search with Eight-Direction Adjacency

Word Search with Eight-Direction Adjacency

Microsoft logoMicrosoft● MediumNEW GRADONSITE INTERVIEW

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Microsoft Japan data-analysis internship onsite asks whether a string exists in an N×N character grid using horizontal, vertical, and diagonal moves. Cell reuse, direction changes, case sensitivity, interface, and bounds are conventional enrichment.

Given a square character grid board and a nonempty string word, return true if the word can be formed by a path through the grid.

From each cell, the path may move to any of its eight horizontal, vertical, or diagonal neighbors. A path may change direction between characters, but it cannot use the same cell more than once.

Function

wordExists8Directions(board: char[][], word: String) → boolean

Examples

Example 1

board = [["A","B"],["C","D"]]word = "AD"return = true
board
010AB1CD

The path moves diagonally from the upper-left A to the lower-right D.

Example 2

board = [["A","B"],["C","D"]]word = "ABA"return = false
board
010AB1CD

The only A would need to be reused after visiting B, which is forbidden.

Constraints

  • 1 <= board.length <= 6
  • board[i].length = board.length
  • 1 <= word.length <= board.length * board.length
  • The grid and word contain uppercase and lowercase English letters, matched case-sensitively.

More Microsoft Onsite Interview questions

  • Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEWTesla interview questions
  • Trace a Word Through a Letter GridExpedia · ONSITE INTERVIEWExpedia interview questions
  • Find a Word in a Letter GridAdobe · PHONE SCREENAdobe interview questions
  • Number of IslandsFleetx · ONSITE INTERVIEW
  • Word SearchBloomberg LP · OA · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Number of IslandsIntuit · ONSITE INTERVIEWIntuit interview questions
  • Word SearchAmazon · ONSITE INTERVIEW
  • Number of Islands with Diagonal ConnectivityGoogle · ONSITE INTERVIEWGoogle interview questions
  • Island Count and Maximum AreaOracle · ONSITE INTERVIEWOracle interview questions
  • Query Whether an Island Size ExistsMeta · ONSITE INTERVIEWMeta interview questions

Interview reports that mention this question

  • Microsoft AI/ML Intern Interviews: 114 Experiences (Part 1 of 2)

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public boolean wordExists8Directions(char[][] board, String word) {
      // Write your code here.
    }

}
Checking account…