Day 116 Solved 1559. Detect Cycles in 2D Grid 🔁 Today’s problem was a great exercise in DFS + cycle detection in grids. 🔍 Key learnings: How to detect cycles while avoiding revisiting the immediate parent node Using DFS with direction vectors efficiently Tracking visited cells smartly to prevent false positives 💡 The tricky part was ensuring we don’t count the previous cell as a cycle — small detail, big impact. ⏱️ Performance: Runtime: 27 ms Memory: 64.79 MB Every day, a little sharper. On to Day 117 💪 #DSA #CodingJourney #100DaysOfCode #LeetCode #DFS #ProblemSolving
Detecting Cycles in 2D Grid with DFS
More Relevant Posts
-
Day 1️⃣ 3️⃣ /15 — Consistency Challenge 🚀 Today’s problem: LeetCode 1391 — Check if There is a Valid Path in a Grid A really interesting DFS + grid connectivity problem 🔥 🔹 Approach: Each cell represents a street type with specific allowed directions We simulate movement using DFS starting from (0, 0) Key Idea 💡 It’s not enough to just move to a neighbor — 👉 the next cell must also connect back to the current cell 🔹 Time Complexity: 👉 O(m × n) 🔹 Space Complexity: 👉 O(m × n) From simple grids → to directional graphs → to validation logic #LeetCode #DSA #DFS #Graphs #Consistency #CodingJourney #LearnInPublic
To view or add a comment, sign in
-
-
🚀 Day 13 of #LeetCode Challenge ✅ Question #1299 – Replace Elements with Greatest Element on Right Side 💡 Approach: Solved this problem by traversing the array from right to left while keeping track of the maximum element seen so far. 🔹 Steps: Initialize maxrt = -1 Traverse from last index to first Replace current element with maxrt Update maxrt = max(maxrt, current element) 🧠 What I Learned: Reverse traversal can make problems easier Maintaining a running maximum helps optimize to O(n) time complexity ⚡ Performance: Runtime: 3 ms Memory: 72.64 MB
To view or add a comment, sign in
-
-
🚀 Day 246 of #500DaysOfCode Solved LeetCode 1391 – Check if There is a Valid Path in a Grid 🛣️ 💡 Approach: Each cell type defines allowed directions (streets) Use DFS/BFS traversal from (0,0) Move only if: Current cell allows that direction Next cell has a matching connection back Maintain a visited matrix to avoid cycles ⚡ Key Insight: It’s not just movement — it’s bidirectional connectivity validation Both cells must agree on the connection ⏱️ Complexity: Time: O(m × n) Space: O(m × n) ✨ Takeaway: Grid + constraints on movement → think graph traversal with validation rules. Another day, another step forward 💪🔥 #LeetCode #DSA #Graphs #DFS #GridProblems #Consistency
To view or add a comment, sign in
-
-
I just opened a PR on the Lance columnar data format adding SIMD kernels for bf16 distance functions. The results: 2.6x faster dot product and 2.5x faster L2 norm on Apple Silicon, with solid gains on x86_64 as well. The approach follows Lance’s existing f16 kernel pattern, compiling C source via build.rs with per-architecture flags and runtime CPU dispatch. BF16-to-f32 conversion is just a left-shift by 16 bits, so with the right compiler hints the SIMD code gets very tight. Kernels cover dot product, L2, cosine, and norm_l2 across NEON, AVX2, AVX-512, and loongarch64 with scalar fallback. Initially I tried integrating an external SIMD library, but cross-platform benchmarking showed it only helped bf16 (where Lance had no SIMD at all) while regressing f16/f32/f64 due to compensated summation overhead. Reviewer feedback pushed me toward in-tree kernels with zero new dependencies, which turned out to be the right call. This is also a great time to contribute to Lance. The maintainers are responsive, and the codebase is well-structured Rust with clear patterns to follow. If you’re interested in systems-level work on columnar data formats and vector search, take a look. Also big thanks to Ryan Deak for pointing out NumKong, a great library to learn more about ML related SIMD kernels. https://lnkd.in/gndmV-Zv
To view or add a comment, sign in
-
For those who use local LLMs. From yesterday you can test TurboQuant in vLLM in nighly version. It's not official release, so some stuff still may not work. We also got new Qwen. Probably, it's time to start diving into local coding and maybe try to do some finetuning and see how far we can push small models to write production ready code. https://lnkd.in/dUPrgMHi
To view or add a comment, sign in
-
Trying to parse a WAV file, but the bytes I'm getting seemed nonsensical, turns out WAV is little-endian, while I'm on big-endian. 30 minutes of debugging x). I wonder why such a split in the industry still exists? We agreed on a byte being 8 bits, why not byteorder?
To view or add a comment, sign in
-
I recently completed a microproject comparing Instruction vs. Data Cache Performance using the Ripes simulator. it’s one thing to read about cache hits and misses in a textbook, but seeing the real-time impact on execution efficiency brings the theory of Computer Organization & Architecture to life. This project analyzes the performance difference between instruction cache and data cache using the Ripes simulator. By simulating different cache configurations, I compared hit rates, misses, and execution behavior to understand how instruction flow and data access patterns affect overall CPU performance. #computerorganizationandarchiteture #microproject
To view or add a comment, sign in
-
DSA Day 17. No new problem. Just revision. Took a step back today and reviewed everything I've learnt so far: ⟶ Arrays & Hashing ⟶ Linked Lists — slow & fast pointers, sentinel nodes, Floyd's cycle detection, carry logic No new concepts. No new problems. Just making sure the foundation is solid before moving forward. Revision doesn't feel productive. But it is. You can't build on shaky ground. Day 18 tomorrow — new topic incoming. ✊ #DSA #LeetCode #SoftwareEngineering #FrontendDeveloper
To view or add a comment, sign in
-
The leverage point for memory-safe C++ was never the syntax, it was always one layer down. A compiler's AST mirrors source code too literally to reason about flow and lifetimes; LLVM IR has already lowered away the type information ownership and aliasing analyses need. Anything interesting (lifetime checks, idiomatic standard-library optimizations, diagnostics that name C++ concepts instead of optimizer internals) has to live in the IR between them. That's what ClangIR is. A high-level intermediate representation built on the same MLIR framework that powers TensorFlow and Mojo, now part of mainline LLVM with GPU codegen and experimental safety work landing on top of it. WG21 spent this cycle ratifying reflection and contracts; the work that actually decides whether C++ becomes memory-safe is happening one layer below where the committee can reach.
To view or add a comment, sign in
-
-
SLAB, SLUB, and SLOB: Choosing the Optimal Kernel Cache Allocator The kernel allocates hundreds of millions of small objects every second—task_struct, dentries, inodes, socket buffers. When your production server starts showing 40% sys time and memory fragmentation spikes, you’re probably hitting allocator pathology. Most engineers think kmalloc() is just kernel malloc(), but understanding the slab layer underneath is what separates debugging from guessing. https://lnkd.in/d5cZfVst
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