Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them. If there are less than 2k but greater than or eq…
public class Solution { public string ReverseStr(string s, int k) { var len = s.Length; //记录k的倍数 //分出k的奇数倍和偶数倍 ; StringBuilder sb = new StringBuilder(); ;//计算奇偶 do { //取出k个字符 var str = ""; if (beginIndex + k <= len) { str = s.Substring(beginI…