Dileep Kumar Maurya’s Post

🔥 DSA Challenge – Day 130/360 🚀 📌 Topic: Backtracking / DFS on Grid 🧩 Problem: Word Search Problem Statement: Given a 2D grid of characters and a word, check if the word exists by moving in 4 directions (no cell reuse). 🔍 Example: Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]] word = "ABCCED" Output: true 💡 Approach: Backtracking + DFS 1️⃣ Step 1 – Start from every cell matching the first character 2️⃣ Step 2 – Explore 4 directions (up, down, left, right) recursively 3️⃣ Step 3 – Mark visited cells and backtrack after exploring ✔️ Avoid revisiting the same cell ✔️ Stop early when characters don’t match ✔️ Return true as soon as full word is found ⏱ Complexity: Time: O(N * M * 4^L) Space: O(L) (recursion stack) 📚 Key Learning: Backtracking is powerful for exploring all possible paths while avoiding invalid ones using pruning. #DSA #Java #Coding #InterviewPrep #ProblemSolving #TechJourney #130DaysOfCode #LeetCode #Backtracking

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories