You are viewing a single comment's thread. Return to all comments →
Correct Implementation Snippet in C:
while(n>0){ n--; scanf("%ld",&ch); switch(ch){ case 1: x; scanf("%lld",&x); if(top==-1){ top++; stack[top]=x;} else{ stack[top+1]=max(stack[top],x); top++;} break; case 2: if(top>=0) top--; break; case 3: printf("%lld\n",stack[top]); break; default: exit(0); } }
max(int,int) is just a function that returns the larger number This is up and running. ENJOY.
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Element
You are viewing a single comment's thread. Return to all comments →
Correct Implementation Snippet in C:
max(int,int) is just a function that returns the larger number This is up and running. ENJOY.