From d7effc344138c61b4a2ec4750dec7f377a19b2ae Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Mon, 13 Nov 2023 22:48:05 -0500 Subject: [PATCH] adding stack leetcode problem --- lectures/21_hash_tables_II/README.md | 2 ++ lectures/22_priority_queues/README.md | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lectures/21_hash_tables_II/README.md b/lectures/21_hash_tables_II/README.md index 05ff41b..c108ea3 100644 --- a/lectures/21_hash_tables_II/README.md +++ b/lectures/21_hash_tables_II/README.md @@ -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 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. + +- [Leetcode problem 20: Valid Parentheses](https://leetcode.com/problems/valid-parentheses/). Solution: [p20_valid_parentheses.cpp](../../leetcode/p20_valid_parentheses.cpp) diff --git a/lectures/22_priority_queues/README.md b/lectures/22_priority_queues/README.md index 391020d..3ee7d57 100644 --- a/lectures/22_priority_queues/README.md +++ b/lectures/22_priority_queues/README.md @@ -8,8 +8,6 @@ - What’s a Priority Queue? - A Priority Queue as a Heap - A Heap as a Vector -- Building a Heap -- Heap Sort ## 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 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 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).