This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TrianglePrinter { | |
public static void main(String[] args) { | |
printTriangle(5); | |
} | |
public static void printTriangle(int h) { | |
System.out.print(buildTriangle(h)); | |
} | |
private static String buildTriangle(int h) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
public class BM { | |
public static void main(String[] args) { | |
String source = "abcde"; | |
String template = "cd"; | |
System.out.println(getFirstEntry(source, template)); | |
} | |
public static HashMap<Character, Integer> makeOffsetTable(String pattern) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class KMP { | |
public static void main(String[] args) { | |
String string = "abcdefgabd"; | |
String word = "defg"; | |
System.out.println(getFirstEntry(string, word)); | |
} | |
public static int[] prefixFunction(String s) { | |
int[] p = new int[s.length()]; |