✅ 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
Day 99 LeetCode Challenge: Available Captures for Rook
More Relevant Posts
-
✅ Day 95 of 100 Days LeetCode Challenge Problem: 🔹 #869 – Reordered Power of 2 🔗 https://lnkd.in/gkNXaSFM Learning Journey: 🔹 Today’s problem focused on checking whether the digits of a number can be rearranged to form a power of 2. 🔹 I created a helper function to extract and store the digits of a number. 🔹 Then I sorted the digits of the input number for comparison. 🔹 Next, I generated powers of 2 iteratively and compared their sorted digit lists with the input. 🔹 If any match was found, I returned True. Otherwise, continued until the digit length exceeded the input. Concepts Used: 🔹 Digit Extraction 🔹 Sorting 🔹 Simulation of Powers of 2 🔹 Brute Force Optimization Key Insight: 🔹 Instead of generating permutations (which is expensive), sorting digits allows quick comparison. 🔹 Any valid rearrangement must have the same digit frequency as some power of 2. Complexity: 🔹 Time: O(log n * d log d) 🔹 Space: O(d) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
Find the winner of the circular game - Recursion is just solving a smaller version of the same problem: I recently tackled the Josephus Problem on LeetCode. It’s a classic challenge that perfectly illustrates the power of recursive thinking. The Problem: n people stand in a circle. Every k-th person is eliminated until only one survivor remains. The goal is to find that survivor’s position. The Recursive Logic: Instead of simulating the entire elimination process, we ask: "If I know the survivor's position for n-1 people, can I find it for n?" Base Case: With 1 person, the survivor is at index 0. The Shift: Once the first person is removed, the problem resets with n-1 people. We just shift that result by k and use % n to wrap around the circle. It’s a great reminder of how modular arithmetic and recursion can turn a complex circular puzzle into a single, elegant line of code: return (solve(n-1, k) + k) % n #Python #Algorithms #Recursion #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
Day 56 of #GeekStreak60: The Phantom Pointer Trick! 🕵️♂️📈 Tackled the "Sorted subsequence of size 3" problem on @GeeksforGeeks today. Key Learning: Finding an increasing triplet is easy if you use extra arrays to track minimums and maximums, but that violates the O(1) space constraint. The optimal solution is to use "Greedy State Tracking." By iterating through the array in a single pass, I maintained three variables: the absolute smallest number seen (num1), a valid middle number (num2), and a snapshot of num1 locked in at the exact moment num2 was discovered. If the loop encounters any number strictly greater than num2, the valid triplet is instantly formed! This perfectly eliminates the need for O(n) memory arrays while keeping the time complexity to a strict O(n). Just 4 days left! The logic is feeling sharper than ever. 🚀 #geekstreak60 #npci #coding #Algorithms #Python #DataStructures #Optimization #SoftwareEngineering
To view or add a comment, sign in
-
-
Just proposed 3 new tools for langchain community. The current built ins are great for demos but fall short in production: - Math can't solve equations or do calculus - Web scraping returns raw noisy HTML - Python REPL has zero security controls So I built: CalculatorTool - equations, calculus, unit conversion via sympy + pint WebScraperTool - smart extraction, metadata, retry logic, robots.txt PythonCodeExecutorTool - AST security scanning, stateful sessions, timeout kill 95 tests. no external APIs. ready to merge. here's the issue: https://lnkd.in/gXRYRJpa #OpenSource #LangChain #Python #AIAgents #LLM
To view or add a comment, sign in
-
-
✅ Day 89 of 100 Days LeetCode Challenge Problem: 🔹 #1480 – Running Sum of 1D Array 🔗 https://lnkd.in/gSTZrxF7 Learning Journey: 🔹 Today’s problem focused on computing the running (prefix) sum of an array. 🔹 Instead of using an extra array, I optimized the solution by modifying the input array in-place. 🔹 Starting from index 1, I updated each element as: • nums[i] += nums[i-1] 🔹 This way, each index stores the cumulative sum up to that point. 🔹 Finally, returned the modified array. Concepts Used: 🔹 Prefix Sum 🔹 In-place Computation 🔹 Array Traversal Key Insight: 🔹 The previous element already stores the prefix sum, so we can reuse it directly. 🔹 Eliminates the need for extra space while maintaining linear time. Complexity: 🔹 Time: O(n) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
✅ Day 97 of 100 Days LeetCode Challenge Problem: 🔹 #1281 – Subtract the Product and Sum of Digits of an Integer 🔗 https://lnkd.in/gxTAZc6U Learning Journey: 🔹 Today’s problem involved extracting digits of a number and performing two operations simultaneously. 🔹 I initialized two variables: one for product (pr) and one for sum (sm). 🔹 Using a while loop, I extracted each digit using n % 10. 🔹 Updated the product by multiplying the digit and updated the sum by adding it. 🔹 Reduced the number using integer division (n //= 10) after each step. 🔹 Finally returned the difference between product and sum. Concepts Used: 🔹 Digit Extraction 🔹 While Loop 🔹 Arithmetic Operations 🔹 Number Manipulation Key Insight: 🔹 Both product and sum can be computed in a single traversal of digits. 🔹 Efficient use of modulus and division avoids converting the number to a string. Complexity: 🔹 Time: O(d) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
Day 47 of #GeekStreak60: The Binary State Machine! 0️⃣1️⃣ Tackled the "Consecutive 1's not allowed" problem on @GeeksforGeeks today. Key Learning: Counting valid combinations often looks like a backtracking problem, which leads to an O(2^n) time trap. By analyzing the strict rules of binary generation, I modeled the problem as a Finite State Machine. Because a 1 can only follow a 0, but a 0 can follow anything, I simply tracked the counts of strings ending in each digit iteratively. This completely eliminated the need to generate the strings themselves, dropping the time complexity to a highly efficient O(n) and the auxiliary space down to a perfect O(1)! (Fun fact: This strict state transition actually generates the Fibonacci sequence under the hood!) Less than two weeks left in the 60-day sprint! 🚀 #geekstreak60 #npci #coding #Algorithms #Python #DataStructures #DynamicProgramming #StateMachines #Optimization
To view or add a comment, sign in
-
-
🚀 Day 38 of My Problem Solving Journey Today I solved the problem: Valid Parentheses. 🔹 Implemented an approach using string replacement to repeatedly remove valid pairs like "()", "{}", and "[]". 🔹 Learned how to simplify the problem by eliminating balanced brackets step by step. 🔹 Practiced working with string manipulation and loop conditions. 🔹 Understood how this problem can also be solved efficiently using a stack-based approach. 💡 Key takeaway: By continuously removing valid pairs, we can check if the string becomes empty. However, using a stack is a more optimal and scalable solution for this problem. 📌 Example: Input: "()" Output: true Input: "(]" Output: false This problem improved my understanding of stacks, string operations, and pattern matching techniques. On to the next challenge! 💪🔥 #Day38 #CodingJourney #Python #ProblemSolving #DataStructures #Algorithms #LeetCode
To view or add a comment, sign in
-
-
A 10 million document RAG dataset occupies 31 GB of RAM at float32. turbovec fits it in just 4 GB - and now it searches it faster than FAISS. I just shipped a new release of turbovec: a Rust vector index with Python bindings, built on Google Research's TurboQuant algorithm. Data-oblivious 2-4 bit quantization that matches the Shannon lower bound on distortion - zero training and no rebuilds when the corpus grows. What's in the box: → Hand-written SIMD kernels - 12–20% faster than FAISS FastScan on ARM; match-or-beat on x86. → O(1) stable-id delete and save/load. The corpus is live and mutable, not a static snapshot. → Drop-in integrations for LangChain, LlamaIndex, and Haystack. → Published benchmarks (recall, speed, compression) at d=200/1536/3072 — every number reproducible from the repo. If you're building RAG where memory, latency, or privacy matters, give it a spin. GitHub: https://lnkd.in/e5M4dVRk Paper: https://lnkd.in/eHRmpYms #RAG #VectorSearch #OpenSource #Rust #Python #𝗟𝗟𝗠 #𝗢𝗽𝗲𝗻𝗦𝗼𝘂𝗿𝗰𝗲 #𝗚𝗲𝗺𝗺𝗮4
To view or add a comment, sign in
-
-
AI agents just moved into software reverse engineering tools. IP becomes easier to extract. A GitHub project connects IDA Pro to agents. They can now read code, modify it, run Python, and even drive debugging inside sensitive environments. That’s the shift. Iteration effort drops. Exploration scales. Still imperfect. Hallucinations are not gone. But the attack surface is expanding. Three signals. Every week. The AI Shift Subscribe → https://lnkd.in/eMstK-8g
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development