由买买提看人间百态

topics

全部话题 - 话题: dpelement
(共0页)
D********g
发帖数: 650
1
来自主题: JobHunting版 - Algorithm Problem
/**
* In an exam you have n problems to work on. i=0, 1, ..., n-1.
The i-th problem takes you x[i] minutes, and give you a score s[i].
You have 60 minutes to work on them. How can you get the best score?
*/
static class DPElement {
int value;
int prevCostIdx; // 0-based cost idx
int takenThisElement; // 0/1, indicating whether taking current
element, idx 0 based.
public DPElement() {
value = 0;
prevCostIdx = 0;
tak... 阅读全帖
D********g
发帖数: 650
2
来自主题: JobHunting版 - 一道G家店面题
加上了backtracking:
static class DPElement {
int value;
int prevCostIdx; // 0-based cost idx
int takenThisElement; // 0/1, indicating whether taking current
element, idx 0 based.
public DPElement() {
value = 0;
prevCostIdx = 0;
takenThisElement = 0;
}
}
static String word2Anagram(final String word) {
if (word == null) {
return null;
}

int ht[] = new int[256];
f... 阅读全帖
(共0页)