Rotate and delete gfg potd | 02-10-24 | GFG Problem of the day

  Рет қаралды 2,103

CodeGenius

CodeGenius

Күн бұрын

Пікірлер: 14
@CodeGenius316
@CodeGenius316 Ай бұрын
Subscribe
@jvinay2210
@jvinay2210 Ай бұрын
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
@CS090Srikanth Ай бұрын
Really wonderful explanation ❤
@ritwicksingharoy5742
@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
@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
@T_M_T_K Ай бұрын
Subscribe kar diya sir par please java mai bhi solution samjaya karo
@nandinigupta3836
@nandinigupta3836 Ай бұрын
Keep it up!!! ❤beautiful explanation 🥹
@manojitsaha6262
@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
@animez718 Ай бұрын
same vro subh bhi kth element hi tha abhi change hua hoga
@onkardhingra9083
@onkardhingra9083 Ай бұрын
Yes, kth hi tha pehle
@mohammadanas7929
@mohammadanas7929 Ай бұрын
Best explain
@OGAbhishekMalviya
@OGAbhishekMalviya Ай бұрын
sare test case pass nhi hore
@salmaniproductions1104
@salmaniproductions1104 Ай бұрын
Thank you so much
@fshimcds
@fshimcds Ай бұрын
🙏
Majority Vote | gfg potd | 03-10-24 | GFG Problem of the day
28:35
Rotate and Delete | Array | GFG POTD | C++ | Java | Code Kar Lo
17:32
The Ultimate Sausage Prank! Watch Their Reactions 😂🌭 #Unexpected
00:17
La La Life Shorts
Рет қаралды 7 МЛН
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 5 МЛН
Happy birthday to you by Secret Vlog
00:12
Secret Vlog
Рет қаралды 6 МЛН
Being Competent With Coding Is More Fun
11:13
TheVimeagen
Рет қаралды 113 М.
Count Palindromic Subsequences | Problem of the Day : 26/08/22 | Yash Dwivedi
15:27
Rotate and delete | GFG POTD 2nd Oct 2024 | JAVA
6:59
CodeCraft
Рет қаралды 247
Circle of Strings | BFS | GFG POTD | C++ | Java | Code Kar Lo
18:09
XOR Linked List | gfg potd | 07-10-24 | GFG Problem of the day
27:23
The Ultimate Sausage Prank! Watch Their Reactions 😂🌭 #Unexpected
00:17
La La Life Shorts
Рет қаралды 7 МЛН