Runtime 1ms, 83% beats
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public String reverseStr(String s, int k) {\n        char[] str=s.toCharArray();\n        if(str.length<k){\n            char[] ans=new char[str.length];\n            for(int i=0;i<str.length;i++){\n                ans[i]=str[str.length-i-1];\n            }\n            return new String(ans);\n        }\n        for(int i=0;i<s.length();i+=(2*k)){\n            int a=i;\n            int b=Math.min(i+k-1, s.length()-1);\n            swap(str,a,b);\n        }\n        String ans=new String(str);\n        return ans;\n    }\n\n    public void swap(char[] str, int a, int b){\n        while(a<b){\n            char temp=str[a];\n            str[a]=str[b];\n            str[b]=temp;\n            a++;\n            b--;\n        }\n    }\n}\n```
['Java']