src/io/github/marwlod/burrows_wheeler/BurrowsWheeler.java
// reading from standard input and writing to standard output
reading from standard input and writing to standard output
reading from standard input and writing to standard output
public static void inverseTransform() {
        final int originalIndex = BinaryStdIn.readInt();
        final String in = BinaryStdIn.readString();
        final char[] encoded = in.toCharArray();
        final int[] counts = calculateCounts(encoded);
        int[] next = new int[in.length()];
        for (int i = 0; i < in.length(); i++) {
            char currChar = encoded[i];
            int charIndex = counts[currChar]++;
            if (charIndex == i) {
                next[(charIndex + 1) % in.length()] = i;
            } else {
                next[charIndex] = i;
            }
        }
        int count = 0;
        for (int i = next[originalIndex]; count < in.length(); i = next[i]) {
            BinaryStdOut.write(encoded[i]);
            count++;
        }
        BinaryStdOut.flush();
    }
public static void inverseTransform ( ) { final int originalIndex = BinaryStdIn . readInt ( ) ; final String in = BinaryStdIn . readString ( ) ; final char [ ] encoded = in . toCharArray ( ) ; final int [ ] counts = calculateCounts ( encoded ) ; int [ ] next = new int [ in . length ( ) ] ; for ( int i = 0 ; i < in . length ( ) ; i ++ ) { char currChar = encoded [ i ] ; int charIndex = counts [ currChar ] ++ ; if ( charIndex == i ) { next [ ( charIndex + 1 ) % in . length ( ) ] = i ; } else { next [ charIndex ] = i ; } } int count = 0 ; for ( int i = next [ originalIndex ] ; count < in . length ( ) ; i = next [ i ] ) { BinaryStdOut . write ( encoded [ i ] ) ; count ++ ; } BinaryStdOut . flush ( ) ; }
reading from standard input and writing to standard output
reading from standard input and writing to standard output