adding the set section

This commit is contained in:
Jidong Xiao
2023-10-23 00:22:15 -04:00
parent 285d3e4650
commit edcc52f3d5

View File

@@ -65,7 +65,16 @@ map_vect :: const_iterator p;
The compiler makes the substitution for you. The compiler makes the substitution for you.
## 16.3 Leetcode Exercises ## 16.3 Standard Library Sets
- STL sets are ordered containers storing unique “keys”. An ordering relation on the keys, which defaults to
operator<, is necessary. Because STL sets are ordered, they are technically not traditional mathematical sets.
- Sets are like maps except they have only keys, there are no associated values. Like maps, the keys are constant.
This means you cant change a key while it is in the set. You must remove it, change it, and then reinsert it.
- Access to items in sets is extremely fast! O(log n), just like maps, but sets do not have the [] operator, and
you shouldnt use [] to access elements in a set.
## 16.4 Leetcode Exercises
- [Leetcode problem 49: Group Anagrams](https://leetcode.com/problems/group-anagrams/). Solution: [p49_group_anagrams.cpp](../../leetcode/p49_group_anagrams.cpp). - [Leetcode problem 49: Group Anagrams](https://leetcode.com/problems/group-anagrams/). Solution: [p49_group_anagrams.cpp](../../leetcode/p49_group_anagrams.cpp).
- [Leetcode problem 290: Word Pattern](https://leetcode.com/problems/word-pattern/). Solution: [p290_word_pattern.cpp](../../leetcode/p290_word_pattern.cpp). - [Leetcode problem 290: Word Pattern](https://leetcode.com/problems/word-pattern/). Solution: [p290_word_pattern.cpp](../../leetcode/p290_word_pattern.cpp).