Skip to content

0012 and 0013 done in c #4511

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

Open
wants to merge 61 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
9de9aba
olution and Readme file updated with all the terms
pranjal030404 May 23, 2025
2e3bd2f
style: format code and docs with prettier
pranjal030404 May 23, 2025
4e9aab5
Update README.md
yanglbme May 23, 2025
6b22bb9
Update README_EN.md
yanglbme May 23, 2025
bb9981e
Update Solution.c
yanglbme May 23, 2025
c05b7a5
solution of 0003 done in c
pranjal030404 May 23, 2025
55bc9c9
Merge branch 'main' of https://github.com/pranjal030404/leetcode.doocs
pranjal030404 May 23, 2025
bc3ef00
0004 done in c language
pranjal030404 May 23, 2025
1358633
Merge branch 'main' into main
pranjal030404 May 23, 2025
c154596
style: format code and docs with prettier
pranjal030404 May 23, 2025
1366d3e
Merge branch 'main' into main
pranjal030404 May 25, 2025
f609530
Update README.md
yanglbme May 26, 2025
377d9dd
Update README_EN.md
yanglbme May 26, 2025
6053870
Update Solution.c
yanglbme May 26, 2025
77e281b
Update README.md
yanglbme May 26, 2025
90bb304
Update README_EN.md
yanglbme May 26, 2025
63a213f
Update Solution.c
yanglbme May 26, 2025
c207437
0005 and 0006 done in c language
pranjal030404 Jun 3, 2025
0496362
Merge branch 'main' of https://github.com/pranjal030404/leetcode.doocs
pranjal030404 Jun 3, 2025
66176ea
Merge branch 'main' into main
pranjal030404 Jun 3, 2025
db6e8f1
style: format code and docs with prettier
pranjal030404 Jun 3, 2025
67e39b5
Merge branch 'main' into main
pranjal030404 Jun 3, 2025
7c546ef
c added
pranjal030404 Jun 3, 2025
394c41d
Merge branch 'main' of https://github.com/pranjal030404/leetcode.doocs
pranjal030404 Jun 3, 2025
f4cc2cb
style: format code and docs with prettier
pranjal030404 Jun 3, 2025
7cbf92b
formatted
pranjal030404 Jun 3, 2025
d31fb66
Merge branch 'main' of https://github.com/pranjal030404/leetcode.doocs
pranjal030404 Jun 3, 2025
a304c26
Update Solution.c
yanglbme Jun 9, 2025
c7833f3
Update README.md
yanglbme Jun 9, 2025
c1744a1
Update README_EN.md
yanglbme Jun 9, 2025
abd5684
Update Solution.c
yanglbme Jun 9, 2025
a1051fa
Update README.md
yanglbme Jun 9, 2025
e085f12
Update README_EN.md
yanglbme Jun 9, 2025
0cca36a
Merge branch 'doocs:main' into main
pranjal030404 Jun 10, 2025
bca9136
Solution done for 0008 and 0009 in c language
pranjal030404 Jun 18, 2025
f997c7e
Merge branch 'doocs:main' into main
pranjal030404 Jun 18, 2025
9523135
style: format code and docs with prettier
pranjal030404 Jun 18, 2025
c86d561
Update README.md
yanglbme Jun 18, 2025
0865be2
Update README_EN.md
yanglbme Jun 18, 2025
63be5c0
Update Solution.c
yanglbme Jun 18, 2025
b50b69d
Update README.md
yanglbme Jun 18, 2025
3380c30
Update README_EN.md
yanglbme Jun 18, 2025
f2b6144
Update Solution.c
yanglbme Jun 18, 2025
32dd631
Update README.md
yanglbme Jun 18, 2025
e74cd36
Update README_EN.md
yanglbme Jun 18, 2025
acb9ee6
Solution of 0010 and 0011 in c language is done
pranjal030404 Jun 19, 2025
e02e0a6
Merge branch 'main' of https://github.com/pranjal030404/leetcode.doocs
pranjal030404 Jun 19, 2025
157f4ae
Merge branch 'main' into main
pranjal030404 Jun 19, 2025
4b3c784
style: format code and docs with prettier
pranjal030404 Jun 19, 2025
6b4f3d5
Create Solution2.c
yanglbme Jun 19, 2025
3edfb3d
Update Solution.c
yanglbme Jun 19, 2025
01e1e53
Update README.md
yanglbme Jun 19, 2025
59289cf
Update README_EN.md
yanglbme Jun 19, 2025
74f1997
Update Solution.c
yanglbme Jun 19, 2025
61bbe5f
Update README.md
yanglbme Jun 19, 2025
b5addc6
Update README_EN.md
yanglbme Jun 19, 2025
481cb58
Update README_EN.md
yanglbme Jun 19, 2025
04e664c
0012 and 0013 done
pranjal030404 Jun 20, 2025
3b9a66c
Merge branch 'main' of https://github.com/pranjal030404/leetcode.doocs
pranjal030404 Jun 20, 2025
3811cc1
Merge branch 'main' into main
pranjal030404 Jun 20, 2025
b496d54
style: format code and docs with prettier
pranjal030404 Jun 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,7 @@ bool isMatch(char* s, char* p) {
m = strlen(s);
n = strlen(p);
memset(f, 0, sizeof(f));
return dfs(0, 0);
}
return dfs(0, 0)
```

#### PHP
Expand Down
23 changes: 23 additions & 0 deletions solution/0000-0099/0012.Integer to Roman/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,29 @@ class Solution {
}
```

