Day 99 LeetCode Challenge: Available Captures for Rook

✅ Day 99 of 100 Days LeetCode Challenge Problem: 🔹 #999 – Available Captures for Rook 🔗 https://lnkd.in/gAw_XpbJ Learning Journey: 🔹 Today’s problem focused on simulating rook movement on a chessboard. 🔹 First, I located the position of the rook 'R' on the board. 🔹 Then, I explored all four directions: up, down, left, and right. 🔹 In each direction, I moved step-by-step until: • I hit a bishop 'B' → stop (blocked) • I found a pawn 'p' → increment count and stop • Or reached the board boundary 🔹 Summed all valid captures and returned the result. Concepts Used: 🔹 Matrix Traversal 🔹 Simulation 🔹 Direction Vectors 🔹 Boundary Checking Key Insight: 🔹 The rook’s movement is linear in 4 directions, and each direction is independent. 🔹 Early stopping (on bishop or pawn) is critical for correctness and efficiency. Complexity: 🔹 Time: O(1) (fixed 8×8 board, constant work) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #100DaysOfCode #Python #CodingJourney #ProblemSolving #LearningInPublic

  • text

To view or add a comment, sign in

Explore content categories