diff --git a/cpp/widest-vertical-area-between-two-points-containing-no-points.cpp b/cpp/widest-vertical-area-between-two-points-containing-no-points.cpp new file mode 100644 index 0000000..8641575 --- /dev/null +++ b/cpp/widest-vertical-area-between-two-points-containing-no-points.cpp @@ -0,0 +1,21 @@ +#include +#include + +class Solution { +public: + int maxWidthOfVerticalArea(const std::vector>& points) { + std::set seen; + for (const auto& point : points) { + seen.insert(point[0]); + } + + int last = *seen.begin(); + int max_width = 0; + for (const auto x : seen) { + max_width = std::max(max_width, x - last); + last = x; + } + + return max_width; + } +};