Skip to content

Commit 13c0dea

Browse files
Merge branch 'doocs:main' into main
2 parents fc25c8a + bc7eb86 commit 13c0dea

File tree

284 files changed

+16700
-13797
lines changed

Some content is hidden

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

284 files changed

+16700
-13797
lines changed

.github/workflows/deploy.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ jobs:
1919
with:
2020
ref: docs
2121
path: mkdocs
22-
- run: mv mkdocs/* .
22+
- run: |
23+
mv -f mkdocs/* .
24+
mv solution/CONTEST_README.md docs/contest.md
25+
mv solution/CONTEST_README_EN.md docs-en/contest.md
2326
- name: Configure Git Credentials
2427
run: |
2528
git config user.name github-actions[bot]

.gitignore

-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
.cache
66
/node_modules
77
/solution/result.json
8-
/solution/contest.json
9-
/solution/contest_list.json
10-
/solution/raw.json
11-
/lcof/lcof.json
12-
/lcof/lcof_list.json
13-
/lcci/lcci.json
148
/solution/__pycache__
159
/solution/.env
1610
*.iml

requirements.txt

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
black==23.12.1
2-
Requests==2.31.0
3-
sortedcontainers==2.4.0
4-
urllib3==1.26.18
5-
mkdocs-git-committers-plugin-2==2.2.3
6-
mkdocs-material==9.5.7
7-
jieba==0.42.1
1+
black==24.2.0
2+
Requests==2.31.0

solution/0000-0099/0003.Longest Substring Without Repeating Characters/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<!-- 这里写题目描述 -->
1010

11-
<p>给定一个字符串 <code>s</code> ,请你找出其中不含有重复字符的&nbsp;<strong>最长子串&nbsp;</strong>的长度。</p>
11+
<p>给定一个字符串 <code>s</code> ,请你找出其中不含有重复字符的&nbsp;<strong>最长<span data-keyword="substring">子串</span></strong><strong>&nbsp;</strong>的长度。</p>
1212

1313
<p>&nbsp;</p>
1414

solution/0000-0099/0005.Longest Palindromic Substring/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<!-- 这里写题目描述 -->
1010

11-
<p>给你一个字符串 <code>s</code>,找到 <code>s</code> 中最长的回文子串。</p>
11+
<p>给你一个字符串 <code>s</code>,找到 <code>s</code> 中最长的回文<span data-keyword="substring">子串</span>。</p>
1212

1313
<p>如果字符串的反序与原始字符串相同,则该字符串称为回文字符串。</p>
1414

solution/0000-0099/0009.Palindrome Number/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<p>给你一个整数 <code>x</code> ,如果 <code>x</code> 是一个回文整数,返回 <code>true</code> ;否则,返回 <code>false</code> 。</p>
1212

13-
<p>回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。</p>
13+
<p><span data-keyword="palindrome-integer">回文数</span>是指正序(从左向右)和倒序(从右向左)读都是一样的整数。</p>
1414

1515
<ul>
1616
<li>例如,<code>121</code> 是回文,而 <code>123</code> 不是。</li>

solution/0000-0099/0023.Merge k Sorted Lists/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,7 @@ public class Solution {
348348
class ListNode {
349349
public $val;
350350
public $next;
351-
public function __construct($val = 0, $next = null)
352-
{
351+
public function __construct($val = 0, $next = null) {
353352
$this->val = $val;
354353
$this->next = $next;
355354
}

solution/0000-0099/0023.Merge k Sorted Lists/README_EN.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,7 @@ public class Solution {
347347
class ListNode {
348348
public $val;
349349
public $next;
350-
public function __construct($val = 0, $next = null)
351-
{
350+
public function __construct($val = 0, $next = null) {
352351
$this->val = $val;
353352
$this->next = $next;
354353
}

solution/0000-0099/0029.Divide Two Integers/README.md

+38
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,44 @@ public class Solution {
227227
}
228228
```
229229

230+
```php
231+
class Solution {
232+
/**
233+
* @param integer $a
234+
* @param integer $b
235+
* @return integer
236+
*/
237+
238+
function divide($a, $b) {
239+
if ($b == 0) {
240+
throw new Exception('Can not divide by 0');
241+
} elseif ($a == 0) {
242+
return 0;
243+
}
244+
if ($a == -2147483648 && $b == -1) {
245+
return 2147483647;
246+
}
247+
$sign = $a < 0 != $b < 0;
248+
249+
$a = abs($a);
250+
$b = abs($b);
251+
$ans = 0;
252+
while ($a >= $b) {
253+
$x = $b;
254+
$cnt = 1;
255+
while ($a >= $x << 1) {
256+
$x <<= 1;
257+
$cnt <<= 1;
258+
}
259+
$a -= $x;
260+
$ans += $cnt;
261+
}
262+
263+
return $sign ? -$ans : $ans;
264+
}
265+
}
266+
```
267+
230268
<!-- tabs:end -->
231269

232270
<!-- end -->

solution/0000-0099/0029.Divide Two Integers/README_EN.md

+38
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,44 @@ public class Solution {
225225
}
226226
```
227227

