package com.dw.leetcode;

//@example: Leetcode - 541. Reverse String II - https://leetcode.com/problems/reverse-string-ii/#/description
public class Reverse_String_II_541 {

	public String revert(String s) {

		char[] array = s.toCharArray();
		int length = s.length();
		for(int i=0;i <= length/2;i++) {
			char temp = array[length - 1 - i]; 
			array[length - 1 - i] = array[i];
			array[i] = temp;
		}
		
		return new String(array);
	}
	
    public String reverseStr(String s, int k) {
        if(k== 0|| k== 1) return s;
        
        
        return "";
    }
	
	public static void main(String[] args) {
		
	}

}

@@ -170,26 +170,24 @@
 _541 %7B%0D%0A
-%0D%0A
 %09public 
 String r
@@ -182,98 +182,84 @@
 lic 
-String revert(String s) %7B%0D%0A%0D%0A%09%09char%5B%5D array = s.toCharArray();%0D%0A%09%09int length = s.length();
+static char%5B%5D array;%0D%0A%09public static void revert(int start, int end) %7B%0D%0A%0D%0A%09%09
 %0D%0A%09%09
@@ -272,21 +272,30 @@
 t i=
-0
+start
 ;i %3C= 
-length
+(start+end)
 /2;i
@@ -326,25 +326,11 @@
 ray%5B
-length - 1 - 
 i%5D;
- 
 %0D%0A%09%09
@@ -340,32 +340,31 @@
 ray%5B
-length - 1 - i%5D = array%5B
+i%5D = array%5Bstart+end - 
 i%5D;%0D
@@ -369,24 +369,36 @@
 ;%0D%0A%09%09%09array%5B
+start+end - 
 i%5D = temp;%0D%0A
@@ -406,41 +406,8 @@
 %09%7D%0D%0A
-%09%09%0D%0A%09%09return new String(array);%0D%0A
 %09%7D%0D%0A
@@ -420,16 +420,23 @@
  public 
+static 
 String r
@@ -524,27 +524,580 @@
     
-%0D%0A        return %22%22
+array = s.toCharArray();%0D%0A        int length = s.length();%0D%0A%0D%0A        int time = length/(2*k);%0D%0A        int rest = length%25(2*k);%0D%0A        int index = 0;%0D%0A        while(index %3C length && time %3E 0) %7B%0D%0A            revert(index,index+k-1);%0D%0A            time--;%0D%0A            index += 2*k;%0D%0A        %7D%0D%0A        %0D%0A        time = length/(2*k);%0D%0A        %0D%0A        if(rest %3E= k)%0D%0A        %7B%0D%0A        %09revert(2*k*time,2*k*time+k-1);%0D%0A        %7D%0D%0A        %0D%0A        if(rest %3C k)%0D%0A        %7B%0D%0A        %09revert(2*k*time,2*k*time+rest-1);%0D%0A        %7D%0D%0A        %0D%0A        return new String(array)
 ;%0D%0A 
@@ -1150,16 +1150,56 @@
 s) %7B%0D%0A%09%09
+System.out.println(reverseStr(%22abc%22,4));
 %0D%0A%09%7D%0D%0A%0D%0A

reverse string II AC