Skip to content

Instantly share code, notes, and snippets.

View kwonghung-YIP's full-sized avatar

Kwong-Hung YIP kwonghung-YIP

View GitHub Profile
@kwonghung-YIP
kwonghung-YIP / list_all_combination.java
Last active May 17, 2022 01:19
Find the binary string of a long value with bitwise operator (Java)
// "static void main" must be defined in a public class.
public class Main {
public static void main(String[] args) {
listItem(new String[] {"A","B","C","D","E","F"});
}
static public void listItem(String[] names) {
int n = names.length;
for (int c=0;c<Math.pow(2,n);c++) {
System.out.print("{");
@kwonghung-YIP
kwonghung-YIP / knapsack.java
Created May 25, 2022 20:08
Knapsack problem
// "static void main" must be defined in a public class.
public class Knapsack {
private String[] name;
private int[] weight;
private int[] value;
private int[][] m;
private int capacity;
public static void main(String[] args) {