In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Xiaobian to share with you how golang brush leetcode skills to achieve stack push, pop sequence, I hope you have something to gain after reading this article, let's discuss it together!
Enter two integer sequences. The first sequence indicates the push order of the stack. Please determine whether the second sequence is the pop order of the stack. Assume that all the numbers pushed into the stack are unequal. For example, sequence {1, 2, 3, 4, 5} is a stack pushing sequence of a stack, sequence {4, 5, 3, 2, 1} is a pop-up sequence corresponding to the stack pushing sequence, but {4, 3, 5, 1, 2} cannot be a pop-up sequence of the stack pushing sequence.
Example 1:
Input: pushed = [1,2,3,4,5], popped = [4,5,3,2,1]
Output: true
Explanation: We can do this in the following order:
push(1), push(2), push(3), push(4), pop() -> 4,
push(5), pop() -> 5, pop() -> 3, pop() -> 2, pop() -> 1
Example 2:
Input: pushed = [1,2,3,4,5], popped = [4,3,5,1,2]
Output: false
Explanation: 1 cannot pop up before 2.
Tip:
0
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.