package leetcode;

import java.util.List;

/**
 * https://leetcode.com/problems/sequential-digits/
 */
public class Problem1291 {
    public List<Integer> sequentialDigits(int low, int high) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1291 prob = new Problem1291();
        System.out.println(prob.sequentialDigits(100, 300)); // [123,234]
        System.out.println(prob.sequentialDigits(1000, 13000)); // [1234,2345,3456,4567,5678,6789,12345]
    }
}

@@ -12,16 +12,44 @@
 tcode;%0A%0A
+import java.util.ArrayList;%0A
 import j
@@ -63,16 +63,16 @@
 l.List;%0A
-
 %0A/**%0A * 
@@ -226,313 +226,1595 @@
     
-// TODO%0A        return null;
+String next = Long.toString(low);%0A        out:%0A        for (int i = 0; i %3C next.length() - 1; i++) %7B
 %0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1291 prob = new Problem1291();%0A        System.out.println(prob.sequentialDigits(100, 300)); // %5B123,234%5D%0A        System.out.println(prob.sequentialDigits(1000, 13000)); // %5B1234,2345,3456,4567,5678,6789,12345%5D
+    if (next.charAt(i + 1) - next.charAt(i) != 1) %7B%0A                int size = next.length();%0A                int j = 0;%0A                while (true) %7B%0A                    int x = next.charAt(0) - '0' + j++;%0A                    next = %22%22 + x++;%0A                    for (int k = 0; k %3C size - 1; k++) %7B%0A                        if (x %3E= 10) %7B%0A                            size++;%0A                            next = %22%22;%0A                            for (int l = 0; l %3C size; l++) %7B%0A                                next += (l + 1);%0A                            %7D%0A                            break;%0A                        %7D%0A                        next += x++;%0A                    %7D%0A                    if (Long.parseLong(next) %3E= low) %7B%0A                        break out;%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A        List%3CInteger%3E answer = new ArrayList%3C%3E();%0A        int size = next.length();%0A        out:%0A        while (Long.parseLong(next) %3C= high) %7B%0A            answer.add(Integer.valueOf(next));%0A            int x = next.charAt(0) - '0' + 1;%0A            next = %22%22 + x++;%0A            for (int i = 0; i %3C size - 1; i++) %7B%0A                if (x %3E= 10) %7B%0A                    size++;%0A                    next = %22%22;%0A                    for (int j = 0; j %3C size; j++) %7B%0A                        next += (j + 1);%0A                    %7D%0A                    continue out;%0A                %7D%0A                next += x++;%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1291