diff --git a/Insertion_Sort.cpp b/Insertion_Sort.cpp index bf8c6ed..769a5f7 100644 --- a/Insertion_Sort.cpp +++ b/Insertion_Sort.cpp @@ -38,7 +38,7 @@ void insertionSort(int arr[], int n) { int main() { int n; - cout<<"Enter number of elements : "; + cout<<"Enter the number of elements : "; cin>>n; int arr[n]; diff --git a/Kadanes_Algo b/Kadanes_Algo new file mode 100644 index 0000000..d788079 --- /dev/null +++ b/Kadanes_Algo @@ -0,0 +1,20 @@ +#include +using namespace std; +int main() +{ + int n; + cin >> n; + int ms = 0, cs = 0; + int arr[n]; + for (int i = 0; i < n; i++) + { + cin >> arr[i]; + cs += arr[i]; + if (cs < 0) + cs = 0; + else if (cs >= ms) + ms = cs; + } + cout << ms << endl; + return 0; +} diff --git a/rat_in_maze.cpp b/rat_in_maze.cpp new file mode 100644 index 0000000..808a791 --- /dev/null +++ b/rat_in_maze.cpp @@ -0,0 +1,75 @@ +#include +using namespace std; + +bool isSafe(int** arr, int x, int y, int n){ + + if( x>n; + + int** arr = new int*[n]; + for(int i=0; i>arr[i][j]; + } + } + + int** solArr = new int*[n]; + for(int i=0; i