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; +} 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< +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