Skip to content

Commit

Permalink
Merge pull request SandeepanM2003#2 from jeetkanodia/add-code
Browse files Browse the repository at this point in the history
added new cpp solution
  • Loading branch information
SandeepanM2003 authored Oct 3, 2023
2 parents a3b4764 + ea2ff40 commit d66e4ff
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions C++/bubble_sort.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Question Link - https://www.codingninjas.com/studio/problems/bubble-sort_624380

void bubbleSort(int arr[], int n)
{
// write your code here
for (int i = n - 1; i >= 0; i--)
{
for (int j = 0; j <= i - 1; j++)
{
if (arr[j] > arr[j + 1])
{
int temp = arr[j + 1];
arr[j + 1] = arr[j];
arr[j] = temp;
}
}
}
}

0 comments on commit d66e4ff

Please sign in to comment.