From 323ffcf0db4586cfcf48dd585c2a42949703b0c3 Mon Sep 17 00:00:00 2001 From: System Administrator Date: Sun, 31 Oct 2021 02:04:19 +0530 Subject: [PATCH 1/3] Leetcode 3Sum-Closest Problem --- LeetCode/3Sum-Closest/Readme.MD | 3 +++ LeetCode/3Sum-Closest/question.txt | 21 +++++++++++++++++ LeetCode/3Sum-Closest/solution.cpp | 38 ++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 LeetCode/3Sum-Closest/Readme.MD create mode 100644 LeetCode/3Sum-Closest/question.txt create mode 100644 LeetCode/3Sum-Closest/solution.cpp diff --git a/LeetCode/3Sum-Closest/Readme.MD b/LeetCode/3Sum-Closest/Readme.MD new file mode 100644 index 00000000..b80ae694 --- /dev/null +++ b/LeetCode/3Sum-Closest/Readme.MD @@ -0,0 +1,3 @@ +Question + +Link - [3Sum Closest](https://leetcode.com/problems/3sum-closest/) \ No newline at end of file diff --git a/LeetCode/3Sum-Closest/question.txt b/LeetCode/3Sum-Closest/question.txt new file mode 100644 index 00000000..fd5e8536 --- /dev/null +++ b/LeetCode/3Sum-Closest/question.txt @@ -0,0 +1,21 @@ +Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. + +Return the sum of the three integers. + +You may assume that each input would have exactly one solution. + +Example 1: + +Input: nums = [-1,2,1,-4], target = 1 +Output: 2 +Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). +Example 2: + +Input: nums = [0,0,0], target = 1 +Output: 0 + + +Constraints: +3 <= nums.length <= 1000 +-1000 <= nums[i] <= 1000 +-104 <= target <= 104 \ No newline at end of file diff --git a/LeetCode/3Sum-Closest/solution.cpp b/LeetCode/3Sum-Closest/solution.cpp new file mode 100644 index 00000000..ef3f4a08 --- /dev/null +++ b/LeetCode/3Sum-Closest/solution.cpp @@ -0,0 +1,38 @@ +class Solution { +public: + int threeSumClosest(vector& nums, int target) { + sort(nums.begin(), nums.end()); + vector v; + + long int closest = INT_MAX; + bool found = false; + for(int i=0; i Date: Sun, 31 Oct 2021 02:07:21 +0530 Subject: [PATCH 2/3] Reset commit --- LeetCode/3Sum-Closest/Readme.MD | 3 --- LeetCode/3Sum-Closest/question.txt | 21 ----------------- LeetCode/3Sum-Closest/solution.cpp | 38 ------------------------------ 3 files changed, 62 deletions(-) delete mode 100644 LeetCode/3Sum-Closest/Readme.MD delete mode 100644 LeetCode/3Sum-Closest/question.txt delete mode 100644 LeetCode/3Sum-Closest/solution.cpp diff --git a/LeetCode/3Sum-Closest/Readme.MD b/LeetCode/3Sum-Closest/Readme.MD deleted file mode 100644 index b80ae694..00000000 --- a/LeetCode/3Sum-Closest/Readme.MD +++ /dev/null @@ -1,3 +0,0 @@ -Question - -Link - [3Sum Closest](https://leetcode.com/problems/3sum-closest/) \ No newline at end of file diff --git a/LeetCode/3Sum-Closest/question.txt b/LeetCode/3Sum-Closest/question.txt deleted file mode 100644 index fd5e8536..00000000 --- a/LeetCode/3Sum-Closest/question.txt +++ /dev/null @@ -1,21 +0,0 @@ -Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. - -Return the sum of the three integers. - -You may assume that each input would have exactly one solution. - -Example 1: - -Input: nums = [-1,2,1,-4], target = 1 -Output: 2 -Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). -Example 2: - -Input: nums = [0,0,0], target = 1 -Output: 0 - - -Constraints: -3 <= nums.length <= 1000 --1000 <= nums[i] <= 1000 --104 <= target <= 104 \ No newline at end of file diff --git a/LeetCode/3Sum-Closest/solution.cpp b/LeetCode/3Sum-Closest/solution.cpp deleted file mode 100644 index ef3f4a08..00000000 --- a/LeetCode/3Sum-Closest/solution.cpp +++ /dev/null @@ -1,38 +0,0 @@ -class Solution { -public: - int threeSumClosest(vector& nums, int target) { - sort(nums.begin(), nums.end()); - vector v; - - long int closest = INT_MAX; - bool found = false; - for(int i=0; i Date: Sun, 31 Oct 2021 02:08:22 +0530 Subject: [PATCH 3/3] Leetcode 3Sum-closest problem --- LeetCode/3Sum-Closest/Readme.MD | 3 +++ LeetCode/3Sum-Closest/question.txt | 21 +++++++++++++++++ LeetCode/3Sum-Closest/solution.cpp | 38 ++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 LeetCode/3Sum-Closest/Readme.MD create mode 100644 LeetCode/3Sum-Closest/question.txt create mode 100644 LeetCode/3Sum-Closest/solution.cpp diff --git a/LeetCode/3Sum-Closest/Readme.MD b/LeetCode/3Sum-Closest/Readme.MD new file mode 100644 index 00000000..b80ae694 --- /dev/null +++ b/LeetCode/3Sum-Closest/Readme.MD @@ -0,0 +1,3 @@ +Question + +Link - [3Sum Closest](https://leetcode.com/problems/3sum-closest/) \ No newline at end of file diff --git a/LeetCode/3Sum-Closest/question.txt b/LeetCode/3Sum-Closest/question.txt new file mode 100644 index 00000000..fd5e8536 --- /dev/null +++ b/LeetCode/3Sum-Closest/question.txt @@ -0,0 +1,21 @@ +Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. + +Return the sum of the three integers. + +You may assume that each input would have exactly one solution. + +Example 1: + +Input: nums = [-1,2,1,-4], target = 1 +Output: 2 +Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). +Example 2: + +Input: nums = [0,0,0], target = 1 +Output: 0 + + +Constraints: +3 <= nums.length <= 1000 +-1000 <= nums[i] <= 1000 +-104 <= target <= 104 \ No newline at end of file diff --git a/LeetCode/3Sum-Closest/solution.cpp b/LeetCode/3Sum-Closest/solution.cpp new file mode 100644 index 00000000..ef3f4a08 --- /dev/null +++ b/LeetCode/3Sum-Closest/solution.cpp @@ -0,0 +1,38 @@ +class Solution { +public: + int threeSumClosest(vector& nums, int target) { + sort(nums.begin(), nums.end()); + vector v; + + long int closest = INT_MAX; + bool found = false; + for(int i=0; i