diff --git a/solution/3300-3399/3394.Check if Grid can be Cut into Sections/README.md b/solution/3300-3399/3394.Check if Grid can be Cut into Sections/README.md index b7dbdc3ca45bc..ac407b5164a0e 100644 --- a/solution/3300-3399/3394.Check if Grid can be Cut into Sections/README.md +++ b/solution/3300-3399/3394.Check if Grid can be Cut into Sections/README.md @@ -115,7 +115,38 @@ tags: #### C++ ```cpp - +class Solution { +public: +vector> merge(vector>& intervals){ + int n=intervals.size(); + sort(begin(intervals),end(intervals)); + vector>result; + result.push_back(intervals[0]); + for(int i=0;i>& rectangles) { + vector>hor; + vector>vert; + for(auto &cord:rectangles){ + int x1=cord[0]; + int y1=cord[1]; + int x2=cord[2]; + int y2=cord[3]; + hor.push_back({x1,x2}); + vert.push_back({y1,y2}); + } + vector> result1= merge(hor); + if(result1.size()>=3) + return true; + vector> result2=merge(vert); + return result2.size()>=3; + } +}; ``` #### Go