Skip to content

Commit 0bb4e77

Browse files
committed
update
1 parent 4756737 commit 0bb4e77

File tree

121 files changed

+1013
-424
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+1013
-424
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
- [](docs/data-structure/graph.md)
2626
- [](docs/data-structure/heap.md)
2727
- [散列表](docs/data-structure/hash.md)
28-
28+
- [字典树](docs/data-structure/trie.md)
29+
2930
### 算法
3031

3132
- [排序](docs/algorithm/sort.md)

assets/数据结构.eddx

37.6 KB
Binary file not shown.
File renamed without changes.

codes/algorithm/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,12 @@
2222
<maven.compiler.source>${java.version}</maven.compiler.source>
2323
<maven.compiler.target>${java.version}</maven.compiler.target>
2424
</properties>
25+
26+
<dependencies>
27+
<dependency>
28+
<groupId>io.github.dunwu</groupId>
29+
<artifactId>data-structure</artifactId>
30+
<version>1.0.0</version>
31+
</dependency>
32+
</dependencies>
2533
</project>

codes/algorithm/src/main/java/io/github/dunwu/algorithm/array/TwoSum.java

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package io.github.dunwu.algorithm.dynamic;
2+
3+
import io.github.dunwu.tool.util.ArrayUtil;
4+
import org.slf4j.Logger;
5+
import org.slf4j.LoggerFactory;
6+
7+
/**
8+
* @author <a href="mailto:forbreak@163.com">Zhang Peng</a>
9+
* @since 2020-03-06
10+
*/
11+
public class MaxSubArray {
12+
13+
private static final Logger log = LoggerFactory.getLogger(MaxSubArray.class);
14+
15+
public static int maxSubArray(int[] nums) {
16+
int[] result = new int[nums.length];
17+
result[0] = nums[0];
18+
int max = nums[0];
19+
for (int i = 1; i < nums.length; i++) {
20+
result[i] = Math.max(result[i - 1] + nums[i], nums[i]);
21+
if (max < result[i]) {
22+
max = result[i];
23+
}
24+
25+
if (log.isDebugEnabled()) {
26+
log.debug(ArrayUtil.toString(result));
27+
}
28+
}
29+
return max;
30+
}
31+
32+
public static void main(String[] args) {
33+
int[] array = new int[] { -2, 1, -3, 4, -1, 2, 1, -5, 4 };
34+
int max = MaxSubArray.maxSubArray(array);
35+
System.out.println("max = " + max);
36+
}
37+
38+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* 动态规划算法
3+
*
4+
* @author <a href="mailto:forbreak@163.com">Zhang Peng</a>
5+
* @since 2020-03-06
6+
*/
7+
package io.github.dunwu.algorithm.dynamic;

codes/algorithm/src/main/java/io/github/dunwu/algorithm/search/SearchStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.github.dunwu.algorithm.search;
22

3-
import io.github.dunwu.algorithm.util.ArrayUtil;
3+
import io.github.dunwu.tool.util.ArrayUtil;
44
import org.slf4j.Logger;
55
import org.slf4j.LoggerFactory;
66

@@ -21,7 +21,7 @@ public SearchStrategy(Search search) {
2121

2222
public int find(Integer[] list, int key) {
2323
logger.info(this.search.getClass().getSimpleName() + " 查找开始:");
24-
logger.info("要查找的线性表:{}", ArrayUtil.getArrayString(list, 0, list.length - 1));
24+
logger.info("要查找的线性表:{}", ArrayUtil.toString(list));
2525
logger.info("要查找的 key:{}", key);
2626

2727
int index = this.search.find(list, key);

codes/algorithm/src/main/java/io/github/dunwu/algorithm/util/ArrayUtil.java

Lines changed: 0 additions & 172 deletions
This file was deleted.

codes/algorithm/src/main/resources/logback.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
<!-- LOGGER BEGIN -->
3333
<!-- 本项目的日志记录,分级打印 -->
34-
<logger name="io.github.dunwu" level="INFO" additivity="false">
34+
<logger name="io.github.dunwu" level="DEBUG" additivity="false">
3535
<appender-ref ref="ALL" />
3636
<appender-ref ref="STDOUT" />
3737
</logger>

0 commit comments

Comments
 (0)