package leetcode;

/**
 * https://leetcode.com/problems/freedom-trail/
 */
public class Problem514 {
    public int findRotateSteps(String ring, String key) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem514 prob = new Problem514();
        System.out.println(prob.findRotateSteps("godding", "gd")); // 4
    }
}

@@ -193,16 +193,609 @@
 %0A    %7D%0A%0A
+    private static int findRotateSteps(String ring, String key, int idx) %7B%0A        int count1 = 0;%0A        int i = idx;%0A        while (key.charAt(idx) != ring.charAt(i)) %7B%0A            i++;%0A            if (i == ring.length()) %7B%0A                i = 0;%0A            %7D%0A            count1++;%0A        %7D%0A        int count2 = 0;%0A        int j = idx;%0A        while (key.charAt(idx) != ring.charAt(j)) %7B%0A            j--;%0A            if (j == -1) %7B%0A                j = ring.length() - 1;%0A            %7D%0A            count2++;%0A        %7D%0A        int min = Math.min(count1, count2);%0A        return min;%0A    %7D%0A%0A
     publ
@@ -947,16 +947,89 @@
 ); // 4%0A
+        System.out.println(prob.findRotateSteps(%22godding%22, %22gdo%22)); // 6%0A
     %7D%0A%7D%0A

Update problem 514