课程: Java Algorithms
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Stack algorithms: Theorizing an algorithm
- [Instructor] As a software engineer, you'll need to know how to leverage the built-in stack functionality when working with algorithms that keep track of state. In this lesson, we'll look at how we can use the stack data structure to solve software problems. Let's say we want to print out the next greater element for every element in the array. The next greater element for a given element is the first greater element on the right side of the array. If no greater element exists, then the next greater element is a sentinel value, -1. For example, if we were given an array with 4, 5, 2 and 35, the next greater element for 4 would be 5. The next greater element for 5 would be 35 and the same for two. 35 does not have a next greater element to the right, so it's value would be -1. In another example, let's say we have 16, 7, 2 and 15. 16 does not have a next greater element, so it would be -1. 7's next greater element to the right is 15 and the same for 2. 16 is not to the right of 7 and…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
(已锁定)
What is a queue?1 分钟 53 秒
-
(已锁定)
Standard queue operations in Java3 分钟 38 秒
-
(已锁定)
Queue algorithms: Generate binary numbers4 分钟 41 秒
-
(已锁定)
What is a stack?1 分钟 58 秒
-
(已锁定)
Basic stack operations in Java3 分钟 32 秒
-
(已锁定)
Stack algorithms: Theorizing an algorithm5 分钟 21 秒
-
(已锁定)
Stack algorithms: Next greater element3 分钟 57 秒
-
(已锁定)
Stack algorithms: Matching parentheses4 分钟 49 秒
-
(已锁定)
Solution: Evaluate reverse polish notation4 分钟 16 秒
-
(已锁定)
-
-
-