simplest pancake C++ soution using vector ,  reverse function
\nclass Solution {\npublic:\n    void flip(vector<int> &v , int k){\n        reverse(v.begin() , v.begin() + k+1);\n    }\n    vector<int> pancakeSort(vector<in
```\nclass Solution {\npublic:\n    void flip(vector<int> &v , int k){\n        reverse(v.begin() , v.begin() + k+1);\n    }\n    vector<int> pancakeSort(vector<int>& A) {\n        vector<int>ans;\n        int n = A.size();\n        //int mx = INT_MIN , imx ;\n        for(int sz = n;sz>1;sz--){\n            int mx = INT_MIN , imx ; // mx = max element within sz and imx = index of max element\n            for(int i =0;i<sz;i++){\n                if(mx < A[i]){\n                    imx = i;\n                    mx = A[i];\n                }\n            }\n            \n            ans.push_back(imx + 1);\n            flip(A , imx);\n            ans.push_back(sz);\n            flip(A , sz -1);\n            \n        }\n    \n    return ans;\n    }\n};\n```\n\n\n
[]