keep going brother it helps me a lot i watch it everyday don't stop this series plese i am new to all this
@CS090SrikanthАй бұрын
Really wonderful explanation ❤
@ritwicksingharoy5742Ай бұрын
You need to perform half the times of original array size, at that time whatever the first element is is your answer. int rotateDelete(vector &arr) { // Your code here int sz=arr.size()/2; int k=1; while(n) { arr.insert(arr.begin(),arr.back()); //Last ele added to start arr.pop_back(); //removed ele from last //Array is now rotated arr.erase(arr.end()-k); //Erase k-th element from last k++; n--; } return arr[0]; }
@omkumarjha2745Ай бұрын
I solved it through recursion -- TC - 0(N) and SC - 0(N) -- Recursive call stack space int solve(vector &arr , int k , int n){ if(n == 1) return 0; int ind = (k == 0) ? solve(arr , k + 1 , n) : solve(arr , k + 1 , n - 1); int deletedInd = n - k; int newInd = (ind == 0) ? n - 1 : ind; if(newInd > deletedInd){ // from example 1 return newInd; } else if(newInd == deletedInd) return newInd - 1; // from example 2 return newInd - 1; } int rotateDelete(vector &arr) { int n = arr.size(); int ind = solve(arr , 0 , n); return arr[ind]; }
@T_M_T_KАй бұрын
Subscribe kar diya sir par please java mai bhi solution samjaya karo
@nandinigupta3836Ай бұрын
Keep it up!!! ❤beautiful explanation 🥹
@manojitsaha6262Ай бұрын
main raat ko dekha tha tab kth element tha 2nd point pe main dry run nahi kar paya ab samjh aya ki wrong tha constrain
@animez718Ай бұрын
same vro subh bhi kth element hi tha abhi change hua hoga