Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    Practice problems / Word search

    Word search

    Mediumbacktrackingdfsmatrix

    board is a grid of letters (one string per row). Return true if word can be spelled from adjacent cells (up/down/left/right) without using the same cell twice.

    Example 1

    Input:  board = ["ABCE","SFCS","ADEE"], word = "ABCCED"
    Output: true

    Example 2

    Input:  board = ["ABCE","SFCS","ADEE"], word = "ABCB"
    Output: false

    It needs a second B, but the only B is already used.

    Constraints

    • 1 ≤ rows, cols ≤ 6
    • 1 ≤ word.length ≤ 15
    • Upper and lower case letters

    Submit checks your solution against 9 tests, including hidden ones.

    /**
     * @param {string[]} board
     * @param {string} word
     * @return {bool}
     */
    function exist(board, word) {
      
    }
    
    Sign in to run
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.