diff --git a/DSA/Arrays/QuickSort.js b/DSA/Arrays/QuickSort.js new file mode 100644 index 0000000..b668065 --- /dev/null +++ b/DSA/Arrays/QuickSort.js @@ -0,0 +1,19 @@ +const quickSort = (arr) => { + if (arr.length <= 1) { + return arr; + } + + let pivot = arr[0]; + let leftArr = []; + let rightArr = []; + + for (let i = 1; i < arr.length; i++) { + if (arr[i] < pivot) { + leftArr.push(arr[i]); + } else { + rightArr.push(arr[i]); + } + } + + return [...quickSort(leftArr), pivot, ...quickSort(rightArr)]; + }; \ No newline at end of file diff --git a/DSA/BFS/waterJug.js b/DSA/BFS/waterJug.js index 6d887d0..529d85b 100644 --- a/DSA/BFS/waterJug.js +++ b/DSA/BFS/waterJug.js @@ -132,4 +132,6 @@ function printSolution(node) { (() => { const [m, n, d] = [4, 3, 2]; solve(m, n, d); -})(); \ No newline at end of file +})(); + +// Demo Change \ No newline at end of file