Skip to content

Commit 9b8eedb

Browse files
committed
move order
1 parent de171e0 commit 9b8eedb

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

doc/summary.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ how to solve a problem
44
|step|describe|
55
|---|---|
66
|Concrete examples|Manually solve concrete instances of the problem and then build a general solution.|
7+
|Graph modeling|Describe the problem using a graph and solve it using an existing algorithm.|
78
|Case analysis|Split the input/execution into a number of cases and solve each case in isolation.|
89
|Iterative refinement|Most problems can be solved using a brute-force approach. Find such a solution and improve upon it.|
910
|Reduction|Use a well-known solution to some other problem as a subroutine.|
10-
|Graph modeling|Describe the problem using a graph and solve it using an existing algorithm.|
1111

1212
### data structure
1313
#### primitive
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.wcong.algorithm.epi.honors;
2+
3+
/**
4+
* Write a program to compute the maximum profit
5+
* that can be made by buying and selling a share k times over a given day range.
6+
* Your program takes k and an array of daily stock prices as input.
7+
*
8+
* @author wcong<wc19920415@gmail.com>
9+
* @since 12/03/2018
10+
*/
11+
public class BuySellStockKTimes {
12+
13+
static class Info {
14+
int times;
15+
int profit;
16+
}
17+
18+
public int maxProfit(int[] array, int k) {
19+
Info[] infos = new Info[array.length];
20+
infos[0] = new Info();
21+
for (int i = 1; i < array.length; i++) {
22+
for (int j = 0; j < i; j++) {
23+
if (array[j] < array[i]) {
24+
25+
}
26+
}
27+
}
28+
return 0;
29+
}
30+
31+
}

0 commit comments

Comments
 (0)