diff --git a/hello.cpp b/hello.cpp new file mode 100644 index 0000000..99cd931 --- /dev/null +++ b/hello.cpp @@ -0,0 +1,29 @@ + #include +using namespace std; + +class Solution { +public: + bool hasPairWithSum(vector& arr, int target) { + int i = 0, j = arr.size() - 1; + while (i < j) { + int sum = arr[i] + arr[j]; + if (sum == target) return true; + else if (sum < target) i++; + else j--; + } + return false; + } +}; // ✅ class खत्म होने के बाद semicolon ज़रूरी है + +int main() { + vector arr = {1, 2, 4, 7, 11, 15}; + int target = 15; + + Solution sol; + if (sol.hasPairWithSum(arr, target)) + cout << "Pair Found!" << endl; + else + cout << "No Pair Found!" << endl; + + return 0; +}