From c8e0564cfc3a66b0bb16da2cd61a86605a36f658 Mon Sep 17 00:00:00 2001 From: Its-suyash <72913942+Its-suyash@users.noreply.github.com> Date: Sun, 25 Oct 2020 11:25:41 +0530 Subject: [PATCH 1/2] Some changes in bubble.c --- Bubble_sort.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Bubble_sort.c b/Bubble_sort.c index 53c45d3..429282c 100644 --- a/Bubble_sort.c +++ b/Bubble_sort.c @@ -1,25 +1,19 @@ #include - int main() { int i,J,K,n,A[n],temp; - printf("Enter number of elements in an array: "); scanf("%d", &n); - printf("\nEnter the elements in array:\n"); - for (i=0; i<=n-1; i++) { scanf("%d",&A[i]); } - printf("\nThe original array is:\n"); for (i=0; i Date: Tue, 4 Oct 2022 11:58:40 +0530 Subject: [PATCH 2/2] Create SortColorNew.py --- .../75. Sort Colors/SortColorNew.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 LeetCode Solutions/75. Sort Colors/SortColorNew.py diff --git a/LeetCode Solutions/75. Sort Colors/SortColorNew.py b/LeetCode Solutions/75. Sort Colors/SortColorNew.py new file mode 100644 index 0000000..5ebc4fe --- /dev/null +++ b/LeetCode Solutions/75. Sort Colors/SortColorNew.py @@ -0,0 +1,15 @@ +# this solution is by 3 pointer + +class Solution: + def sortColors(self, nums): + beg, mid, end = 0, 0, len(nums) - 1 + while mid <= end: + if nums[mid] == 0: + nums[beg], nums[mid] = nums[mid], nums[beg] + mid += 1 + beg += 1 + elif nums[mid] == 2: + nums[mid], nums[end] = nums[end], nums[mid] + end -= 1 + else: #nums[mid] == 1: + mid += 1