My issue
I have completed all questions except this one fue to the compilation error please fix it as soon as possible
My code
int Search_Insert_Position(int arr[], int n, int k) {
int left = 0;
int right = n - 1;
while (left <= right) {
int mid = left + (right - left) / 2;
if (arr[mid] == k) {
return mid; // Target found
} else if (arr[mid] < k) {
left = mid + 1; // Move to the right half
} else {
right = mid - 1; // Move to the left half
}
}
// If not found, left is the position where k should be inserted
return left;
}
Learning course: Data structures & Algorithms lab
Problem Link: https://www.codechef.com/learn/course/muj-dsa-c/MUJDSAC20A/problems/DSAAGP1094