Shubham Kumar Singh’s Post

🚀 DSA Series #1 — Closest Target in Circular Array Today I solved an interesting problem involving circular arrays + shortest distance logic. 🧠 Key Insight: Instead of simulating movement, we can compute distance using modulo. 👉 Forward distance: (i - start + n) % n 👉 Backward distance: (start - i + n) % n Take the minimum of both — done in O(n) time ⚡ 📌 Complexity: O(n) time | O(1) space 💡 Learning: Circular problems often look tricky, but math simplifies everything. 🔥 Building consistency with: #DSA #Java #Coding #PlacementPreparation #100DaysOfCode If you’re on the same path, let’s connect and grow 🤝

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories