Shivam Yadav’s Post

✨ Day 85 of #100DaysOfCode ✨ Today I worked on the Word Search problem using C++ and Backtracking. In this problem, we’re given a 2D grid of characters and need to check if a given word can be formed by sequentially adjacent letters (up, down, left, or right). 🔹 My approach: Start from every cell that matches the first character of the word. Use recursion to explore all four directions — top, right, bottom, and left. Temporarily mark a cell as visited (using ‘!’) to prevent revisiting it during the same search path. If we reach the end of the word, we return true. After exploring, we backtrack by restoring the cell’s original value. This solution is a great example of depth-first search (DFS) combined with backtracking — a powerful pattern for solving grid-based problems. 💡 Key Concepts Used: Recursion Backtracking 2D Array Traversal Boundary Condition Handling #100DaysOfCode #DSA #CPlusPlus #Backtracking #Recursion #ProblemSolving #CodeNewbie #CodingJourney

  • text

To view or add a comment, sign in

Explore content categories