[Java] Solution | Beginner Friendly
\nclass Solution {\n    public String reverseStr(String s, int k) {\n        StringBuilder sb,ans;\n        sb = new StringBuilder(s);\n        ans = new String
```\nclass Solution {\n    public String reverseStr(String s, int k) {\n        StringBuilder sb,ans;\n        sb = new StringBuilder(s);\n        ans = new StringBuilder("");\n        int size = s.length(), left=0,right=k;\n       \n    while(size>0){\n        if(2*k <= size){\n            StringBuilder str = new StringBuilder(sb.substring(left,right));\n            str.reverse();\n            ans.append(str);\n            ans.append(sb,right,right+k);\n            left += 2*k;\n            right += 2*k;\n            size = size - 2*k;\n        }\n        else if(size < k){\n           StringBuilder str = new StringBuilder(sb.substring(left,sb.length()));\n           str.reverse();\n           ans.append(str);\n           size=0;\n        }\n        else if(size >= k){\n            StringBuilder str = new StringBuilder(sb.substring(left,right));\n            str.reverse();\n            ans.append(str);\n            ans.append(sb,right,sb.length());\n            size = 0;\n        }\n    }    \n        return ans.toString();    \n            \n    }\n}\n```
['Java']