Skip to content

Commit d41b590

Browse files
committed
update
1 parent 44a27ce commit d41b590

27 files changed

+709
-112
lines changed

README.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1-
leetcode: [https://leetcode.com/ly2015CNTJ/](https://leetcode.com/ly2015CNTJ/)
1+
leetcode: [https://leetcode.com/ly2015CNTJ/](https://leetcode.com/ly2015CNTJ/)
2+
3+
| Title | Category | Link | ext_info |
4+
| ------------------------------------------------------ | ------------- | ------------------------------------------------------------ | -------- |
5+
| leetcode - 1255. Maximum Score Words Formed by Letters | backtracking | [Maximum Score Words Formed by Letters - LeetCode](https://leetcode.com/problems/maximum-score-words-formed-by-letters/) | |
6+
| leetcode - 162. Find Peak Element | binary search | [Find Peak Element - LeetCode](https://leetcode.com/problems/find-peak-element/) | |
7+
| | | | |
8+
| | | | |
9+
| | | | |
10+
| | | | |
11+
| | | | |
12+
| | | | |
13+
| | | | |
14+
| | | | |
15+
| | | | |
16+
| | | | |
17+
| | | | |
18+
| | | | |
19+
| | | | |
20+
| | | | |
21+
| | | | |
22+
| | | | |
23+
| | | | |
24+

contest/leetcode_biweek_58/[editing]leetcode_1960_Maximum_Product_of_the_Length_of_Two_Palindromic_Substrings.java

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// AC: Runtime: 70 ms, faster than 50.00% of Java online submissions for Delete Characters to Make Fancy String.
2+
// Memory Usage: 94.1 MB, less than 50.00% of Java online submissions for Delete Characters to Make Fancy String.
3+
// .
4+
// T:O(n), S:O(n)
5+
//
6+
class Solution {
7+
public String makeFancyString(String s) {
8+
StringBuilder ret = new StringBuilder();
9+
int dupCount = 0;
10+
char lastChar = ' ';
11+
for (char c: s.toCharArray()) {
12+
if (lastChar == ' ') {
13+
dupCount = 1;
14+
lastChar = c;
15+
ret.append(c);
16+
continue;
17+
}
18+
19+
if (c == lastChar) {
20+
if (dupCount >= 2) {
21+
continue;
22+
} else {
23+
dupCount++;
24+
ret.append(c);
25+
}
26+
} else {
27+
dupCount = 1;
28+
ret.append(c);
29+
lastChar = c;
30+
}
31+
}
32+
33+
return ret.toString();
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
// AC: Runtime: 1 ms, faster than 100.00% of Java online submissions for Check if Move is Legal.
2+
// Memory Usage: 39.8 MB, less than 100.00% of Java online submissions for Check if Move is Legal.
3+
// check x-axios, y-axios, 45° diagonal, 135° diagonal
4+
// T:O(4 * n) ~ O(n), S:O(1)
5+
//
6+
class Solution {
7+
public boolean checkMove(char[][] board, int rMove, int cMove, char color) {
8+
char oppositeColor = ' ';
9+
if (color == 'B') {
10+
oppositeColor = 'W';
11+
} else {
12+
oppositeColor = 'B';
13+
}
14+
15+
// y-axios
16+
if (rMove >= 2) {
17+
if (board[rMove - 1][cMove] == oppositeColor) {
18+
for (int i = rMove - 2; i >= 0; i--) {
19+
if (board[i][cMove] == '.') {
20+
break;
21+
}
22+
if (board[i][cMove] == color) {
23+
return true;
24+
}
25+
}
26+
}
27+
}
28+
if (rMove <= 5) {
29+
if (board[rMove + 1][cMove] == oppositeColor) {
30+
for (int i = rMove + 2; i <= 7; i++) {
31+
if (board[i][cMove] == '.') {
32+
break;
33+
}
34+
if (board[i][cMove] == color) {
35+
return true;
36+
}
37+
}
38+
}
39+
}
40+
41+
// x-axios
42+
if (cMove >= 2) {
43+
if (board[rMove][cMove - 1] == oppositeColor) {
44+
for (int i = cMove - 2; i >= 0; i--) {
45+
if (board[rMove][i] == '.') {
46+
break;
47+
}
48+
if (board[rMove][i] == color) {
49+
return true;
50+
}
51+
}
52+
}
53+
}
54+
if (cMove <= 5) {
55+
if (board[rMove][cMove + 1] == oppositeColor) {
56+
for (int i = cMove + 2; i <= 7; i++) {
57+
if (board[rMove][i] == '.') {
58+
break;
59+
}
60+
if (board[rMove][i] == color) {
61+
return true;
62+
}
63+
}
64+
}
65+
}
66+
67+
// 45°
68+
if (rMove >= 2 && cMove <= 5) {
69+
if (board[rMove - 1][cMove + 1] == oppositeColor) {
70+
for (int i = 2; rMove - i >= 0 && cMove + i <= 7; i++) {
71+
if (board[rMove - i][cMove + i] == '.') {
72+
break;
73+
}
74+
if (board[rMove - i][cMove + i] == color) {
75+
return true;
76+
}
77+
}
78+
}
79+
}
80+
if (rMove <= 5 && cMove >= 2) {
81+
if (board[rMove + 1][cMove - 1] == oppositeColor) {
82+
for (int i = 2; rMove + i <= 7 && cMove - i >= 0; i++) {
83+
if (board[rMove + i][cMove - i] == '.') {
84+
break;
85+
}
86+
if (board[rMove + i][cMove - i] == color) {
87+
return true;
88+
}
89+
}
90+
}
91+
}
92+
93+
// 135°
94+
if (rMove >= 2 && cMove >= 2) {
95+
if (board[rMove - 1][cMove - 1] == oppositeColor) {
96+
for (int i = 2; rMove - i >= 0 && cMove - i >= 0; i++) {
97+
if (board[rMove - i][cMove - i] == '.') {
98+
break;
99+
}
100+
if (board[rMove - i][cMove - i] == color) {
101+
return true;
102+
}
103+
}
104+
}
105+
}
106+
if (rMove <= 5 && cMove <= 5) {
107+
if (board[rMove + 1][cMove + 1] == oppositeColor) {
108+
for (int i = 2; rMove + i <= 7 && cMove + i <= 7; i++) {
109+
if (board[rMove + i][cMove + i] == '.') {
110+
break;
111+
}
112+
if (board[rMove + i][cMove + i] == color) {
113+
return true;
114+
}
115+
}
116+
}
117+
}
118+
119+
return false;
120+
}
121+
}

leetcode_solved/[editing]leetcode_0051_N-Queens.cpp

-6
This file was deleted.

leetcode_solved/[editing]leetcode_0416_Partition_Equal_Subset_Sum.cpp

-6
This file was deleted.

leetcode_solved/[editing]leetcode_0459_Repeated_Substring_Pattern.cpp

-6
This file was deleted.

leetcode_solved/[editing]leetcode_0541_Reverse_String_II.cpp

-6
This file was deleted.

leetcode_solved/[editing]leetcode_0560_Subarray_Sum_Equals_K.cpp

-6
This file was deleted.

leetcode_solved/[editing]leetcode_0718_Maximum_Length_of_Repeated_Subarray.cpp

-6
This file was deleted.

leetcode_solved/[editing]leetcode_0916_Word_Subsets.cpp

-6
This file was deleted.

leetcode_solved/[editing]leetcode_1160_Find_Words_That_Can_Be_Formed_by_Characters.cpp

-63
This file was deleted.

leetcode_solved/[editing]leetcode_1277_Count_Square_Submatrices_with_All_Ones.cpp

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution {
2+
public:
3+
int findTheCity(int n, vector<vector<int>>& edges, int distanceThreshold) {
4+
5+
}
6+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution {
2+
public:
3+
int minDifficulty(vector<int>& jobDifficulty, int d) {
4+
5+
}
6+
};

0 commit comments

Comments
 (0)