## unknown Interview Question for Personnels

Country: India

Comment hidden because of low score. Click to expand.
0
of 0 vote

The basic idea behind this is whenever u add some element into the stack all you have to do is store the minimum element of the stack in the top most element of the stack. So the next time you insert you can compare the value of the node that is being inserted and the minimum node that is at the top of the stack and decide the new minimum from this information.

Comment hidden because of low score. Click to expand.
0
of 0 vote

The basic idea behind this is whenever u add some element into the stack all you have to do is store the minimum element of the stack in the top most element of the stack. So the next time you insert you can compare the value of the node that is being inserted and the minimum node that is at the top of the stack and decide the new minimum from this information.
(nobrainer .co .cc)

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````This algo is to find min & max value in the stack using linked list.
the idea is create the linked list by adding new nodes at top(first), after forming the list  find the minimum&maximum value in it.
this linked list uses stack procedure to create.

To find the min value,
int find_min(struct node *p)
{
p=top;
int mn=p->data;
while(p!=NULL)
{
if(mn > p->data)
{
mn=p->data;
}
else
}
return mn;
}
To find the max value
int find_max(struct node *q)
{
q=top;
int mx=q->data;
while(q!=NULL)
{
if(mx < q->data)
{
mx=q->data;
}
else
}
return mx;
}``````

Comment hidden because of low score. Click to expand.
0

hello
code was good bt it take complexity of n as we traverse the stack i nedd to find max among stack in o(1)
plz respond

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.