Leetcode 31. Next permutation | GeeksforGeeks | Data Structure and AlgorithmsMe: “Okay, GfG / LeetCode - next permutation. I need the next lexicographically larger arrangement of this array (in-place). How do I do it?”Brain: “Easy. There's a greedy trick - find a pivot, swap with the smallest bigger element on its right, then...Sep 10, 2025·3 min read
Binary Search vs First Occurrence Binary Search – Why Index MattersWhen we think of binary search, most of us imagine the classic algorithm that splits the array into halves until the element is found. It’s elegant, runs in O(log n) time, and is a staple in every programmer’s toolkit. But what if the array contains ...Aug 29, 2025·3 min read