Advertisement
nikunjsoni

1465

Jun 3rd, 2021
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int maxArea(int h, int w, vector<int>& hCuts, vector<int>& vCuts) {
  4.         sort(begin(hCuts), end(hCuts));
  5.         sort(begin(vCuts), end(vCuts));
  6.         auto max_h = max(hCuts[0], h - hCuts.back());
  7.         auto max_v = max(vCuts[0], w - vCuts.back());
  8.         for(auto i = 0; i < hCuts.size() - 1; ++i)
  9.             max_h = max(max_h, hCuts[i + 1] - hCuts[i]);
  10.         for(auto i = 0; i < vCuts.size() - 1; ++i)
  11.             max_v = max(max_v, vCuts[i + 1] - vCuts[i]);        
  12.         return ((long)max_h * max_v) % 1000000007;
  13.     }
  14. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement