diff --git a/lectures/03_classes_I/README.md b/lectures/03_classes_I/README.md index 11c431d..8887dc1 100644 --- a/lectures/03_classes_I/README.md +++ b/lectures/03_classes_I/README.md @@ -144,6 +144,6 @@ bool earlier_date (const Date& a, const Date& b) { ## 3.11 Exercises -- [Leetcode problem 1051: Height Checker](https://leetcode.com/problems/height-checker/) Solution: [p1051_heightchecker.cpp](../../leetcode/p1051_heightchecker.cpp) -- [Leetcode problem 211: Design Add and Search Words Data Structure](https://leetcode.com/problems/design-add-and-search-words-data-structure/) +- [Leetcode problem 977: Squares of a Sorted Array](https://leetcode.com/problems/squares-of-a-sorted-array/). Solution: [p977_sortedsquare.cpp](../../leetcode/p977_sortedsquare.cpp) +- [Leetcode problem 1051: Height Checker](https://leetcode.com/problems/height-checker/). Solution: [p1051_heightchecker.cpp](../../leetcode/p1051_heightchecker.cpp) - [Leetcode problem 1662: Check If Two String Arrays are Equivalent](https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent/) diff --git a/leetcode/p977_sortedsquare.cpp b/leetcode/p977_sortedsquare.cpp new file mode 100644 index 0000000..ed7df3f --- /dev/null +++ b/leetcode/p977_sortedsquare.cpp @@ -0,0 +1,13 @@ +class Solution { +public: + vector sortedSquares(vector& nums) { + int size = nums.size(); + vector squares; + // create the squares vector + for(int i=0;i