-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Solution of 0010 and 0011 done in c language #4508
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
57 commits
Select commit
Hold shift + click to select a range
9de9aba
olution and Readme file updated with all the terms
pranjal030404 2e3bd2f
style: format code and docs with prettier
pranjal030404 4e9aab5
Update README.md
yanglbme 6b22bb9
Update README_EN.md
yanglbme bb9981e
Update Solution.c
yanglbme c05b7a5
solution of 0003 done in c
pranjal030404 55bc9c9
Merge branch 'main' of https://github.com/pranjal030404/leetcode.doocs
pranjal030404 bc3ef00
0004 done in c language
pranjal030404 1358633
Merge branch 'main' into main
pranjal030404 c154596
style: format code and docs with prettier
pranjal030404 1366d3e
Merge branch 'main' into main
pranjal030404 f609530
Update README.md
yanglbme 377d9dd
Update README_EN.md
yanglbme 6053870
Update Solution.c
yanglbme 77e281b
Update README.md
yanglbme 90bb304
Update README_EN.md
yanglbme 63a213f
Update Solution.c
yanglbme c207437
0005 and 0006 done in c language
pranjal030404 0496362
Merge branch 'main' of https://github.com/pranjal030404/leetcode.doocs
pranjal030404 66176ea
Merge branch 'main' into main
pranjal030404 db6e8f1
style: format code and docs with prettier
pranjal030404 67e39b5
Merge branch 'main' into main
pranjal030404 7c546ef
c added
pranjal030404 394c41d
Merge branch 'main' of https://github.com/pranjal030404/leetcode.doocs
pranjal030404 f4cc2cb
style: format code and docs with prettier
pranjal030404 7cbf92b
formatted
pranjal030404 d31fb66
Merge branch 'main' of https://github.com/pranjal030404/leetcode.doocs
pranjal030404 a304c26
Update Solution.c
yanglbme c7833f3
Update README.md
yanglbme c1744a1
Update README_EN.md
yanglbme abd5684
Update Solution.c
yanglbme a1051fa
Update README.md
yanglbme e085f12
Update README_EN.md
yanglbme 0cca36a
Merge branch 'doocs:main' into main
pranjal030404 bca9136
Solution done for 0008 and 0009 in c language
pranjal030404 f997c7e
Merge branch 'doocs:main' into main
pranjal030404 9523135
style: format code and docs with prettier
pranjal030404 c86d561
Update README.md
yanglbme 0865be2
Update README_EN.md
yanglbme 63be5c0
Update Solution.c
yanglbme b50b69d
Update README.md
yanglbme 3380c30
Update README_EN.md
yanglbme f2b6144
Update Solution.c
yanglbme 32dd631
Update README.md
yanglbme e74cd36
Update README_EN.md
yanglbme acb9ee6
Solution of 0010 and 0011 in c language is done
pranjal030404 e02e0a6
Merge branch 'main' of https://github.com/pranjal030404/leetcode.doocs
pranjal030404 157f4ae
Merge branch 'main' into main
pranjal030404 4b3c784
style: format code and docs with prettier
pranjal030404 6b4f3d5
Create Solution2.c
yanglbme 3edfb3d
Update Solution.c
yanglbme 01e1e53
Update README.md
yanglbme 59289cf
Update README_EN.md
yanglbme 74f1997
Update Solution.c
yanglbme 61bbe5f
Update README.md
yanglbme b5addc6
Update README_EN.md
yanglbme 481cb58
Update README_EN.md
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
33 changes: 33 additions & 0 deletions
solution/0000-0099/0010.Regular Expression Matching/Solution.c
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,33 @@ | ||
| #define MAX_LEN 1000 | ||
|
|
||
| char *ss, *pp; | ||
| int m, n; | ||
| int f[MAX_LEN + 1][MAX_LEN + 1]; | ||
|
|
||
| bool dfs(int i, int j) { | ||
| if (j >= n) { | ||
| return i == m; | ||
| } | ||
| if (f[i][j] != 0) { | ||
| return f[i][j] == 1; | ||
| } | ||
| int res = -1; | ||
| if (j + 1 < n && pp[j + 1] == '*') { | ||
| if (dfs(i, j + 2) || (i < m && (ss[i] == pp[j] || pp[j] == '.') && dfs(i + 1, j))) { | ||
| res = 1; | ||
| } | ||
| } else if (i < m && (ss[i] == pp[j] || pp[j] == '.') && dfs(i + 1, j + 1)) { | ||
| res = 1; | ||
| } | ||
| f[i][j] = res; | ||
| return res == 1; | ||
| } | ||
|
|
||
| bool isMatch(char* s, char* p) { | ||
| ss = s; | ||
| pp = p; | ||
| m = strlen(s); | ||
| n = strlen(p); | ||
| memset(f, 0, sizeof(f)); | ||
| return dfs(0, 0); | ||
| } |
20 changes: 20 additions & 0 deletions
solution/0000-0099/0010.Regular Expression Matching/Solution2.c
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,20 @@ | ||
| bool isMatch(char* s, char* p) { | ||
| int m = strlen(s), n = strlen(p); | ||
| bool f[m + 1][n + 1]; | ||
| memset(f, 0, sizeof(f)); | ||
| f[0][0] = true; | ||
|
|
||
| for (int i = 0; i <= m; ++i) { | ||
| for (int j = 1; j <= n; ++j) { | ||
| if (p[j - 1] == '*') { | ||
| f[i][j] = f[i][j - 2]; | ||
| if (i > 0 && (p[j - 2] == '.' || p[j - 2] == s[i - 1])) { | ||
| f[i][j] = f[i][j] || f[i - 1][j]; | ||
| } | ||
| } else if (i > 0 && (p[j - 1] == '.' || p[j - 1] == s[i - 1])) { | ||
| f[i][j] = f[i - 1][j - 1]; | ||
| } | ||
| } | ||
| } | ||
| return f[m][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
22 changes: 22 additions & 0 deletions
solution/0000-0099/0011.Container With Most Water/Solution.c
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,22 @@ | ||
| int min(int a, int b) { | ||
| return a < b ? a : b; | ||
| } | ||
|
|
||
| int max(int a, int b) { | ||
| return a > b ? a : b; | ||
| } | ||
|
|
||
| int maxArea(int* height, int heightSize) { | ||
| int l = 0, r = heightSize - 1; | ||
| int ans = 0; | ||
| while (l < r) { | ||
| int t = min(height[l], height[r]) * (r - l); | ||
| ans = max(ans, t); | ||
| if (height[l] < height[r]) { | ||
| ++l; | ||
| } else { | ||
| --r; | ||
| } | ||
| } | ||
| return ans; | ||
| } |
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.