Easy logic C++ using modular arithmetic
Logic is not a big problem here, simply we have to find the largest area of the cake i.e. the largest length multiplied by the largest width.\n\nTo find the lar
Logic is not a big problem here, simply we have to find the largest area of the cake i.e. the largest length multiplied by the largest width.\n\nTo find the largest length/width, we will find the maximum difference between continuous elements in array.\n\nMajor problem here is the multiplication, Integer overflow should be handled by using modular arthematic.\n```\nlong long multiply(int h, int v) {\n        long long ans = 0;\n        h = h%MOD;\n        \n        while(v>0) {\n            if(v%2==1) {\n                ans = (ans+h)%MOD;\n            }\n            \n            h = (h*2)%MOD;\n            \n            v = v/2;\n        }\n        return ans%MOD;\n    }\n```\n\n\nFull Code for reference:\n```\nclass Solution {\npublic:\n    const int MOD = 1e9+7;\n    int maxArea(int h, int w, vector<int>& horizontalCuts, vector<int>& verticalCuts) {\n        horizontalCuts.push_back(h);\n        verticalCuts.push_back(w);\n        sort(horizontalCuts.begin(), horizontalCuts.end());\n        sort(verticalCuts.begin(), verticalCuts.end());\n        \n        int vert=verticalCuts[0], horiz=horizontalCuts[0];\n        \n        for(int i=1; i<horizontalCuts.size(); i++) {\n            horiz = max(horiz, horizontalCuts[i]-horizontalCuts[i-1]);\n        }\n        \n        for(int i=1; i<verticalCuts.size(); i++) {\n            vert = max(vert, verticalCuts[i]-verticalCuts[i-1]);\n        }\n        // cout<<horiz<<" "<<vert<<endl;\n        return multiply(horiz, vert);\n    }\n    \n    long long multiply(int h, int v) {\n        long long ans = 0;\n        h = h%MOD;\n        \n        while(v>0) {\n            if(v%2==1) {\n                ans = (ans+h)%MOD;\n            }\n            \n            h = (h*2)%MOD;\n            \n            v = v/2;\n        }\n        return ans%MOD;\n    }\n};\n```
['Sorting', 'C++']