adding stack leetcode problem

This commit is contained in:
Jidong Xiao
2023-11-13 22:48:05 -05:00
parent 083a5c0294
commit d7effc3441
2 changed files with 8 additions and 4 deletions

View File

@@ -167,3 +167,5 @@ functionality.-->
- [Leetcode problem 232: Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks/). Solution: [p232_queue_using_stacks.cpp](../../leetcode/p232_queue_using_stacks.cpp). - [Leetcode problem 232: Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks/). Solution: [p232_queue_using_stacks.cpp](../../leetcode/p232_queue_using_stacks.cpp).
- [Leetcode problem 102: Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/). Solution: [p102_level_order_traversal.cpp](../../leetcode/p102_level_order_traversal.cpp). - [Leetcode problem 102: Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/). Solution: [p102_level_order_traversal.cpp](../../leetcode/p102_level_order_traversal.cpp).
- Play this [animation](https://jidongxiao.github.io/CSCI1200-DataStructures/animations/trees/level_order/index.html) to see how the level order traversal works. - Play this [animation](https://jidongxiao.github.io/CSCI1200-DataStructures/animations/trees/level_order/index.html) to see how the level order traversal works.
- [Leetcode problem 20: Valid Parentheses](https://leetcode.com/problems/valid-parentheses/). Solution: [p20_valid_parentheses.cpp](../../leetcode/p20_valid_parentheses.cpp)

View File

@@ -8,8 +8,6 @@
- Whats a Priority Queue? - Whats a Priority Queue?
- A Priority Queue as a Heap - A Priority Queue as a Heap
- A Heap as a Vector - A Heap as a Vector
- Building a Heap
- Heap Sort
## 22.1 Range Based for Loop ## 22.1 Range Based for Loop
@@ -117,9 +115,13 @@ Lambda is new to the C++ language (part of C++11). But lambda is a core piece of
- Draw two different binary heaps with these values: 52 13 48 7 32 40 18 25 4 - Draw two different binary heaps with these values: 52 13 48 7 32 40 18 25 4
- Draw several other trees with these values that not binary heaps. - Draw several other trees with these values which are not binary heaps.
## 22.7 Leetcode Exercises ## 22.7 Implementing a Heap with a Vector (instead of Nodes & Pointers)
- The standard library (STL) priority_queue is implemented as a binary heap.
## 22.8 Leetcode Exercises
- [Leetcode problem 215: Kth Largest Element in an Array](https://leetcode.com/problems/rearrange-words-in-a-sentence/). Solution: [p1451_rearrange_words_in_a_sentence.cpp](../../leetcode/p1451_rearrange_words_in_a_sentence.cpp). - [Leetcode problem 215: Kth Largest Element in an Array](https://leetcode.com/problems/rearrange-words-in-a-sentence/). Solution: [p1451_rearrange_words_in_a_sentence.cpp](../../leetcode/p1451_rearrange_words_in_a_sentence.cpp).
- [Leetcode problem 373: Find K Pairs with Smallest Sums](https://leetcode.com/problems/most-frequent-subtree-sum/). Solution: [p508_most_frequent_subtree_sum.cpp](../../leetcode/p508_most_frequent_subtree_sum.cpp). - [Leetcode problem 373: Find K Pairs with Smallest Sums](https://leetcode.com/problems/most-frequent-subtree-sum/). Solution: [p508_most_frequent_subtree_sum.cpp](../../leetcode/p508_most_frequent_subtree_sum.cpp).