Simple Two Pointers Approach in C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n Using inbuilt function
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n Using inbuilt functions of STL along with two pointer technique\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(s.length())\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(s.length())\n\n# Code\n```\nclass Solution {\npublic:\n    string reverseStr(string s, int k)\n    {\n        int n=s.length();\n        if(k>n)\n        { \n            reverse(s.begin(),s.end());\n            return s;\n        }\n      \n       int j=0;\n    string ans;\n    \n    for (int i = 0; i < n; i += (2 * k))\n    {\n        string temp = s.substr(i, k);\n        reverse(temp.begin(), temp.end());\n        ans += temp;\n\n        j += k ;\n        while (j < n && j < (i+2*k))\n        {\n            ans.push_back(s[j]);\n            j++;\n        }\n    }\n    return ans;\n        \n    }\n};\n```
['Two Pointers', 'String', 'C++']