228+
```php
229+
class Solution {
230+
/**
231+
* @param integer $a
232+
* @param integer $b
233+
* @return integer
234+
*/
235+
236+
function divide($a, $b) {
237+
if ($b == 0) {
238+
throw new Exception('Can not divide by 0');
239+
} elseif ($a == 0) {
240+
return 0;
241+
}
242+
if ($a == -2147483648 && $b == -1) {
243+
return 2147483647;
244+
}
245+
$sign = $a < 0 != $b < 0;
246+
247+
$a = abs($a);
248+
$b = abs($b);
249+
$ans = 0;
250+
while ($a >= $b) {
251+
$x = $b;
252+
$cnt = 1;
253+
while ($a >= $x << 1) {
254+
$x <<= 1;
255+
$cnt <<= 1;
256+
}
257+
$a -= $x;
258+
$ans += $cnt;
259+
}
260+
261+
return $sign ? -$ans : $ans;
262+
}
263+
}
264+
```
265+
228266
<!-- tabs:end -->
229267

230268
<!-- end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
class Solution {
2+
/**
3+
* @param integer $a
4+
* @param integer $b
5+
* @return integer
6+
*/
7+
8+
function divide($a, $b) {
9+
if ($b == 0) {
10+
throw new Exception('Can not divide by 0');
11+
} elseif ($a == 0) {
12+
return 0;
13+
}
14+
if ($a == -2147483648 && $b == -1) {
15+
return 2147483647;
16+
}
17+
$sign = $a < 0 != $b < 0;
18+
19+
$a = abs($a);
20+
$b = abs($b);
21+
$ans = 0;
22+
while ($a >= $b) {
23+
$x = $b;
24+
$cnt = 1;
25+
while ($a >= $x << 1) {
26+
$x <<= 1;
27+
$cnt <<= 1;
28+
}
29+
$a -= $x;
30+
$ans += $cnt;
31+
}
32+
33+
return $sign ? -$ans : $ans;
34+
}
35+
}

solution/0000-0099/0030.Substring with Concatenation of All Words/README.md

+56
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,62 @@ public class Solution {
308308
}
309309
```
310310

311+
```php
312+
class Solution {
313+
/**
314+
* @param String $s
315+
* @param String[] $words
316+
* @return Integer[]
317+
*/
318+
function findSubstring($s, $words) {
319+
$cnt = [];
320+
foreach ($words as $w) {
321+
if (!isset($cnt[$w])) {
322+
$cnt[$w] = 1;
323+
} else {
324+
$cnt[$w]++;
325+
}
326+
}
327+
$m = strlen($s);
328+
$n = count($words);
329+
$k = strlen($words[0]);
330+
$ans = [];
331+
for ($i = 0; $i < $k; ++$i) {
332+
$cnt1 = [];
333+
$l = $i;
334+
$r = $i;
335+
$t = 0;
336+
while ($r + $k <= $m) {
337+
$w = substr($s, $r, $k);
338+
$r += $k;
339+
if (!array_key_exists($w, $cnt)) {
340+
$cnt1 = [];
341+
$l = $r;
342+
$t = 0;
343+
continue;
344+
}
345+
if (!isset($cnt1[$w])) {
346+
$cnt1[$w] = 1;
347+
} else {
348+
$cnt1[$w]++;
349+
}
350+
++$t;
351+
while ($cnt1[$w] > $cnt[$w]) {
352+
$remove = substr($s, $l, $k);
353+
$l += $k;
354+
$cnt1[$remove]--;
355+
$t--;
356+
}
357+
if ($t == $n) {
358+
$ans[] = $l;
359+
}
360+
}
361+
}
362+
return $ans;
363+
}
364+
}
365+
```
366+
311367
<!-- tabs:end -->
312368

313369
### 方法二

solution/0000-0099/0030.Substring with Concatenation of All Words/README_EN.md

+56
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,62 @@ public class Solution {
305305
}
306306
```
307307

