feat: add LeetCode problem 75 (#1113)

* added leetcode problem 75

* Update 75.c

resolved issues

* Update 75.c

* updating DIRECTORY.md

* Update 75.c

Removed the header file

* chore: apply suggestions from code review

Co-authored-by: Taj <tjgurwara99@users.noreply.github.com>

* updating DIRECTORY.md

Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: Taj <tjgurwara99@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions@users.noreply.github.com>
This commit is contained in:
Satvik 2023-01-21 05:20:49 +05:30 committed by GitHub
parent a680c83b83
commit 5ac30afa86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 0 deletions

View File

@ -172,6 +172,7 @@
* [1009](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1009.c)
* [101](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/101.c)
* [1019](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1019.c)
* [1026](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1026.c)
* [104](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/104.c)
* [108](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/108.c)
* [1089](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1089.c)
@ -179,6 +180,7 @@
* [11](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/11.c)
* [110](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/110.c)
* [112](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/112.c)
* [1147](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1147.c)
* [118](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/118.c)
* [1184](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1184.c)
* [1189](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1189.c)
@ -187,6 +189,7 @@
* [1207](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1207.c)
* [121](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/121.c)
* [125](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/125.c)
* [1283](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1283.c)
* [13](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/13.c)
* [136](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/136.c)
* [14](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/14.c)
@ -196,12 +199,15 @@
* [153](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/153.c)
* [160](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/160.c)
* [1653](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1653.c)
* [1657](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1657.c)
* [169](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/169.c)
* [1695](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1695.c)
* [1704](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1704.c)
* [173](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/173.c)
* [1752](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1752.c)
* [1769](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1769.c)
* [1833](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1833.c)
* [1838](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1838.c)
* [189](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/189.c)
* [190](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/190.c)
* [191](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/191.c)
@ -211,7 +217,9 @@
* [2024](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/2024.c)
* [203](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/203.c)
* [206](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/206.c)
* [2095](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/2095.c)
* [21](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/21.c)
* [2125](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/2125.c)
* [2130](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/2130.c)
* [215](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/215.c)
* [217](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/217.c)
@ -220,6 +228,7 @@
* [2256](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/2256.c)
* [226](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/226.c)
* [2270](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/2270.c)
* [2279](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/2279.c)
* [230](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/230.c)
* [2304](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/2304.c)
* [231](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/231.c)
@ -227,6 +236,8 @@
* [236](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/236.c)
* [24](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/24.c)
* [242](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/242.c)
* [2482](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/2482.c)
* [2501](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/2501.c)
* [26](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/26.c)
* [268](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/268.c)
* [27](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/27.c)
@ -264,23 +275,27 @@
* [66](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/66.c)
* [669](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/669.c)
* [674](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/674.c)
* [684](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/684.c)
* [7](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/7.c)
* [700](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/700.c)
* [701](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/701.c)
* [704](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/704.c)
* [709](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/709.c)
* [75](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/75.c)
* [771](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/771.c)
* [79](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/79.c)
* [8](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/8.c)
* [807](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/807.c)
* [82](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/82.c)
* [83](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/83.c)
* [841](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/841.c)
* [852](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/852.c)
* [876](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/876.c)
* [9](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/9.c)
* [901](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/901.c)
* [905](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/905.c)
* [917](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/917.c)
* [931](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/931.c)
* [938](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/938.c)
* [94](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/94.c)
* [965](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/965.c)

View File

@ -32,6 +32,7 @@
| 53 | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray/) | [C](./src/53.c) | Easy |
| 62 | [Unique Paths](https://leetcode.com/problems/unique-paths/description/) | [C](./src/62.c) | Medium |
| 66 | [Plus One](https://leetcode.com/problems/plus-one/) | [C](./src/66.c) | Easy |
| 75 | [Sort Colors](https://leetcode.com/problems/sort-colors/) | [C](./src/75.c) | Medium |
| 79 | [Word Search](https://leetcode.com/problems/word-search/) | [C](./src/79.c) | Medium |
| 82 | [Remove Duplicates from Sorted List II](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/) | [C](./src/82.c) | Medium |
| 83 | [Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list/) | [C](./src/83.c) | Easy |

24
leetcode/src/75.c Normal file
View File

@ -0,0 +1,24 @@
void swap(int *x, int *y){
if (x==y)
return;
*x = *x + *y;
*y= *x - *y;
*x= *x - *y;
}
void sortColors(int* arr, int n){
int start=0, mid=0, end=n-1;
while(mid<=end){
if(arr[mid]==1)
mid++;
else if(arr[mid]==0){
swap(&arr[mid],&arr[start]);
mid++;
start++;
}
else{
swap(&arr[mid],&arr[end]);
end--;
}
}
}