c++ world's fastest solution with approach.
Approach1:-)\nJust save the k length substring and reverse that and replace that in the original string and you have the answer. See the code for more clarifica
# **Approach1:-)**\nJust save the k length substring and reverse that and replace that in the original string and you have the answer. See the code for more clarification.\n\nTC = O(n)\nSC = O(n)+O(k) = O(n)\nAuxiliary space = O(k)\n```\nclass Solution {\npublic:\n    string reverseStr(string s, int k) {\n        \n        int n=s.length();\n        for( int i=0 ; i<n ; i+=2*k ){\n            \n            string str = s.substr(i,k);\n            reverse(str.begin(),str.end());\n            s.replace(i,k,str);\n        }\n        return s;\n    }\n};\n```\n# **Approach2:->**\nThis is a two pointer approach where one pointer marks the beginning and the othere is the minimum between the length and the kth position from start( start refers to the 2*k starting string ). For more clarity see the code.\nTC = O(n)\nSC = O(n)\nAuxiliary space = O(1)\n```\nclass Solution {\npublic:\n    string reverseStr(string s, int k) {\n        \n        int l=0;\n        int r = min(k,(int)s.length());\n        while( l < s.length() ){\n            \n            reverse(s.begin()+l,s.begin()+r);\n            l+=2*k;\n            r=min(k+l,(int)s.size());\n        }\n        return s;\n    }\n};\n```
['C', 'C++']