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
boolean Solution(Map<Char, int> sofar, List<Char> rest, int k) { | |
if (rest.isEmpty()) { | |
return validateAnswer(sofar); | |
} | |
k = k+1; | |
Char a = rest.poll(); | |
int[] candidates = findCandidates(sofar); | |
for(int i=0; i< candidates.length; i++) |
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
void printPath(Node node, int target) { | |
List<Node> path = new ArrayList<Node>(); | |
traversePath(node, target, path, 0); | |
} | |
void traversePath(Node node, int target, List<Node> path, level) { | |
if (node == null) return; | |
path.add(level, node); |
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
input : | |
Integer[] src; | |
int TARGER | |
countNumbers(src, 0, currentPath, results); | |
countNumbers(Integer[] src, int index, List<Integer> currentPath, List<List<Integer>> results) | |
{ | |
List<Integer> path = new ArrayList<Integer>(); | |
path.addAll(currentPath); |
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
int string_compare(char *s, char *t, int i, int j, ) | |
// s is inut text | |
// t is target | |
{ | |
int k; /* counter */ | |
int opt[3]; /* cost of the three options */ | |
int lowest_cost; /* lowest cost */ | |
if (i == 0) return(j * cost.insertion); | |
if (j == 0) return(i * cost.deletion); |
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
void sliding_window(int [] a, int[] b){ | |
for(i=0; i b[i-w+1] = Q.top(); | |
while(!Q.empty() && Q.back() < a[i]) { | |
Q.popBack(); | |
} | |
Q.pushBack(i); | |
while(!Q.empty() && Q.front() Q.popFront(); | |
} | |
} // end for loop | |
b[n-w] = Q.top(); |