My issue
idk what is wrong with the sulotion
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[100] = {
2,
4,
6,
8,
10
}; // Initial array
int size = 5; // Current size of the array
int pos = 2; // Index of the element to delete
if (pos>=0 && pos<size)
{
for(int i=pos; i <size-1; i++)
{
arr[i]= arr[i+1];
}
}
size--;
cout<<"Updated array: ";
for (int i = 0; i < size; i++)
{
cout << arr[i] << " ";
}
return 0;
}
Learning course: Data structures & Algorithms lab
Problem Link: https://www.codechef.com/learn/course/muj-aiml-dsa-c/MUJADSAC05/problems/DSAAGP08