Stack data type Interview Question | #stack #python #coding #shorts #shortvideo

preview_player
Показать описание

Hello everyone, I use to upload coding related videos every day on this channel. Please do subscribe to learn coding and to show support to me.

Thanks for reading. 😘

More from this channel :

Рекомендации по теме
Комментарии
Автор

Question:-
Given an array target and an integer n. In each iteration, you will read a number from list = {1, 2, 3…, n}.
- Build the target array using the following operations:
— Push: Read a new element from the beginning list, and push it in the array.
— Pop: delete the last element of the array.
— If the target array is already built, stop reading more elements.
— Return the operations to build the target array.

Example :
Input: target = [1, 3], n = 3
Output: ["Push", "Push", "Pop", "Push"]

Input: target = [1, 2], n = 4
Output: ["Push", "Push"]

Then what is the output for below input?
Input: target = [1, 2, 3], n = 3

kg_codes
welcome to shbcf.ru