stack empty nhi tha jb 2 push kiya .. kyuki already 11 tha .. toh usko ek different stack 'a' me daal diye jo ki line 57,58 kar rhi hai, then ab line 59 chali ... or hum again function insert_corr_posn line 52 pahuch gaye...ab humra stack empty hai ab hum 2 ko push krenge then ab again hum line 60 me aagye then jo 11 stack 'a' me tha usko push kr denge main stack me ..jo 2 ke upar aa jayega 11
for java folks --
public Stack sort(Stack st){
if(st.size()
Bhaiya mujhe sari video chorkar srf apka method smjh aya thanks bro ☺️☺️☺️☺️☺️
Your way of explanation is really very amazing! Thank you!
My C++ solution:
void putElement(int x, stack& st){
if(st.empty() or st.top()
Great video bro, understood in one go 👍
Your explanations are really easy to understand
Scope m x declared nhi h ..error aara h backtrack wali line k code m ..why ?
Thanks bro for really simple explanation
after inserting 2 how 11 is coming back ? i mean which line of code is responsible for that
stack empty nhi tha jb 2 push kiya .. kyuki already 11 tha .. toh usko ek different stack 'a' me daal diye jo ki line 57,58 kar rhi hai, then ab line 59 chali ... or hum again function insert_corr_posn line 52 pahuch gaye...ab humra stack empty hai ab hum 2 ko push krenge then ab again hum line 60 me aagye then jo 11 stack 'a' me tha usko push kr denge main stack me ..jo 2 ke upar aa jayega 11
bhaiya description me problem link daal diya karo
Thanks Bhai! Osm Explanation.
Thanks brother for the videos
Bhaiya Academy of technology ke uppar ek video banayiye✌
Bhai please 🙏 iss data structure ki video jldi jldi bnna do.
Java Code:
import java.util.* ;
import java.io.*;
public class Solution {
public static void sortStackHelper(Stack stack, int x){
if(stack.size()==0 || stack.peek()
Bhya base condition me return bhul gye.. Ap
Stack overflow ho jyega😂😂
he's using if - else instead of return
I'm getting a segmentation error with your code.
Code:
void insert_sort(int x,stack &s){
if(s.top() < x || s.empty()){
s.push(x);
}
else{
int a = s.top();
s.pop();
insert_sort(x,s);
s.push(a);
}
}
void reverse(stack &s){
if(s.size() > 0 ){
int x = s.top();
s.pop();
reverse(s);
insert_sort(x,s);
}
}
void SortedStack :: sort()
{
reverse(s);
}
bhai vo s.top() ko baad me kr s.empty() k
Ha
Bhai koi mass recruiting company sa related bhi bna do
ok