This file contains hidden or 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.HashSet; | |
import java.util.Scanner; | |
import java.util.Set; | |
public class Palindromes { | |
public static void main(String[] args) { | |
Set<String> words = new HashSet<String>(); | |
Scanner scanner = new Scanner(System.in); | |
while (scanner.hasNext()) { | |
String word = scanner.next().toLowerCase(); |
This file contains hidden or 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.Arrays; | |
public class AlgorithmL { | |
public static void main(String[] args) { | |
if (args.length != 1) { | |
System.err.println("Usage: provide a string (quoted if multiword)"); | |
System.exit(1); | |
} | |
char[] letters = args[0].toCharArray(); | |
Arrays.sort(letters); |
This file contains hidden or 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 org.opencv.core.Core | |
import org.opencv.core.CvType | |
import org.opencv.core.Mat | |
class Main { | |
static { System.loadLibrary(Core.NATIVE_LIBRARY_NAME); } | |
public static void main(String[] args) { | |
Mat m = Mat.eye(3, 3, CvType.CV_8UC1); | |
System.out.println("m = " + m.dump()); |
This file contains hidden or 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 org.opencv.core.Core; | |
import org.opencv.core.CvType; | |
import org.opencv.core.Mat; | |
public class OtherMain { | |
static { System.loadLibrary(Core.NATIVE_LIBRARY_NAME); } | |
public static void main(String[] args) { | |
Mat m = Mat.eye(3, 3, CvType.CV_8UC1); | |
System.out.println("m = " + m.dump()); |
This file contains hidden or 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 org.opencv.core.Core | |
import org.opencv.core.CvType | |
import org.opencv.core.Mat | |
class Main { | |
static { | |
Runtime.getRuntime().loadLibrary0(groovy.lang.GroovyClassLoader.class, Core.NATIVE_LIBRARY_NAME) | |
} | |
public static void main(String[] args) { |
This file contains hidden or 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.Arrays; | |
public class OneSwapMinNumber { | |
/** | |
* Worst case running time | |
* O(11*k) - k is the number of digits in the number (length of string) | |
*/ | |
public static String min(String num) { | |
char[] digits = num.toCharArray(); | |
int[] rindex = new int[10]; |
This file contains hidden or 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 InvokeStatic { | |
public static void someStaticMethod() {} | |
public static void main(String[] args) { | |
someStaticMethod(); | |
} | |
} | |
//Compiled from "InvokeStatic.java" | |
//public class InvokeStatic { | |
// public InvokeStatic(); |
This file contains hidden or 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 InvokeInterface { | |
public void methodA() { | |
Runnable r = new Runnable() { | |
@Override public void run() {} | |
}; | |
r.run(); | |
} | |
} | |
//Compiled from "InvokeInterface.java" |
This file contains hidden or 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
class A { | |
public void superMethod() {} | |
} | |
public class InvokeSpecial extends A { | |
// Implicit super constructor call - invokespecial | |
private byte b = 0; | |
{ // instance initializer - invokespecial | |
b = 1; | |
} |
This file contains hidden or 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 For { | |
public static void main(String[] args) { | |
char x = 'a'; | |
for (int i = 0; i < Integer.MAX_VALUE; i++) | |
for (int j = 0; j < Integer.MAX_VALUE; j++) | |
x = 'b'; | |
} | |
} | |
//*************************************************************************************** | |
// javap -c For |