这是命令行解析中非常常见的算法.给定一组预定义的长选项名称 - 计算唯一标识其中一个选项的最短前缀.例如,对于以下选项:
-help
-hostname
-portnumber
-name
-polymorphic
Run Code Online (Sandbox Code Playgroud)
这将是输出:
-he
-ho
-por
-n
-pol
Run Code Online (Sandbox Code Playgroud)
我正在考虑两种可能的方法 - 作为一棵树:
*
/ | \
/ | \
H N P
/ \ |
E O O
/ \
R L
Run Code Online (Sandbox Code Playgroud)
或者通过搜索子串:
for (String s : strings) {
for (int i = 1; i < s.length(); s++) {
if (search(strings,s.substring(0,i)) == 1) {
result.add(s.substring(0,i);
break;
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以,问题是:
我一次又一次地阅读和听到人们对Maven感到沮丧以及它有多复杂.而且使用Ant构建代码要容易得多.
但是,为了:
这就是Maven所需要的:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>type something here</groupId>
<artifactId>type something here</artifactId>
<version>type something here</version>
</project>
Run Code Online (Sandbox Code Playgroud)
什么是相应的最小Ant构建文件?