From a0ae714934e9c0a7b92260a9fe7bab488e7ef5c5 Mon Sep 17 00:00:00 2001 From: Acejoy Date: Fri, 1 Oct 2021 21:46:14 +0530 Subject: [PATCH 1/3] Added the Solution to Problem#1 of Strings --- String/1.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 String/1.cpp diff --git a/String/1.cpp b/String/1.cpp new file mode 100644 index 0000000..4030e94 --- /dev/null +++ b/String/1.cpp @@ -0,0 +1,46 @@ +// Problem link : https://practice.geeksforgeeks.org/problems/palindrome-string0817/1 + +#include +using namespace std; + +class Solution{ +public: + + + int isPalindrome(string S) + { + // Your code goes here + int isPalin=1; + + int firstIndex = 0; + int lastIndex = S.length()-1; + + while(firstIndex Date: Fri, 1 Oct 2021 22:04:17 +0530 Subject: [PATCH 2/3] Added The Solution to Problem#27 of Array --- Array/27.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Array/27.cpp diff --git a/Array/27.cpp b/Array/27.cpp new file mode 100644 index 0000000..a759906 --- /dev/null +++ b/Array/27.cpp @@ -0,0 +1,66 @@ +// Problem link : https://practice.geeksforgeeks.org/problems/triplet-sum-in-array-1587115621/1 + +#include +using namespace std; + + + // } Driver Code Ends + + +class Solution{ + public: + // function to find the triplet which sum to x + // arr[] : The input Array + // N : Size of the Array + // X : Sum which you need to search for + + bool find3Numbers(int arr[], int N, int X) + { + //Your Code Here + + int Sum = 0; + sort(arr, arr+N); + //printArray(arr); + + for(int i=0; i X) { + rightPtr--; + } else { + leftPtr++; + } + } + } + + return false; + } + +}; + +// n = 5, X = 10 +// arr[] = [1 2 4 3 6] +// Output: +// 1 +// Explanation: +// The triplet {1, 3, 6} in +// the array sums up to 10. + +int main() +{ + int N=5,sum=10; + int i,A[N] = {1,2,4,3,6}; + + Solution ob; + cout << ob.find3Numbers(A, N, sum) << endl; + + return 0; +} From 53df8bc5f6331a5780920717bebcd8672d466032 Mon Sep 17 00:00:00 2001 From: Acejoy Date: Fri, 1 Oct 2021 22:16:24 +0530 Subject: [PATCH 3/3] Added The Solution Problem#2 of Matrix --- Matrix/2.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Matrix/2.cpp diff --git a/Matrix/2.cpp b/Matrix/2.cpp new file mode 100644 index 0000000..c64f0c4 --- /dev/null +++ b/Matrix/2.cpp @@ -0,0 +1,64 @@ +// { Driver Code Starts +//Initial template for C++ + +#include +using namespace std; + + +class Solution{ +public: + int median(vector> &matrix, int r, int c){ + // code here + int minElement = INT_MAX; + int maxELement = INT_MIN; + + for(int i=0; i> matrix(r, vector(c)); + matrix[0] = {1,3,5}; + matrix[1] = {2,6,9}; + matrix[2] = {3,6,9}; + Solution obj; + cout<