Skip to content

Commit 3cd9a0b

Browse files
committed
chore: update lc problems
1 parent 7ab0647 commit 3cd9a0b

File tree

122 files changed

+471
-246
lines changed

Some content is hidden

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

122 files changed

+471
-246
lines changed

.github/workflows/prettier.yml

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

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"trailingComma": "all",
77
"bracketSpacing": true,
88
"arrowParens": "avoid",
9-
"phpVersion": "8.1"
9+
"phpVersion": "8.1",
10+
"braceStyle": "1tbs"
1011
}

lcof/面试题05. 替换空格/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,13 @@ class Solution {
227227
* @return String
228228
*/
229229
function replaceSpace($s) {
230-
$rs = "";
230+
$rs = '';
231231
for ($i = 0; $i < strlen($s); $i++) {
232-
if ($s[$i] === " ") $rs = $rs."%20";
233-
else $rs = $rs.$s[$i];
232+
if ($s[$i] === ' ') {
233+
$rs = $rs . '%20';
234+
} else {
235+
$rs = $rs . $s[$i];
236+
}
234237
}
235238
return $rs;
236239
}

solution/0000-0099/0001.Two Sum/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ proc twoSum(nums: seq[int], target: int): seq[int] =
238238

239239
```php
240240
class Solution {
241-
242241
/**
243242
* @param Integer[] $nums
244243
* @param Integer $target

solution/0000-0099/0001.Two Sum/README_EN.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ proc twoSum(nums: seq[int], target: int): seq[int] =
227227

228228
```php
229229
class Solution {
230-
231230
/**
232231
* @param Integer[] $nums
233232
* @param Integer $target

solution/0000-0099/0013.Roman to Integer/README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,24 @@ class Solution {
243243
* @return Integer
244244
*/
245245
function romanToInt($s) {
246-
$hashmap = array('I' => 1, 'V' => 5, 'X' => 10, 'L' => 50, 'C' => 100, 'D' => 500, 'M' => 1000);
246+
$hashmap = [
247+
'I' => 1,
248+
'V' => 5,
249+
'X' => 10,
250+
'L' => 50,
251+
'C' => 100,
252+
'D' => 500,
253+
'M' => 1000,
254+
];
247255
$rs = 0;
248256
for ($i = 0; $i < strlen($s); $i++) {
249257
$left = $hashmap[$s[$i]];
250258
$right = $hashmap[$s[$i + 1]];
251-
if ($left >= $right) $rs += $left;
252-
else $rs -= $left;
259+
if ($left >= $right) {
260+
$rs += $left;
261+
} else {
262+
$rs -= $left;
263+
}
253264
}
254265
return $rs;
255266
}

solution/0000-0099/0013.Roman to Integer/README_EN.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,24 @@ class Solution {
221221
* @return Integer
222222
*/
223223
function romanToInt($s) {
224-
$hashmap = array('I' => 1, 'V' => 5, 'X' => 10, 'L' => 50, 'C' => 100, 'D' => 500, 'M' => 1000);
224+
$hashmap = [
225+
'I' => 1,
226+
'V' => 5,
227+
'X' => 10,
228+
'L' => 50,
229+
'C' => 100,
230+
'D' => 500,
231+
'M' => 1000,
232+
];
225233
$rs = 0;
226234
for ($i = 0; $i < strlen($s); $i++) {
227235
$left = $hashmap[$s[$i]];
228236
$right = $hashmap[$s[$i + 1]];
229-
if ($left >= $right) $rs += $left;
230-
else $rs -= $left;
237+
if ($left >= $right) {
238+
$rs += $left;
239+
} else {
240+
$rs -= $left;
241+
}
231242
}
232243
return $rs;
233244
}

solution/0000-0099/0014.Longest Common Prefix/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,14 @@ class Solution {
228228
* @return String
229229
*/
230230
function longestCommonPrefix($strs) {
231-
$rs = "";
231+
$rs = '';
232232
for ($i = 0; $i < strlen($strs[0]); $i++) {
233233
for ($j = 1; $j < count($strs); $j++) {
234-
if ($strs[0][$i] != $strs[$j][$i]) return $rs;
234+
if ($strs[0][$i] != $strs[$j][$i]) {
235+
return $rs;
236+
}
235237
}
236-
$rs = $rs.$strs[0][$i];
238+
$rs = $rs . $strs[0][$i];
237239
}
238240
return $rs;
239241
}

solution/0000-0099/0014.Longest Common Prefix/README_EN.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,14 @@ class Solution {
219219
* @return String
220220
*/
221221
function longestCommonPrefix($strs) {
222-
$rs = "";
222+
$rs = '';
223223
for ($i = 0; $i < strlen($strs[0]); $i++) {
224224
for ($j = 1; $j < count($strs); $j++) {
225-
if ($strs[0][$i] != $strs[$j][$i]) return $rs;
225+
if ($strs[0][$i] != $strs[$j][$i]) {
226+
return $rs;
227+
}
226228
}
227-
$rs = $rs.$strs[0][$i];
229+
$rs = $rs . $strs[0][$i];
228230
}
229231
return $rs;
230232
}

solution/0000-0099/0026.Remove Duplicates from Sorted Array/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,13 @@ impl Solution {
229229

230230
```php
231231
class Solution {
232-
233232
/**
234233
* @param Integer[] $nums
235234
* @return Integer
236235
*/
237236
function removeDuplicates(&$nums) {
238237
$k = 0;
239-
foreach($nums as $x) {
238+
foreach ($nums as $x) {
240239
if ($k == 0 || $x != $nums[$k - 1]) {
241240
$nums[$k++] = $x;
242241
}

0 commit comments

Comments
 (0)