forked from doocs/leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
[pull] main from doocs:main #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1f57e5e
chore: auto compress images
yanglbme 526b902
feat: add solutions to lc problem: No.1643
yanglbme e43dd02
feat: add solutions to lc problem: No.1637
yanglbme 24d191c
feat: add solutions to lc problem: No.1655
yanglbme f51d868
feat: add php solution to lc problem: No.0769 (#957)
Qiu-IT 707af68
feat: add solutions to lc problem: No.2427
yanglbme 7e91d18
feat: update solutions to lc problem: No.2428
yanglbme 0212990
feat: update solutions to lc problem: No.12
thinkasany 4250319
feat: add solutions to lc problem: No.1637
yanglbme afd72a6
feat: add golang solution to lc problem: No.0087 (#959)
atompi a615012
feat: add solutions to lc problem: No.1854
yanglbme ca289c7
feat: add solutions to lc problem: No.1856
yanglbme 1b8e686
feat: add php solution to lc problem: No.0349 (#960)
Qiu-IT 72aac94
feat: add solutions to lc problem: No.2367
yanglbme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
solution/0000-0099/0012.Integer to Roman/Solution.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function intToRoman(num: number): string { | ||
const nums: number[] = [ | ||
1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1, | ||
]; | ||
const romans: string[] = [ | ||
'M', | ||
'CM', | ||
'D', | ||
'CD', | ||
'C', | ||
'XC', | ||
'L', | ||
'XL', | ||
'X', | ||
'IX', | ||
'V', | ||
'IV', | ||
'I', | ||
]; | ||
let ans: string = ''; | ||
for (let i = 0; i < nums.length; ++i) { | ||
while (num >= nums[i]) { | ||
num -= nums[i]; | ||
ans += romans[i]; | ||
} | ||
} | ||
return ans; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
solution/0000-0099/0087.Scramble String/Solution.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
func isScramble(s1 string, s2 string) bool { | ||
n := len(s1) | ||
dp := make([][][]bool, n+1) | ||
for i := range dp { | ||
dp[i] = make([][]bool, n) | ||
for j := range dp[i] { | ||
dp[i][j] = make([]bool, n+1) | ||
} | ||
} | ||
for i := 0; i < n; i++ { | ||
for j := 0; j < n; j++ { | ||
dp[i][j][1] = s1[i] == s2[j] | ||
} | ||
} | ||
for l := 2; l < n+1; l++ { | ||
for i1 := 0; i1 < n-l+1; i1++ { | ||
for i2 := 0; i2 < n-l+1; i2++ { | ||
for i := 1; i < l; i++ { | ||
if dp[i1][i2][i] && dp[i1+i][i2+i][l-i] { | ||
dp[i1][i2][l] = true | ||
break | ||
} | ||
if dp[i1][i2+l-i][i] && dp[i1+i][i2][l-i] { | ||
dp[i1][i2][l] = true | ||
break | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return dp[0][0][n] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
solution/0300-0399/0349.Intersection of Two Arrays/Solution.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Solution { | ||
/** | ||
* @param Integer[] $nums1 | ||
* @param Integer[] $nums2 | ||
* @return Integer[] | ||
*/ | ||
function intersection($nums1, $nums2) { | ||
$rs = []; | ||
$set1 = array_values(array_unique($nums1)); | ||
$set2 = array_values(array_unique($nums2)); | ||
for ($i = 0; $i < count($set1); $i++) { | ||
$hashmap[$set1[$i]] = 1; | ||
} | ||
for ($j = 0; $j < count($set2); $j++) { | ||
if ($hashmap[$set2[$j]]) array_push($rs, $set2[$j]); | ||
} | ||
return $rs; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
solution/0700-0799/0796.Rotate String/Solution.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Solution { | ||
/** | ||
* @param String $s | ||
* @param String $goal | ||
* @return Boolean | ||
*/ | ||
function rotateString($s, $goal) { | ||
return strlen($goal) === strlen($s) && strpos(($s.$s), $goal) !== false; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.