CodingPal is an Online coding platform that teaches coding with visualisation.

Joined July 2021
14 Photos and videos
And it’s Done. You now can enroll to our interview prep platform. Choose a plan that suites you and get started with your interview prep codingpal.org/upgrade

Just got activated razorpay. Tonight will be Payment gateway integration.
1
167
Just got activated razorpay. Tonight will be Payment gateway integration.
110
✅ Binary Search Approach ⚬ Create a function that takes a sorted array & target, and returns [first_index, last_index]. ⚬ Init result: [-1, -1]. Left=0, Right=len(arr)-1. ⚬ Find First Occurrence: While left <= right: mid = (left right) // 2 If arr[mid] == target: result[0] = mid; right = mid - 1 (search left). Elif arr[mid] < target: left = mid 1. Else: right = mid - 1. ⚬ Find Last Occurrence: Reset left=0, right=len(arr)-1. While left <= right: mid = (left right) // 2 If arr[mid] == target: result[1] = mid; left = mid 1 (search right). Elif arr[mid] < target: left = mid 1. Else: right = mid - 1. ⚬ Return result. ⏳Time Complexity: O(log n) – Halves the search space each step. 💾 Space Complexity: O(1) – Constant extra space.
1
57
✅ Iterative Approach ⚬ Create a function that takes the array & target, and returns [first_index, last_index]. ⚬ Init result array: [-1, -1]. ⚬ Loop through the array (i from 0 to n-1) ⚬ If arr[i] == target & result[0] == -1: Set result[0] = i (first occurrence). ⚬ If arr[i] == target & result[0] != -1: Set result[1] = i (update last occurrence). ⚬ Return the result by the loop's end. ⏳Time Complexity: O(n) – Loops over all n elements. 💾 Space Complexity: O(1) – Just a fixed 2-element array

ALT https://codingpal.org/algos-and-ds/first-and-last-occurrances-in-sorted-array

1
27
Want to learn in your programming language of choice? Check out the link below. codingpal.org/algos-and-ds/p…
1
86
Binary search for peak: 1⃣Calculate the middle. 2⃣If value at the middle is bigger than middle 1 index value, the peak will be anywhere to the left, continue in that range. 3⃣else peak value will be somewhere on right. 4⃣Narrow range till found. Time: O(log n), Space: O(1).
1
20
1⃣ The iterative approach to finding a peak element in an array involves scanning through each element one by one. 2⃣If you find a larger element, you update the index. By the end, you have the index of a peak element. 👉Time complexity is O(n), and space complexity is O(1).
1
19
Onwards and upwards from here. Stay tuned for August 8. Subscribe now: youtube.com/@codingpal?featu…
23
3
👇✌️
Late post.
1
Thank u pals.
1
Officially live from 10th September 2021 at codingpal.org
Built a POC to prove the concept. Here is why I built a POC.youtu.be/KbDv947TZGk via @YouTube

Hello Tweety birds. Welcome to the codingpal.org twitter handle.