Skip to content

Commit bdc331c

Browse files
committed
feat: leetcode
1 parent da5c648 commit bdc331c

5 files changed

Lines changed: 52 additions & 4 deletions

File tree

leetcode/src/main/java/com/wdbyte/leetcode/LeetCode388_LengthLongestPath.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* 388. 文件的最长绝对路径
77
* https://leetcode-cn.com/problems/longest-absolute-file-path/
88
*
9-
* @author niulang
9+
* @author https://www.wdbyte.com
1010
* @date 2022/04/20
1111
*/
1212
public class LeetCode388_LengthLongestPath {

leetcode/src/main/java/com/wdbyte/leetcode/LeetCode396_MaxRotateFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* F(3) = (0 * 3) + (1 * 2) + (2 * 6) + (3 * 4) = 0 + 2 + 12 + 12 = 26
2323
* 所以 F(0), F(1), F(2), F(3) 中的最大值是 F(3) = 26 。
2424
*
25-
* @author niulang
25+
* @author https://www.wdbyte.com
2626
* @date 2022/04/22
2727
*/
2828
public class LeetCode396_MaxRotateFunction {

leetcode/src/main/java/com/wdbyte/leetcode/LeetCode515_FindLargeValueInEachTreeRow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* 515. 在每个树行中找最大值
1010
*
11-
* @author niulang
11+
* @author https://www.wdbyte.com
1212
* @date 2022/06/24
1313
*/
1414
public class LeetCode515_FindLargeValueInEachTreeRow {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.wdbyte.leetcode;
2+
3+
/**
4+
* https://leetcode-cn.com/problems/erect-the-fence/
5+
* 587. 安装栅栏
6+
* 在一个二维的花园中,有一些用 (x, y) 坐标表示的树。由于安装费用十分昂贵,你的任务是先用最短的绳子围起
7+
* 所有的树。只有当所有的树都被绳子包围时,花园才能围好栅栏。你需要找到正好位于栅栏边界上的树的坐标。
8+
*
9+
* @author https://www.wdbyte.com
10+
* @date 2022/04/23
11+
*/
12+
public class LeetCode587_OuterTrees {
13+
public static void main(String[] args) {
14+
int[][] trees = {{1, 1}, {2, 2}, {2, 0}, {2, 4}, {3, 3}, {4, 2}};
15+
System.out.println(multi(trees[2], trees[2], trees[4]));
16+
}
17+
18+
public int[][] outerTrees(int[][] trees) {
19+
// 1. 找到最左边的一个点
20+
int startX = 0;
21+
int startY = 0;
22+
for (int[] tree : trees) {
23+
int x = tree[0];
24+
int y = tree[1];
25+
if (x < startX) {
26+
startX = x;
27+
startY = y;
28+
}
29+
}
30+
// 2. 从最左边的一个点开始,寻找最大角度的点的连线
31+
return null;
32+
}
33+
34+
static int[][] sort(int[][] trees) {
35+
return trees;
36+
}
37+
38+
//计算叉积,p1,p2,p0都为点
39+
static double multi(int[] p1, int[] p2, int[] p0) {
40+
double x1, y1, x2, y2;
41+
x1 = p1[0] - p0[0];
42+
y1 = p1[1] - p0[1];
43+
x2 = p2[0] - p0[0];
44+
y2 = p2[1] - p0[1];
45+
return x1 * y2 - x2 * y1;
46+
}
47+
48+
}

leetcode/src/main/java/com/wdbyte/leetcode/LeetCode824_ToGoatLatin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* https://leetcode-cn.com/problems/goat-latin/
55
* 824. 山羊拉丁文
66
*
7-
* @author niulang
7+
* @author https://www.wdbyte.com
88
* @date 2022/04/21
99
*/
1010
public class LeetCode824_ToGoatLatin {

0 commit comments

Comments
 (0)