From 17845485b6caa13aeed4f141639dcfd85e519a28 Mon Sep 17 00:00:00 2001 From: Nikhil More <149102391+Nikhil0-3@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:27:45 +0530 Subject: [PATCH] Time: 0 ms (100.00%), Space: 13.5 MB (24.36%) - LeetHub --- .../1346-check-if-n-and-its-double-exist.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 1346-check-if-n-and-its-double-exist/1346-check-if-n-and-its-double-exist.cpp diff --git a/1346-check-if-n-and-its-double-exist/1346-check-if-n-and-its-double-exist.cpp b/1346-check-if-n-and-its-double-exist/1346-check-if-n-and-its-double-exist.cpp new file mode 100644 index 0000000..8309f93 --- /dev/null +++ b/1346-check-if-n-and-its-double-exist/1346-check-if-n-and-its-double-exist.cpp @@ -0,0 +1,16 @@ +class Solution { +public: + bool checkIfExist(vector& arr) { + // Step 1: Iterate through all pairs of indices + for (int i = 0; i < arr.size(); i++) { + for (int j = 0; j < arr.size(); j++) { + // Step 2: Check the conditions + if (i != j && arr[i] == 2 * arr[j]) { + return true; + } + } + } + // No valid pair found + return false; + } +}; \ No newline at end of file