Java ✔✔✔|| Easy with explanation ✔|| 100% Faster ✔ || Chat GPT 🐱‍🏍🐱‍💻🐱‍👤
Please Upvote \uD83D\uDE4F\uD83D\uDE4F\uD83D\uDE4F\n> In this function, we added a condition to check whether end2 is greater than end if it is greater than we 
# Please Upvote \uD83D\uDE4F\uD83D\uDE4F\uD83D\uDE4F\n> In this function, we added a condition to check whether end2 is greater than end if it is greater than we append the substring of s between end and end2 to the string builder. It will work as expected.\n```\nStringBuilder sb = new StringBuilder();\n        for (int i = 0; i < s.length(); i += 2 * k) {\n            int end = Math.min(i + k, s.length());\n            int end2 = Math.min(i + 2 * k, s.length());\n            sb.append(new StringBuilder(s.substring(i, end)).reverse());\n            if(end2 > end)\n                sb.append(s.substring(end, end2));\n        }\n        return sb.toString();\n```
['Java']