Code doubt for stack vs array

How to identify in an exam if this question needs to be solved through stacks or through array ?

@himanshuep32,
We use data structures such as queue, stack, linked list to decrease the time complexity of our code.

If you encounter a problem and you feel that you can decrease your complexity by using a data structure such as stack, queue or LL, you should try your approach on a paper and do a dry run.

In this, array will have a complexity of O(n^2) and stack will do it in O(n).

You need to analyse which data structure will make insertion, deletion, access, search operations cheaper and what operation you need to use most in the question.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.