There are numerous errors in your code. The most prominent one that comes to my eye is the implementation of push and pop.
int push(int ele, int dup_top)
You return the new stack top index. But in your solve function, you just assign that value to push_ret and never update your top1 variable. That is a clear mistake. I would recommend to update the stack-top inside your push function, like this:
void push (int value)
{
stack1[++topIdx] = value;
}
The same applies to your pop function, which at the moment does not decrement to top index at all. It should read:
char pop ()
{
return stack1[topidx--];
}
That would make your code much more readable and correct at least the most profound errors.