308+
```php
309+
class Solution {
310+
/**
311+
* @param String $s
312+
* @param String[] $words
313+
* @return Integer[]
314+
*/
315+
function findSubstring($s, $words) {
316+
$cnt = [];
317+
foreach ($words as $w) {
318+
if (!isset($cnt[$w])) {
319+
$cnt[$w] = 1;
320+
} else {
321+
$cnt[$w]++;
322+
}
323+
}
324+
$m = strlen($s);
325+
$n = count($words);
326+
$k = strlen($words[0]);
327+
$ans = [];
328+
for ($i = 0; $i < $k; ++$i) {
329+
$cnt1 = [];
330+
$l = $i;
331+
$r = $i;
332+
$t = 0;
333+
while ($r + $k <= $m) {
334+
$w = substr($s, $r, $k);
335+
$r += $k;
336+
if (!array_key_exists($w, $cnt)) {
337+
$cnt1 = [];
338+
$l = $r;
339+
$t = 0;
340+
continue;
341+
}
342+
if (!isset($cnt1[$w])) {
343+
$cnt1[$w] = 1;
344+
} else {
345+
$cnt1[$w]++;
346+
}
347+
++$t;
348+
while ($cnt1[$w] > $cnt[$w]) {
349+
$remove = substr($s, $l, $k);
350+
$l += $k;
351+
$cnt1[$remove]--;
352+
$t--;
353+
}
354+
if ($t == $n) {
355+
$ans[] = $l;
356+
}
357+
}
358+
}
359+
return $ans;
360+
}
361+
}
362+
```
363+
308364
<!-- tabs:end -->
309365

310366
### Solution 2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
class Solution {
2+
/**
3+
* @param String $s
4+
* @param String[] $words
5+
* @return Integer[]
6+
*/
7+
function findSubstring($s, $words) {
8+
$cnt = [];
9+
foreach ($words as $w) {
10+
if (!isset($cnt[$w])) {
11+
$cnt[$w] = 1;
12+
} else {
13+
$cnt[$w]++;
14+
}
15+
}
16+
$m = strlen($s);
17+
$n = count($words);
18+
$k = strlen($words[0]);
19+
$ans = [];
20+
for ($i = 0; $i < $k; ++$i) {
21+
$cnt1 = [];
22+
$l = $i;
23+
$r = $i;
24+
$t = 0;
25+
while ($r + $k <= $m) {
26+
$w = substr($s, $r, $k);
27+
$r += $k;
28+
if (!array_key_exists($w, $cnt)) {
29+
$cnt1 = [];
30+
$l = $r;
31+
$t = 0;
32+
continue;
33+
}
34+
if (!isset($cnt1[$w])) {
35+
$cnt1[$w] = 1;
36+
} else {
37+
$cnt1[$w]++;
38+
}
39+
++$t;
40+
while ($cnt1[$w] > $cnt[$w]) {
41+
$remove = substr($s, $l, $k);
42+
$l += $k;
43+
$cnt1[$remove]--;
44+
$t--;
45+
}
46+
if ($t == $n) {
47+
$ans[] = $l;
48+
}
49+
}
50+
}
51+
return $ans;
52+
}
53+
}

0 commit comments

Comments
 (0)