diff --git a/lectures/03_classes_I/README.md b/lectures/03_classes_I/README.md index 3375aac..e81857f 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 8: String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi/) +- [Leetcode problem 1051: Height Checker](https://leetcode.com/problems/height-checker/) [Solution](../../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 1662: Check If Two String Arrays are Equivalent](https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent/) diff --git a/leetcode/p1051_heightchecker.cpp b/leetcode/p1051_heightchecker.cpp new file mode 100644 index 0000000..16805f7 --- /dev/null +++ b/leetcode/p1051_heightchecker.cpp @@ -0,0 +1,15 @@ +class Solution { +public: + int heightChecker(vector& heights) { + int count = 0; + int size = heights.size(); + vector expected(heights); + sort(expected.begin(),expected.end()); + for(int i=0;i