← Back to Hub

🔮 The Leftmost Rune Quest

Find the First Occurrence in Sorted Array

Target Rune

-

Best Candidate

None

Current Mid

-

Search Range

-

Steps

0
🧠 Current Logic
Generate an array to begin your quest!
Key Insight: When arr[mid] == target, we found a match but there might be an earlier occurrence. So we save this as our candidate answer and keep searching LEFT!
📜 The Sorted Rune Array 📜
Left: -
Mid: -
Right: -
Answer: -
Generate an array to start your quest for the leftmost rune!

📖 First Occurrence Algorithm

Problem: Given a sorted array with duplicates, find the FIRST index where target appears.

Key Modification: When arr[mid] == target, don't stop! Save mid as potential answer and search LEFT (right = mid - 1).

Why it works: By continuing to search left even after finding a match, we ensure we find the leftmost occurrence.

Time Complexity: O(log n)