Skip to content

Solution done for 0008 and 0009 in c language with all the formatted it with clang format as you told to do #4506

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 45 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 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
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
30 changes: 30 additions & 0 deletions solution/0000-0099/0008.String to Integer (atoi)/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,36 @@ class Solution {
}
```

#### C

```c
int myAtoi(char* s) {
int i = 0;

while (s[i] == ' ') {
i++;
}

int sign = 1;
if (s[i] == '-' || s[i] == '+') {
sign = (s[i] == '-') ? -1 : 1;
i++;
}

int res = 0;
while (isdigit(s[i])) {
int digit = s[i] - '0';
if (res > INT_MAX / 10 || (res == INT_MAX / 10 && digit > INT_MAX % 10)) {
return sign == 1 ? INT_MAX : INT_MIN;
}
res = res * 10 + digit;
i++;
}

return res * sign;
}
```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
30 changes: 30 additions & 0 deletions solution/0000-0099/0008.String to Integer (atoi)/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,36 @@ class Solution {
}
```

#### C

```c
int myAtoi(char* s) {
int i = 0;

while (s[i] == ' ') {
i++;
}

int sign = 1;
if (s[i] == '-' || s[i] == '+') {
sign = (s[i] == '-') ? -1 : 1;
i++;
}

int res = 0;
while (isdigit(s[i])) {
int digit = s[i] - '0';
if (res > INT_MAX / 10 || (res == INT_MAX / 10 && digit > INT_MAX % 10)) {
return sign == 1 ? INT_MAX : INT_MIN;
}
res = res * 10 + digit;
i++;
}

return res * sign;
}
```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
25 changes: 25 additions & 0 deletions solution/0000-0099/0008.String to Integer (atoi)/Solution.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
int myAtoi(char* s) {
int i = 0;

while (s[i] == ' ') {
i++;
}

int sign = 1;
if (s[i] == '-' || s[i] == '+') {
sign = (s[i] == '-') ? -1 : 1;
i++;
}

int res = 0;
while (isdigit(s[i])) {
int digit = s[i] - '0';
if (res > INT_MAX / 10 || (res == INT_MAX / 10 && digit > INT_MAX % 10)) {
return sign == 1 ? INT_MAX : INT_MIN;
}
res = res * 10 + digit;
i++;
}

return res * sign;
}
18 changes: 18 additions & 0 deletions solution/0000-0099/0009.Palindrome Number/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,24 @@ class Solution {
}
```

#### C

```c
bool isPalindrome(int x) {
if (x < 0 || (x != 0 && x % 10 == 0)) {
return false;
}

int y = 0;
while (y < x) {
y = y * 10 + x % 10;
x /= 10;
}

return (x == y || x == y / 10);
}
```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
18 changes: 18 additions & 0 deletions solution/0000-0099/0009.Palindrome Number/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,24 @@ class Solution {
}
```

#### C

```c
bool isPalindrome(int x) {
if (x < 0 || (x != 0 && x % 10 == 0)) {
return false;
}

int y = 0;
while (y < x) {
y = y * 10 + x % 10;
x /= 10;
}

return (x == y || x == y / 10);
}
```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
13 changes: 13 additions & 0 deletions solution/0000-0099/0009.Palindrome Number/Solution.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bool isPalindrome(int x) {
if (x < 0 || (x != 0 && x % 10 == 0)) {
return false;
}

int y = 0;
while (y < x) {
y = y * 10 + x % 10;
x /= 10;
}

return (x == y || x == y / 10);
}