#### C

```C

char *intToRoman(int num) {
static char res[20];
res[0] = '\0';

int vals[] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
char *syms[] = {"M", "CM", "D", "CD", "C", "XC", "L",
"XL", "X", "IX", "V", "IV", "I"};

for (int i = 0; i < 13; i++) {
while (num >= vals[i]) {
strcat(res, syms[i]);
num -= vals[i];
}
}
return res;
}

```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
24 changes: 24 additions & 0 deletions solution/0000-0099/0012.Integer to Roman/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,30 @@ class Solution {
}
```

#### C

```C

char* intToRoman(int num) {
static char res[20];
res[0] = '\0';

int vals[] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
char* syms[] = {"M", "CM", "D", "CD", "C", "XC", "L",
"XL", "X", "IX", "V", "IV", "I"};

for (int i = 0; i < 13; i++) {
while (num >= vals[i]) {
strcat(res, syms[i]);
num -= vals[i];
}
}
return res;
}


```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
16 changes: 16 additions & 0 deletions solution/0000-0099/0012.Integer to Roman/Solution.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
char* intToRoman(int num) {
static char res[20];
res[0] = '\0';

int vals[] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
char* syms[] = {"M", "CM", "D", "CD", "C", "XC", "L",
"XL", "X", "IX", "V", "IV", "I"};

for (int i = 0; i < 13; i++) {
while (num >= vals[i]) {
strcat(res, syms[i]);
num -= vals[i];
}
}
return res;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions solution/0000-0099/0013.Roman to Integer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,32 @@ def roman_to_int(s)
end
```

#### C

```C

int romanToInt(char *s) {
int map[26] = {0};
map['I' - 'A'] = 1;
map['V' - 'A'] = 5;
map['X' - 'A'] = 10;
map['L' - 'A'] = 50;
map['C' - 'A'] = 100;
map['D' - 'A'] = 500;
map['M' - 'A'] = 1000;

int res = 0, i = 0;
while (s[i]) {
int val = map[s[i] - 'A'];
int next = s[i + 1] ? map[s[i + 1] - 'A'] : 0;
res += (val < next) ? -val : val;
i++;
}
return res;
}

```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
26 changes: 26 additions & 0 deletions solution/0000-0099/0013.Roman to Integer/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,32 @@ def roman_to_int(s)
end
```

#### C

```C

int romanToInt(char *s) {
int map[26] = {0};
map['I' - 'A'] = 1;
map['V' - 'A'] = 5;
map['X' - 'A'] = 10;
map['L' - 'A'] = 50;
map['C' - 'A'] = 100;
map['D' - 'A'] = 500;
map['M' - 'A'] = 1000;

int res = 0, i = 0;
while (s[i]) {
int val = map[s[i] - 'A'];
int next = s[i + 1] ? map[s[i + 1] - 'A'] : 0;
res += (val < next) ? -val : val;
i++;
}
return res;
}

```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
19 changes: 19 additions & 0 deletions solution/0000-0099/0013.Roman to Integer/Solution.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
int romanToInt(char* s) {
int map[26] = {0};
map['I' - 'A'] = 1;
map['V' - 'A'] = 5;
map['X' - 'A'] = 10;
map['L' - 'A'] = 50;
map['C' - 'A'] = 100;
map['D' - 'A'] = 500;
map['M' - 'A'] = 1000;

int res = 0, i = 0;
while (s[i]) {
int val = map[s[i] - 'A'];
int next = s[i + 1] ? map[s[i + 1] - 'A'] : 0;
res += (val < next) ? -val : val;
i++;
}
return res;
}