question_slug stringlengths 3 77 | title stringlengths 1 183 | slug stringlengths 12 45 | summary stringlengths 1 160 ⌀ | author stringlengths 2 30 | certification stringclasses 2
values | created_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | updated_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | hit_count int64 0 10.6M | has_video bool 2
classes | content stringlengths 4 576k | upvotes int64 0 11.5k | downvotes int64 0 358 | tags stringlengths 2 193 | comments int64 0 2.56k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
largest-positive-integer-that-exists-with-its-negative | 💯Faster✅💯Lesser✅2 Methods🧠Detailed Approach🎯Two Pointer🔥Python🐍Java☕C++😎 | fasterlesser2-methodsdetailed-approachtw-3p7a | \uD83D\uDE80 Hi, I\'m Mohammed Raziullah Ansari, and I\'m excited to share 2 ways to solve this question with detailed explanation of each approach:\n\n# \uD83C | Mohammed_Raziullah_Ansari | NORMAL | 2024-05-02T01:01:54.847128+00:00 | 2024-05-02T19:02:49.215536+00:00 | 24,235 | false | # \uD83D\uDE80 Hi, I\'m [Mohammed Raziullah Ansari](https://leetcode.com/Mohammed_Raziullah_Ansari/), and I\'m excited to share 2 ways to solve this question with detailed explanation of each approach:\n\n# \uD83C\uDFAFProblem Explaination: \nYou are given an array of integers. Your task is to find the largest positive... | 62 | 7 | ['Array', 'Hash Table', 'Two Pointers', 'Binary Search', 'Sorting', 'C++', 'Java', 'Python3'] | 32 |
largest-positive-integer-that-exists-with-its-negative | ✅C++ | ✅2 pointers approach | ✅Easy Approach | c-2-pointers-approach-easy-approach-by-y-4p6u | Please upvote if you find this solution helpful :)\n\nclass Solution \n{\npublic:\n int findMaxK(vector<int>& nums) \n {\n sort(nums.begin(), nums. | Yash2arma | NORMAL | 2022-10-16T04:01:18.889269+00:00 | 2022-10-16T09:08:49.219127+00:00 | 7,399 | false | **Please upvote if you find this solution helpful :)**\n```\nclass Solution \n{\npublic:\n int findMaxK(vector<int>& nums) \n {\n sort(nums.begin(), nums.end());\n int low=0, high=nums.size()-1;\n \n while(low < high)\n {\n if((nums[low] + nums[high]) == 0)\n ... | 62 | 1 | ['Two Pointers', 'C', 'C++'] | 11 |
largest-positive-integer-that-exists-with-its-negative | [Python3] simple O(n) beginner friendly! | python3-simple-on-beginner-friendly-by-m-t4f2 | First, convert the nums into a set for quick access.\nSecond, go over the entire nums, for each element k, do:\n1. check if k is positive.\n2. check if -k exist | MeidaChen | NORMAL | 2022-10-16T04:01:40.826841+00:00 | 2024-01-04T19:24:58.382170+00:00 | 3,155 | false | First, convert the nums into a set for quick access.\nSecond, go over the entire nums, for each element k, do:\n1. check if k is positive.\n2. check if -k exist in nums using the set, which takes O(1).\n3. check if k is larger than the largest element we have seen so far. And if it is, update the largest element so far... | 40 | 5 | [] | 11 |
largest-positive-integer-that-exists-with-its-negative | Array | array-by-votrubac-w1qy | C++\ncpp\nint findMaxK(vector<int>& nums) {\n int arr[2001] = {}, res = -1;\n for (int n : nums) {\n if (arr[-n + 1000])\n res = max(res | votrubac | NORMAL | 2022-10-16T04:03:27.271827+00:00 | 2022-10-16T04:03:27.271866+00:00 | 2,374 | false | **C++**\n```cpp\nint findMaxK(vector<int>& nums) {\n int arr[2001] = {}, res = -1;\n for (int n : nums) {\n if (arr[-n + 1000])\n res = max(res, abs(n));\n ++arr[n + 1000]; \n }\n return res;\n}\n``` | 37 | 0 | [] | 6 |
largest-positive-integer-that-exists-with-its-negative | 👏Best Java Solution🎉 || ⏩Fastest🤯 ||✅Simple & Easy Well Explained Approach🔥💥 | best-java-solution-fastest-simple-easy-w-v8h2 | Intuition\nThe problem aims to find the maximum absolute value among pairs of numbers where one is the negative of the other, given an array of integers. It uti | Rutvik_Jasani | NORMAL | 2024-05-02T03:17:06.610584+00:00 | 2024-05-03T04:17:08.930086+00:00 | 4,069 | false | # Intuition\nThe problem aims to find the maximum absolute value among pairs of numbers where one is the negative of the other, given an array of integers. It utilizes HashSet for efficient lookup of negative counterparts.\n\n# I Think This Can Help You(For Proof Click on the Image)\n[![Screenshot 2024-02-24 232407.png... | 29 | 0 | ['Array', 'Hash Table', 'Two Pointers', 'Sorting', 'Java'] | 4 |
largest-positive-integer-that-exists-with-its-negative | Python || 2 lines, T/S: 97%/ 77% | python-2-lines-ts-97-77-by-spaulding-96i1 | \nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n nums = set(nums)\n return max(({x for x in nums if -x in nums}), default=-1)\ | Spaulding_ | NORMAL | 2022-10-16T17:29:44.337486+00:00 | 2024-06-15T19:14:51.761767+00:00 | 885 | false | ```\nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n nums = set(nums)\n return max(({x for x in nums if -x in nums}), default=-1)\n```\n[https://leetcode.com/problems/largest-positive-integer-that-exists-with-its-negative/submissions/1246950981/](https://leetcode.com/problems/largest-po... | 25 | 0 | ['Python', 'Python3'] | 4 |
largest-positive-integer-that-exists-with-its-negative | ✅Variation of TWO SUM Problem||Two approaches | variation-of-two-sum-problemtwo-approach-pzmw | First Approach\n#### This problem is similar to Two sum problem \n\nTwo Sum Problem :- finding two elements that make up a sum k\nThis problem :- the value of | dinesh55 | NORMAL | 2022-10-16T04:28:44.067070+00:00 | 2022-10-16T08:40:03.767962+00:00 | 1,976 | false | ### First Approach\n#### This problem is similar to Two sum problem \n\n`Two Sum Problem :- finding two elements that make up a sum k`\n`This problem :- the value of k is zero that is sum we need to find is 0 and then if there are multiple of them return the max`\n\nSo simply we need to find its additive inverse \n\n`... | 23 | 0 | ['Array', 'C', 'Sorting'] | 7 |
largest-positive-integer-that-exists-with-its-negative | 2 methods||sort+2 pointer vs 1 pass seen Array||8ms Beats 97.34% | 2-methodssort2-pointer-vs-1-pass-seen-ar-eocb | Intuition\n Describe your first thoughts on how to solve this problem. \n2 methods.\n1. Sorting nums + 2 pointer\n2. 1 pass using seen array (a unsigned char ar | anwendeng | NORMAL | 2024-05-02T01:40:32.472173+00:00 | 2024-05-02T01:52:34.869422+00:00 | 5,685 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n2 methods.\n1. Sorting nums + 2 pointer\n2. 1 pass using seen array (a unsigned char array is enough)\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe 1st method needs sorting O(n log n) time which is a very stan... | 22 | 0 | ['Array', 'Two Pointers', 'Bit Manipulation', 'Sorting', 'C++'] | 6 |
largest-positive-integer-that-exists-with-its-negative | Hashing [C++/Java] | hashing-cjava-by-xxvvpp-40eu | Count positive whose negative is there in the array using hashing.\n\nTime - O(n)\nSpace - O(n)\n# C++\n int findMaxK(vector& a) {\n unordered_set st( | xxvvpp | NORMAL | 2022-10-16T04:01:57.176722+00:00 | 2022-10-16T04:10:52.980083+00:00 | 2,738 | false | Count positive whose `negative` is there in the array using `hashing`.\n\nTime - O(`n`)\nSpace - O(`n`)\n# C++\n int findMaxK(vector<int>& a) {\n unordered_set<int> st(begin(a),end(a));\n int res = -1;\n for(int p : a) \n if(p > 0 and st.count(-p)) res = max(res , p);\n return ... | 22 | 1 | ['C', 'Java'] | 9 |
largest-positive-integer-that-exists-with-its-negative | C++ || 6 different approaches || clean code | c-6-different-approaches-clean-code-by-h-jjrk | The leetcode runtimes are not very consistent, but approach 3 seems to be the fastest.\n\n### Approach 1: brute force (127ms)\n\nThe problem is constraint enoug | heder | NORMAL | 2022-10-16T18:43:25.252560+00:00 | 2024-05-02T19:15:28.592682+00:00 | 1,064 | false | The leetcode runtimes are not very consistent, but approach 3 seems to be the fastest.\n\n### Approach 1: brute force (127ms)\n\nThe problem is constraint enough that we can just use brute force.\n\n```cpp\n static int findMaxK(const vector<int>& nums) {\n int ans = -1;\n for (int i : nums)\n ... | 20 | 0 | ['Two Pointers', 'C', 'Sorting', 'C++'] | 8 |
largest-positive-integer-that-exists-with-its-negative | ✅Beats 96% |🔥 Easy, Fast and Efficient using HashSet🔥🔥O(n) time and space complexity 🔥2 pass🔥 | beats-96-easy-fast-and-efficient-using-h-cudn | \n\n\n\n# Intuition\nTo find the largest positive integer k such that -k also exists in the array, we can make array into hashset so that search takes O(1) time | Saketh3011 | NORMAL | 2024-05-02T00:31:06.008861+00:00 | 2024-05-02T19:21:39.401774+00:00 | 6,390 | false | \n\n\n\n# Intuition\nTo find the largest positive integer k such that -k also exists in the array, we can make array into hashset so that search takes O(1) time complexity. And iterate through the hashset a... | 16 | 2 | ['Python', 'C++', 'Java', 'Python3', 'JavaScript'] | 9 |
largest-positive-integer-that-exists-with-its-negative | ☠💀💯 Faster✅💯 Lesser🧠 🎯 C++✅Python3✅Java✅C✅Python✅C#✅💥🔥💫Explained☠💥🔥 Beats 💯 | faster-lesser-cpython3javacpythoncexplai-1wu2 | Intuition\n\n\n\nC++ []\nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n sort(nums.begin(), nums.end());\n int low = 0, high = | Edwards310 | NORMAL | 2024-05-02T01:58:50.792625+00:00 | 2024-05-02T08:55:42.358782+00:00 | 1,967 | false | # Intuition\n\n\n\n- Space complexity:O(N)\n\n# Code\nJAVA\n\nclass Solution {\n public int findMaxK(int[] a | sharforaz_rahman | NORMAL | 2023-05-17T14:23:29.080544+00:00 | 2023-05-17T14:23:29.080583+00:00 | 1,097 | false | **PLEASE UPVOTE IF YOU LIKE IT**\n# Complexity\n- Time complexity:O(N)\n- Space complexity:O(N)\n\n# Code\n**JAVA**\n```\nclass Solution {\n public int findMaxK(int[] arr) {\n HashMap<Integer, Integer> map = new HashMap<>();\n int max = -1;\n for (int i : arr) {\n if (map.containsKey(... | 11 | 0 | ['Hash Table', 'C++', 'Java', 'JavaScript'] | 4 |
largest-positive-integer-that-exists-with-its-negative | ✅ [Python/Rust] fastest (100%) using two pointers, binary search (with detailed comments) | pythonrust-fastest-100-using-two-pointer-p4r2 | IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.\n\nPython. This solution employs sorting and a two-pointers approach. It demonstrated 127 ms runtime (100.00%) and use | stanislav-iablokov | NORMAL | 2022-10-16T04:02:09.448806+00:00 | 2022-10-23T12:37:11.982549+00:00 | 837 | false | **IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.**\n\n**Python.** This [**solution**](https://leetcode.com/submissions/detail/823480874/) employs sorting and a two-pointers approach. It demonstrated **127 ms runtime (100.00%)** and used **14.2 MB memory (33.33%)**. Time complexity is log-linear (due to sorting): **O(N\\*log... | 11 | 0 | ['Python', 'Rust'] | 3 |
largest-positive-integer-that-exists-with-its-negative | ✅✅✅ C++ using Vector || Very Simple and Easy to Understand Solution | c-using-vector-very-simple-and-easy-to-u-td94 | Up Vote if you like the solution\n\n/*\nSimply consider an array of size 1001, then keep on updating each nth index with value of n,\nWhile placing value of n | kreakEmp | NORMAL | 2022-10-16T04:00:29.350599+00:00 | 2022-10-16T04:30:42.120574+00:00 | 1,183 | false | <b>Up Vote if you like the solution\n```\n/*\nSimply consider an array of size 1001, then keep on updating each nth index with value of n,\nWhile placing value of n in array, keep on checking if it has already a number with opposite\nsign is present or not. if present then take it as ans if it greater then prev ans \n... | 10 | 3 | [] | 5 |
largest-positive-integer-that-exists-with-its-negative | 🔥 4 lines of simple code 3 approaches fully explained ✅|| Easy to understand👍 || Beat 96% users🚀 | 4-lines-of-simple-code-3-approaches-full-8976 | Intuition\n# Brute Force :\nPython3 []\nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n c=-1\n for i in nums:\n i=i* | siddharth-kiet | NORMAL | 2024-05-02T07:52:22.703098+00:00 | 2024-05-02T18:24:56.400582+00:00 | 1,503 | false | # Intuition\n# Brute Force :\n```Python3 []\nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n c=-1\n for i in nums:\n i=i*-1\n if i in set(nums) and i>c: c=i\n return c\n```\n```Python []\nclass Solution(object):\n def findMaxK(self, nums):\n """\... | 8 | 0 | ['Array', 'Hash Table', 'Two Pointers', 'Ordered Map', 'Sorting', 'Python', 'C++', 'Python3'] | 1 |
largest-positive-integer-that-exists-with-its-negative | Python3 || O(n) TIME AND SPACE || May 2 2024 Daily | python3-on-time-and-space-may-2-2024-dai-o222 | Intuition\nThe problem requires finding the largest positive integer k such that -k also exists in the given array nums. To solve this, we can use a set to effi | praneelpa | NORMAL | 2024-05-02T01:10:57.877822+00:00 | 2024-05-02T02:51:56.588581+00:00 | 799 | false | # Intuition\nThe problem requires finding the largest positive integer k such that -k also exists in the given array nums. To solve this, we can use a set to efficiently check for the existence of the negation of each number in the array.\n\n# Approach\nInitialize a variable ans to store the result and a set seen to st... | 7 | 0 | ['Array', 'Hash Table', 'Two Pointers', 'Sorting', 'Python3'] | 6 |
largest-positive-integer-that-exists-with-its-negative | Python | Easy Solution✅ | python-easy-solution-by-gmanayath-5v9u | Code\u2705\n\nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n pos, neg= set(), set()\n for digit in nums:\n pos.add( | gmanayath | NORMAL | 2023-02-02T04:30:17.378553+00:00 | 2023-02-02T04:30:17.378595+00:00 | 964 | false | # Code\u2705\n```\nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n pos, neg= set(), set()\n for digit in nums:\n pos.add(digit) if digit > 0 else neg.add(digit)\n \n for digit in sorted(pos,reverse = True):\n if (digit*-1) in neg:\n ... | 7 | 0 | ['Python', 'Python3'] | 4 |
largest-positive-integer-that-exists-with-its-negative | C++|| Simple Solution with small optimization || Beats 99.24% | c-simple-solution-with-small-optimizatio-bfif | \n\n# Approach\n Describe your approach to solving the problem. \nSort the array. \ntake two pointers i and j where i wil keep track of negative numbers and j w | prajnanam | NORMAL | 2024-05-02T03:15:45.854256+00:00 | 2024-05-02T05:03:57.184608+00:00 | 1,027 | false | \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nSort the array. \ntake two pointers i and j where i wil keep track of negative numbers and j will keep track of positive numbers.\nif(nums[i]+nums[j] < 0) that means abs(nums[i]) is > nums[j] so we move i pointer forward.\nif(nums[i]+nums[j] > 0) ... | 6 | 0 | ['Two Pointers', 'Sorting', 'C++'] | 1 |
largest-positive-integer-that-exists-with-its-negative | Java Easiest Solution | java-easiest-solution-by-janhvi__28-dmzc | \nclass Solution {\n public int findMaxK(int[] nums) {\n Arrays.sort(nums);\n for (int i = 0; i < nums.length; i++) {\n for (int j = | Janhvi__28 | NORMAL | 2022-10-18T16:20:33.619166+00:00 | 2022-10-18T16:20:33.619204+00:00 | 427 | false | ```\nclass Solution {\n public int findMaxK(int[] nums) {\n Arrays.sort(nums);\n for (int i = 0; i < nums.length; i++) {\n for (int j = nums.length-1; j>=0; j--) {\n if(nums[i]+nums[j]==0)return nums[j];\n }\n }\n return -1;\n }\n}\n``` | 6 | 0 | ['Java'] | 2 |
largest-positive-integer-that-exists-with-its-negative | Short JavaScript Solution Using a Set Object | short-javascript-solution-using-a-set-ob-6jzm | Found this solution helpful? Consider showing support by upvoting this post.\nHave a question? Kindly leave a comment below.\nThank you and happy hacking!\n\nco | sronin | NORMAL | 2022-10-16T18:32:59.105994+00:00 | 2022-10-17T12:09:49.740109+00:00 | 471 | false | Found this solution helpful? Consider showing support by upvoting this post.\nHave a question? Kindly leave a comment below.\nThank you and happy hacking!\n```\nconst findMaxK = (nums) => {\n let numsSet = new Set(nums)\n let largestInteger = -Infinity\n\n for (let num of numsSet) {\n if (num > 0 && num... | 6 | 0 | ['JavaScript'] | 1 |
largest-positive-integer-that-exists-with-its-negative | Java Two Solutions using sorting and hash Set | java-two-solutions-using-sorting-and-has-fm6g | Solution one, using sorting and hashset..\nFirst, the array is sorted in ascending order and all the elements of the array are stored in a hashset. Then the sor | Abhinav_0561 | NORMAL | 2022-10-16T08:15:18.175130+00:00 | 2022-10-16T08:26:32.874086+00:00 | 848 | false | Solution one, using sorting and hashset..\nFirst, the array is sorted in ascending order and all the elements of the array are stored in a hashset. Then the sorted array is traversed from the end to the 0 index and whenever we found an element whose negative is also present in the hash set, we return the ans. Else retu... | 6 | 0 | ['Sorting', 'Java'] | 3 |
largest-positive-integer-that-exists-with-its-negative | 5 line Code||Easy Understanding||Beginner level | 5-line-codeeasy-understandingbeginner-le-z1b4 | Please upvote to motivate me in my quest of documenting all leetcode solutions. HAPPY CODING:)\nAny suggestions and improvements are always welcome.\n___\n__\nQ | Anos | NORMAL | 2022-10-16T06:21:29.234286+00:00 | 2022-10-16T06:21:29.234320+00:00 | 521 | false | ***Please upvote to motivate me in my quest of documenting all leetcode solutions. HAPPY CODING:)\nAny suggestions and improvements are always welcome*.**\n___________________\n_________________\n***Q2441. Largest Positive Integer That Exists With Its Negative***\n_______________________________________________________... | 6 | 0 | ['Python'] | 2 |
largest-positive-integer-that-exists-with-its-negative | Python O(n) | python-on-by-diwakar_4-6koh | Complexity\n- Time complexity: O(nlog2n))\n- Space complexity: O(n)\n\n# Code\n\nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n d = { | diwakar_4 | NORMAL | 2022-10-16T04:09:57.386796+00:00 | 2022-10-16T04:41:46.772129+00:00 | 459 | false | # Complexity\n- Time complexity: O(nlog<sub>2</sub>n))\n- Space complexity: O(n)\n\n# Code\n```\nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n d = {}\n for i in nums:\n d[i] = d.get(i, 0)+1\n \n ans = -1\n for i in sorted(d.keys()):\n if i<0:... | 6 | 1 | ['Python3'] | 2 |
largest-positive-integer-that-exists-with-its-negative | 💯JAVA Solution Explained in HINDI (4 Approaches) | java-solution-explained-in-hindi-4-appro-kvwt | https://youtu.be/6fkCZNSwC6s\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F Also, please do upvote | The_elite | NORMAL | 2024-05-02T13:05:02.948628+00:00 | 2024-05-02T13:05:02.948654+00:00 | 869 | false | https://youtu.be/6fkCZNSwC6s\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F Also, please do upvote the solution if you liked it.\n\n# Subscribe link:- [ReelCoding](https://www.youtube.com/@reelcoding?sub_confirmation=1)\n\nSubscribe Goal:- 400\nCurrent Subscr... | 5 | 0 | ['Java'] | 0 |
largest-positive-integer-that-exists-with-its-negative | ✅ One Line Solution | one-line-solution-by-mikposp-xjys | (Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1\nTime complexity: O(n). Space complexi | MikPosp | NORMAL | 2024-05-02T08:16:33.992334+00:00 | 2024-05-02T08:16:33.992352+00:00 | 890 | false | (Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1\nTime complexity: $$O(n)$$. Space complexity: $$O(n)$$.\n```\nclass Solution:\n def findMaxK(self, a: List[int]) -> int:\n return max(filter(lambda v:-v in d,d:={*a}),default=-1)\n```\n\n#... | 5 | 0 | ['Array', 'Hash Table', 'Sorting', 'Python', 'Python3'] | 1 |
largest-positive-integer-that-exists-with-its-negative | 3 solutions | O(n^2), O(n logn) and O(n) | ✅ | 3-solutions-on2-on-logn-and-on-by-gurman-zoyt | \n---\n\n# BRUTEFORCE SOLUTION (O(N^2))\n\n---\n\n\n# Intuition\n Describe your first thoughts on how to solve this problem. \nA brute force approach involves c | gurmankd | NORMAL | 2024-05-02T04:40:38.678036+00:00 | 2024-05-02T04:42:24.543047+00:00 | 11 | false | \n---\n\n# BRUTEFORCE SOLUTION $$(O(N^2))$$\n\n---\n\n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nA brute force approach involves checking every pair of elements in the array to see if their absolute values are equal. This requires nested loops to compare each element with every ... | 5 | 0 | ['Two Pointers', 'Sorting', 'C++'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Python | Easy | python-easy-by-khosiyat-lqeu | see the Successfully Accepted Submission\n\n# Code\n\nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n # Initialize a set to store the | Khosiyat | NORMAL | 2024-05-02T04:36:53.014669+00:00 | 2024-05-02T04:36:53.014696+00:00 | 503 | false | [see the Successfully Accepted Submission](https://leetcode.com/problems/largest-positive-integer-that-exists-with-its-negative/submissions/1247084199/?envType=daily-question&envId=2024-05-02)\n\n# Code\n```\nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n # Initialize a set to store the absol... | 5 | 0 | ['Python3'] | 0 |
largest-positive-integer-that-exists-with-its-negative | 🗓️ Daily LeetCoding Challenge Day 134|| 🔥 JAVA SOL | daily-leetcoding-challenge-day-134-java-ejvra | Good morning!!\n# Code\n\nclass Solution {\n public int findMaxK(int[] nums) {\n int[] sum = new int[1001];\n int max = -1;\n for (int n | DoaaOsamaK | NORMAL | 2024-05-02T04:25:30.725738+00:00 | 2024-05-02T04:25:30.725761+00:00 | 249 | false | Good morning!!\n# Code\n```\nclass Solution {\n public int findMaxK(int[] nums) {\n int[] sum = new int[1001];\n int max = -1;\n for (int n : nums) {\n int index = n > 0 ? n : -n;\n if (sum[index] != n) {\n sum[index] += n;\n }\n \n ... | 5 | 0 | ['Java'] | 2 |
largest-positive-integer-that-exists-with-its-negative | C# Concise with Linq | c-concise-with-linq-by-ilya-a-f-vv34 | csharp\npublic class Solution\n{\n public int FindMaxK(int[] nums) => nums\n .Where(int.IsNegative)\n .Select(int.Abs)\n .Intersect(nums | ilya-a-f | NORMAL | 2024-05-02T01:02:37.688457+00:00 | 2024-05-02T01:02:37.688475+00:00 | 177 | false | ```csharp\npublic class Solution\n{\n public int FindMaxK(int[] nums) => nums\n .Where(int.IsNegative)\n .Select(int.Abs)\n .Intersect(nums.Where(int.IsPositive))\n .DefaultIfEmpty(-1)\n .Max();\n}\n``` | 5 | 0 | ['Hash Table', 'C#'] | 1 |
largest-positive-integer-that-exists-with-its-negative | Beats 98% || you wouldn't have thought of this I BET!! | beats-98-you-wouldnt-have-thought-of-thi-7kk6 | Intuition\n Describe your first thoughts on how to solve this problem. \n# HEY GUYS WRITING THIS POST TAKES LOT OF EFFORTS , AN UPVOTE WOULD CHEER ME UP FRIEND. | Abhishekkant135 | NORMAL | 2024-05-02T13:20:24.461327+00:00 | 2024-05-02T13:20:24.461358+00:00 | 257 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n# HEY GUYS WRITING THIS POST TAKES LOT OF EFFORTS , AN UPVOTE WOULD CHEER ME UP FRIEND. ALSO GET MY LINKEDIN IN COMMENTS.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n\n1. **Initializing Variables:**\n - `int[... | 4 | 0 | ['Array', 'Java'] | 1 |
largest-positive-integer-that-exists-with-its-negative | Hash table solution | hash-table-solution-by-drgavrikov-0znd | Approach\n Describe your approach to solving the problem. \nThe idea is to use a hash table for constant-time element lookup. We iterate through the array, and | drgavrikov | NORMAL | 2024-05-02T08:05:50.549850+00:00 | 2024-06-02T07:52:10.455791+00:00 | 20 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\nThe idea is to use a hash table for constant-time element lookup. We iterate through the array, and if there exists a negative counterpart $-num$ for the current element $num$ in the hash table, we update the answer.\n\nThis approach provides fast loo... | 4 | 0 | ['Hash Table', 'Memoization', 'C++'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Go solution. Beats 96% | go-solution-beats-96-by-upikoth-4kim | Code\n\nfunc findMaxK(nums []int) int {\n alreadySeenNums := map[int]bool{}\n res := -1\n\n for _, num := range nums {\n numAbs := int(math.Abs( | upikoth | NORMAL | 2024-05-02T07:24:17.840759+00:00 | 2024-05-02T07:24:17.840782+00:00 | 279 | false | # Code\n```\nfunc findMaxK(nums []int) int {\n alreadySeenNums := map[int]bool{}\n res := -1\n\n for _, num := range nums {\n numAbs := int(math.Abs(float64(num)))\n\n if numAbs < res {\n continue\n }\n\n if alreadySeenNums[-num] {\n res = numAbs\n } els... | 4 | 0 | ['Go'] | 0 |
largest-positive-integer-that-exists-with-its-negative | 💯Faster✅💯 | |unordered set||sorting|| 🔥Python🐍Java☕C++😎 | faster-unordered-setsorting-pythonjavac-ercgs | Intuition\n Describe your first thoughts on how to solve this problem. \nSeeking Negatives: Since we\'re looking for pairs of positive and negative integers in | sujalgupta09 | NORMAL | 2024-05-02T04:45:18.767020+00:00 | 2024-05-02T04:45:18.767049+00:00 | 1,070 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSeeking Negatives: Since we\'re looking for pairs of positive and negative integers in the array, one way to approach this problem is to iterate through the array and for each positive number, check if its negative counterpart exists in t... | 4 | 0 | ['Array', 'Two Pointers', 'Sorting', 'Ordered Set', 'Python', 'C++', 'Java'] | 3 |
largest-positive-integer-that-exists-with-its-negative | Easy | Multiset | Short and Efficient code | easy-multiset-short-and-efficient-code-b-kwv7 | \n\n# Code\n\nclass Solution {\npublic:\n // use of set\n int findMaxK(vector<int>& nums) {\n multiset<int> st;\n for(auto it : nums)\n | YASH_SHARMA_ | NORMAL | 2024-05-02T04:02:23.734221+00:00 | 2024-05-02T04:02:23.734252+00:00 | 119 | false | \n\n# Code\n```\nclass Solution {\npublic:\n // use of set\n int findMaxK(vector<int>& nums) {\n multiset<int> st;\n for(auto it : nums)\n {\n st.insert(it);\n }\n\n int ans = -1;\n for(auto it : nums)\n {\n if(it > 0)\n {\n ... | 4 | 0 | ['Array', 'Ordered Set', 'C++'] | 0 |
largest-positive-integer-that-exists-with-its-negative | 100% Faster || 3 Approaches || Easy to Understand || Short & Concise | 100-faster-3-approaches-easy-to-understa-kg63 | Intuition\nWe need to find the largest positive integer k such that its negative counterpart -k exists in the given array. To achieve this, we can iterate throu | gameboey | NORMAL | 2024-05-02T00:42:33.531377+00:00 | 2024-05-02T00:51:17.153481+00:00 | 37 | false | # Intuition\nWe need to find the largest positive integer k such that its negative counterpart -k exists in the given array. To achieve this, we can iterate through the array and keep track of the largest positive integer k encountered so far for which -k also exists in the array.\n\n# Approach: Brute Force\nLet\'s div... | 4 | 0 | ['Array', 'Hash Table', 'Two Pointers', 'C++', 'Java', 'Python3', 'JavaScript'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Java Easy Solution Using Two Pointers [ 88.55% ] [ 4ms ] | java-easy-solution-using-two-pointers-88-m5lh | Approach\n1. Sort the input array nums in non-decreasing order.\n2. Initialize two pointers, st at the beginning of the array and lt at the end of the array.\n3 | RajarshiMitra | NORMAL | 2024-04-16T06:55:30.040742+00:00 | 2024-06-16T08:32:26.920979+00:00 | 19 | false | # Approach\n1. Sort the input array `nums` in non-decreasing order.\n2. Initialize two pointers, `st` at the beginning of the array and `lt` at the end of the array.\n3. Iterate over the array while `st` is less than or equal to `lt`.\n4. In each iteration:\n - Check if the sum of the elements at `st` and `lt` is gre... | 4 | 0 | ['Java'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Java|2 pointer | Easiest solution | java2-pointer-easiest-solution-by-abhish-v0b2 | \nclass Solution {\n public int findMaxK(int[] nums) {\n Arrays.sort(nums);\n for (int i = 0; i < nums.length; i++) {\n for (int j = | abhishekalimchandani69 | NORMAL | 2022-10-18T12:17:44.505548+00:00 | 2022-10-18T12:17:44.505579+00:00 | 530 | false | ```\nclass Solution {\n public int findMaxK(int[] nums) {\n Arrays.sort(nums);\n for (int i = 0; i < nums.length; i++) {\n for (int j = nums.length-1; j>=0; j--) {\n if(nums[i]+nums[j]==0)return nums[j];\n }\n }\n return -1;\n }\n}\n``` | 4 | 0 | ['Two Pointers', 'Java'] | 3 |
largest-positive-integer-that-exists-with-its-negative | C++ | 2 Pointers | Easy | c-2-pointers-easy-by-shreyanshxyz-56ac | \nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n sort(nums.begin(), nums.end());\n \n int l = 0;\n int r = nums. | shreyanshxyz | NORMAL | 2022-10-16T08:17:17.927147+00:00 | 2022-10-16T08:17:17.927216+00:00 | 184 | false | ```\nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n sort(nums.begin(), nums.end());\n \n int l = 0;\n int r = nums.size() - 1;\n \n while(l < r){\n if(nums[l]*-1 == nums[r]){\n return nums[r];\n } else if (nums[l]*-1 < nu... | 4 | 0 | ['Two Pointers', 'C'] | 1 |
largest-positive-integer-that-exists-with-its-negative | 2 pointers | 2-pointers-by-flexsloth-mxo6 | \nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n \n sort(nums.begin() , nums.end());\n int i = 0 , j = nums.size()-1;\n | flexsloth | NORMAL | 2022-10-16T04:06:08.489565+00:00 | 2024-01-21T18:54:29.512865+00:00 | 976 | false | ```\nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n \n sort(nums.begin() , nums.end());\n int i = 0 , j = nums.size()-1;\n for(int k = 0 ; k < nums.size() ; k++){\n if(-nums[i] == nums[j]) return nums[j];\n else if(-nums[i] > nums[j]) i++;\n ... | 4 | 0 | ['C++'] | 2 |
largest-positive-integer-that-exists-with-its-negative | 💯Faster🔥Lesser✅🧠Detailed Approach🎯Two Pointer🔥Python🐍 | fasterlesserdetailed-approachtwo-pointer-0mn2 | Intuition\n Describe your first thoughts on how to solve this problem. \nfor pairing the negative and positive pairs used the logic\n>sum of x and -x is zero\n# | MerinMathew19 | NORMAL | 2024-05-02T13:05:41.663247+00:00 | 2024-05-02T13:15:57.796682+00:00 | 42 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n**for pairing the negative and positive pairs used the logic**\n>sum of x and -x is zero\n# Approach\n<!-- Describe your approach to solving the problem. -->\n**1) Sorted the array first**\nExample:\n>nums = [-10,8,6,7,3,-2,-3]\... | 3 | 0 | ['Python3'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Swift solution | swift-solution-by-azm819-eg4q | Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n# Co | azm819 | NORMAL | 2024-05-02T06:41:34.901573+00:00 | 2024-05-02T06:41:34.901599+00:00 | 27 | false | # Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n func findMaxK(_ nums: [Int]) -> Int {\n var numSet = Set<Int>()\n var result = -1\n... | 3 | 0 | ['Array', 'Hash Table', 'Swift'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Two pointer Approach | No extra space | two-pointer-approach-no-extra-space-by-a-hhl9 | Approach\n- Sort input array so that all negatives are in begin and positives are in end\n- Keep two pointers one for positive and one for negative integers\n- | anupsingh556 | NORMAL | 2024-05-02T05:19:48.152014+00:00 | 2024-05-02T05:19:48.152045+00:00 | 5 | false | # Approach\n- Sort input array so that all negatives are in begin and positives are in end\n- Keep two pointers one for positive and one for negative integers\n- Move the pointer af number with absolute larger value to next one if they are equal return the value \n\n# Complexity\n- Time complexity:\nO(nlogn)\n- Space c... | 3 | 0 | ['C++'] | 0 |
largest-positive-integer-that-exists-with-its-negative | C# Solution for Largest Positive Integer That Exists With Its Negative Problem | c-solution-for-largest-positive-integer-z5ua1 | Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition behind this C# solution is to utilize two pointers starting from both end | Aman_Raj_Sinha | NORMAL | 2024-05-02T04:54:46.257469+00:00 | 2024-05-02T04:54:46.257494+00:00 | 133 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition behind this C# solution is to utilize two pointers starting from both ends of the sorted array, moving towards each other to efficiently find pairs of numbers that sum up to zero.\n\n# Approach\n<!-- Describe your approach t... | 3 | 0 | ['C#'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Maximum Absolute Value Pair in Sorted Array: Two Pointer Approach | maximum-absolute-value-pair-in-sorted-ar-9c7c | Intuition\n The problem likely involves finding some maximum value or satisfying certain conditions within an array. The use of sorting and two pointers suggest | samarp_1001 | NORMAL | 2024-05-02T04:53:05.849352+00:00 | 2024-05-02T04:53:05.849397+00:00 | 249 | false | # Intuition\n The problem likely involves finding some maximum value or satisfying certain conditions within an array. The use of sorting and two pointers suggests there\'s a strategy involving comparing elements from both ends of the array.\n\n# Approach\nOne potential approach is to sort the array and then use two po... | 3 | 0 | ['Two Pointers', 'Sorting', 'C++'] | 1 |
largest-positive-integer-that-exists-with-its-negative | Beats 99.07% Time⌛ 98.70% Memory 💾🔥🔥 | Python, C++ 💻 | Clear Explanation📗 | beats-9907-time-9870-memory-python-c-cle-toeu | Beats 99.07% Time\u231B 98.70% Memory \uD83D\uDCBE\uD83D\uDD25\uD83D\uDD25 | Python, C++ \uD83D\uDCBB | Clear Explanation\uD83D\uDCD7\n## 1. Proof\n Describe yo | kcp_1410 | NORMAL | 2024-05-02T04:02:23.840951+00:00 | 2024-05-02T06:30:30.736973+00:00 | 103 | false | # Beats 99.07% Time\u231B 98.70% Memory \uD83D\uDCBE\uD83D\uDD25\uD83D\uDD25 | Python, C++ \uD83D\uDCBB | Clear Explanation\uD83D\uDCD7\n## 1. Proof\n<!-- Describe your first thoughts on how to solve this problem. -->\n### 1.1. Python3\n {\n result = -1\n\n for (let i = 0; i < nums.length; i++) {\n if (nums.indexOf(-nums[i], i+1) > 0) \n | Nbekweb | NORMAL | 2024-05-02T03:07:30.901639+00:00 | 2024-05-02T03:07:30.901662+00:00 | 593 | false | \n\n# Code\n```\nvar findMaxK = function(nums) {\n result = -1\n\n for (let i = 0; i < nums.length; i++) {\n if (nums.indexOf(-nums[i], i+1) > 0) \n if (Math.abs(nums[i]) > result) result = Math.abs(nums[i]) \n }\n\n return result\n};\n``` | 3 | 0 | ['JavaScript'] | 2 |
largest-positive-integer-that-exists-with-its-negative | C++ One Pass Liner Solution | Beats 💯✅ | c-one-pass-liner-solution-beats-by-shobh-kw1d | Intuition\n Describe your first thoughts on how to solve this problem. \nTo efficiently solve this problem, we employ a strategy that utilizes a vector seen to | shobhitkushwaha1406 | NORMAL | 2024-05-02T01:48:02.171200+00:00 | 2024-05-02T01:48:02.171222+00:00 | 11 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTo efficiently solve this problem, we employ a strategy that utilizes a vector seen to keep track of encountered numbers. Initializing seen with a size of 1001, we anticipate integers ranging from 0 to 1000 inclusively within nums.\n# App... | 3 | 0 | ['Bit Manipulation', 'C++'] | 0 |
largest-positive-integer-that-exists-with-its-negative | C++ Simple Solution Using set and Priority_queue | c-simple-solution-using-set-and-priority-ynvt | Intuition\n Describe your first thoughts on how to solve this problem. \nIntuition for that problem is that find all unique element present in the array ,Now we | skill_improve | NORMAL | 2024-05-02T01:10:46.107929+00:00 | 2024-05-02T01:10:46.107947+00:00 | 143 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIntuition for that problem is that find all unique element present in the array ,Now we want greatest element of which its negation exist then put all the positive element in the priority-queue and simply iterating the pq and checking .\... | 3 | 0 | ['Array', 'Hash Table', 'Two Pointers', 'Sorting', 'C++'] | 1 |
largest-positive-integer-that-exists-with-its-negative | Two Pointer_Very simple_Python_C++ | two-pointer_very-simple_python_c-by-saqu-1704 | Intuition\n\npython []\nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n nums.sort()\n l, r = 0, len(nums)-1\n \n | Saquif_Sohol | NORMAL | 2024-05-02T01:05:34.599281+00:00 | 2024-05-02T01:05:34.599312+00:00 | 783 | false | # Intuition\n\n```python []\nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n nums.sort()\n l, r = 0, len(nums)-1\n \n while(nums[l]<0 and l<r):\n if nums[l]*(-1) == nums[r]:\n return nums[r]\n if nums[l]*(-1) > nums[r]:\n ... | 3 | 0 | ['Two Pointers', 'C++', 'Python3'] | 6 |
largest-positive-integer-that-exists-with-its-negative | Easy Java Solution || Beginner Friendly | easy-java-solution-beginner-friendly-by-9f1t4 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | anikets101 | NORMAL | 2024-04-22T02:21:21.603581+00:00 | 2024-04-22T02:21:21.603613+00:00 | 188 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 3 | 0 | ['Java'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Beats 100% of users with C++|| Using Map and Two Pointer || Faster Solution || Easy to Understand || | beats-100-of-users-with-c-using-map-and-qujx0 | Abhiraj Pratap Singh\n\n---\n\n# if you like the approach please upvote it\n\n---\n\n# Intuition\n- The problem appears to involve finding the maximum value k s | abhirajpratapsingh | NORMAL | 2023-12-20T19:31:08.017180+00:00 | 2024-05-02T17:06:16.044091+00:00 | 87 | false | # Abhiraj Pratap Singh\n\n---\n\n# if you like the approach please upvote it\n\n---\n\n# Intuition\n- The problem appears to involve finding the maximum value k such that both k and -k exist in the given vector.\n\n---\n\n\n\n- Space complexity:\nO(n)\n\n# Code\n```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar findMaxK = function... | 3 | 0 | ['JavaScript'] | 1 |
largest-positive-integer-that-exists-with-its-negative | 100% - O(N) - O(1) Java✅ | 100-on-o1-java-by-omjethva24-2x2s | Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# Co | omjethva24 | NORMAL | 2023-11-16T07:47:21.817753+00:00 | 2023-11-16T07:47:21.817781+00:00 | 121 | false | # Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int findMaxK(int[] nums) {\n int[] freq = new int[1001];\n\n for(int num : nums){\n ... | 3 | 0 | ['Java'] | 2 |
largest-positive-integer-that-exists-with-its-negative | Beginner-friendly || Simple solution with HashMap | beginner-friendly-simple-solution-with-h-f455 | Intuition\nLet\'s briefly explain, what problem is:\n- there\'s a list of nums\n- our goal is to find the maximum, that has a negative integer of himself (i.e., | subscriber6436 | NORMAL | 2023-10-25T21:07:13.358601+00:00 | 2023-10-25T21:08:31.385017+00:00 | 221 | false | # Intuition\nLet\'s briefly explain, what problem is:\n- there\'s a list of `nums`\n- our goal is to find **the maximum**, that has a **negative integer of himself** (i.e., 2 and -2 etc)\n\nThe approach is **straighforward**: iterate over `nums` and at each step check, if a particular integer is **a maximum one**, and ... | 3 | 0 | ['Array', 'Hash Table', 'TypeScript', 'Python3'] | 1 |
largest-positive-integer-that-exists-with-its-negative | Python3: solution beats 99.89% | python3-solution-beats-9989-by-resilient-9gqf | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | ResilientWarrior | NORMAL | 2023-08-27T13:18:34.392179+00:00 | 2023-08-27T13:18:34.392208+00:00 | 6 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 3 | 0 | ['Python3'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Easy to understand C++ Solution using set SC:O(n) ✅✅ | easy-to-understand-c-solution-using-set-z5b4q | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nI used the set to store the numbers in sorted order.\n\n# Complexity\n- T | om_limbhare | NORMAL | 2023-01-20T16:39:55.882652+00:00 | 2023-02-17T09:02:19.222324+00:00 | 338 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nI used the set to store the numbers in sorted order.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ ... | 3 | 0 | ['Array', 'C++'] | 3 |
largest-positive-integer-that-exists-with-its-negative | python, sort(), double pointers | python-sort-double-pointers-by-nov05-bmwg | ERROR: type should be string, got "https://leetcode.com/submissions/detail/854012683/\\n\\nRuntime: 126 ms, faster than 98.12% of Python3 online submissions for Largest Positive Integer That Exists" | nov05 | NORMAL | 2022-12-03T18:05:42.768024+00:00 | 2022-12-03T18:11:50.777103+00:00 | 373 | false | ERROR: type should be string, got "https://leetcode.com/submissions/detail/854012683/\\n```\\nRuntime: 126 ms, faster than 98.12% of Python3 online submissions for Largest Positive Integer That Exists With Its Negative.\\nMemory Usage: 14.1 MB, less than 90.76% of Python3 online submissions for Largest Positive Integer That Exists With Its Negative.\\n```\\n```\\nclass Solution:\\n def findMaxK(self, nums: List[int]) -> int:\\n nums.sort()\\n l = len(nums)\\n i, j = 0, l-1\\n while i<l and j>=0:\\n if -nums[i]==nums[j]:\\n return nums[j]\\n elif -nums[i]<nums[j]:\\n j-=1\\n else:\\n i+=1\\n return -1\\n```" | 3 | 0 | ['Sorting', 'Python'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Simple C++ solution | O(n) |2 pointer simple approach | simple-c-solution-on-2-pointer-simple-ap-rg11 | ```\nclass Solution {\npublic:\n int findMaxK(vector& nums) {\n sort(nums.begin(),nums.end());\n int s=0,e=nums.size()-1;\n while(s<e){\ | mohiteravi348 | NORMAL | 2022-11-27T18:37:14.767847+00:00 | 2022-11-27T18:37:14.767978+00:00 | 73 | false | ```\nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int s=0,e=nums.size()-1;\n while(s<e){\n if(nums[s]+nums[e]==0)\n return nums[e];\n else if(nums[s]+nums[e]<0)s++;\n else\n e--;\n ... | 3 | 0 | ['C'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Easy Python Solution | easy-python-solution-by-vistrit-0d1x | Code\n\nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n nums.sort()\n for i in nums[::-1]:\n if -i in nums:\n | vistrit | NORMAL | 2022-11-03T15:42:43.959770+00:00 | 2022-11-03T15:42:43.959809+00:00 | 683 | false | # Code\n```\nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n nums.sort()\n for i in nums[::-1]:\n if -i in nums:\n return i\n return -1\n``` | 3 | 0 | ['Python', 'Python3'] | 3 |
largest-positive-integer-that-exists-with-its-negative | [JAVA] easiest two pointer solution | java-easiest-two-pointer-solution-by-jug-bgeh | \n\n# Code\n\nclass Solution {\n public int findMaxK(int[] nums) {\n Arrays.sort(nums);\n for(int i = 0; i < nums.length; i ++) {\n for(in | Jugantar2020 | NORMAL | 2022-10-24T16:48:31.082466+00:00 | 2022-10-24T16:48:31.082511+00:00 | 254 | false | \n\n# Code\n```\nclass Solution {\n public int findMaxK(int[] nums) {\n Arrays.sort(nums);\n for(int i = 0; i < nums.length; i ++) {\n for(int j = nums.length - 1; j > 0; j --) \n if(nums[i] + nums[j] == 0) return nums[j];\n } \n return - 1;\n }\n}\n```\n# PLEASE UPVOTE IF I... | 3 | 0 | ['Java'] | 3 |
largest-positive-integer-that-exists-with-its-negative | Two sum||C++||Java ||4 lines solution||Sorting | two-sumcjava-4-lines-solutionsorting-by-1p4hm | \n\n# Code\nJAVA solution \n\nclass Solution {\n public int findMaxK(int[] nums) {\n Arrays.sort(nums);\n for(int i=0;i<nums.length;i++)\n | Kashif_Rahman | NORMAL | 2022-10-18T20:26:06.755605+00:00 | 2022-10-18T20:26:06.755644+00:00 | 151 | false | \n\n# Code\nJAVA solution \n```\nclass Solution {\n public int findMaxK(int[] nums) {\n Arrays.sort(nums);\n for(int i=0;i<nums.length;i++)\n for(int j=nums.length-1;j>=0;j--)\n if(nums[i]+nums[j]==0) return nums[j];\n return -1;\n }\n}\n```\nC++ solution \n```\ncla... | 3 | 0 | ['Sorting', 'C++', 'Java'] | 1 |
largest-positive-integer-that-exists-with-its-negative | Java | hashset | easy to understand | java-hashset-easy-to-understand-by-conch-vyob | \n //Runtime: 5 ms, faster than 100.00% of Java online submissions for Largest Positive Integer That Exists With Its Negative.\n //Memory Usage: 42.5 MB, | conchwu | NORMAL | 2022-10-16T05:54:26.321099+00:00 | 2022-10-16T06:07:15.062284+00:00 | 453 | false | ```\n //Runtime: 5 ms, faster than 100.00% of Java online submissions for Largest Positive Integer That Exists With Its Negative.\n //Memory Usage: 42.5 MB, less than 60.00% of Java online submissions for Largest Positive Integer That Exists With Its Negative.\n\t//Time: O(N); Space: O(N)\n public int findMaxK... | 3 | 0 | ['Ordered Set', 'Java'] | 2 |
largest-positive-integer-that-exists-with-its-negative | Binary Search O(NlogN) Solution | binary-search-onlogn-solution-by-travanj-vkin | cpp\nclass Solution {\npublic:\n int findMaxK(vector<int> &nums) {\n int n = nums.size();\n sort(nums.begin(), nums.end());\n for (int i | travanj05 | NORMAL | 2022-10-16T04:44:04.151173+00:00 | 2022-10-16T04:44:04.151196+00:00 | 108 | false | ```cpp\nclass Solution {\npublic:\n int findMaxK(vector<int> &nums) {\n int n = nums.size();\n sort(nums.begin(), nums.end());\n for (int i = n - 1; i >= 0; i--) {\n if (nums[i] < 0) return -1;\n if (binary_search(nums.begin(), nums.end(), -nums[i])) {\n retu... | 3 | 0 | ['C', 'Binary Tree', 'C++'] | 1 |
largest-positive-integer-that-exists-with-its-negative | ✅C++||✅Intuitive HashMap ||✅Short Code | cintuitive-hashmap-short-code-by-bhushan-tkwk | \nint findMaxK(vector<int>& nums) {\n \n map<int,int> mp ;\n for( auto it : nums ) mp[it]++;\n \n int ans = INT_MIN ;\n | Bhushan_Mahajan | NORMAL | 2022-10-16T04:06:18.218289+00:00 | 2022-10-16T04:06:45.355175+00:00 | 1,874 | false | ```\nint findMaxK(vector<int>& nums) {\n \n map<int,int> mp ;\n for( auto it : nums ) mp[it]++;\n \n int ans = INT_MIN ;\n bool gotAnsr = false ;\n \n for( int i=0 ; i<nums.size() ; i++ ){\n \n if( nums[i] > 0 ) {\n if( mp.find... | 3 | 0 | [] | 1 |
largest-positive-integer-that-exists-with-its-negative | C++ Array | c-array-by-theomkumar-vwew | Bruteforce Approach \n\n int findMaxK(vector<int>& nums) {\n int maxi = -1;\n for (int i = 0; i < nums.size(); i++)\n {\n for (i | theomkumar | NORMAL | 2022-10-16T04:04:51.296446+00:00 | 2022-10-16T04:18:33.480770+00:00 | 295 | false | Bruteforce Approach \n```\n int findMaxK(vector<int>& nums) {\n int maxi = -1;\n for (int i = 0; i < nums.size(); i++)\n {\n for (int j = 0; j < nums.size(); j++)\n {\n if (nums[i] == nums[j]*-1)\n maxi = max(nums[i], maxi);\n }\n ... | 3 | 0 | ['C', 'C++'] | 1 |
largest-positive-integer-that-exists-with-its-negative | ✅C++|| Simple Brute Force|| Easy Solution | c-simple-brute-force-easy-solution-by-in-i47b | \nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int n = nums.size();\n int sum = 0;\n | indresh149 | NORMAL | 2022-10-16T04:03:32.024219+00:00 | 2022-10-16T04:03:32.024245+00:00 | 456 | false | ```\nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int n = nums.size();\n int sum = 0;\n int maxi = -1;\n for(int i=0;i<n;i++){\n int a = nums[i]; \n for(int j=i+1;j<n;j++){\n if(a+nums[... | 3 | 0 | ['C'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Easy to Understand | C++ | easy-to-understand-c-by-s1ddharth-53aa | \nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n map<int, set<int>> mp;\n for(auto &it: nums) {\n mp[abs(it)].inser | s1ddharth | NORMAL | 2022-10-16T04:03:20.489699+00:00 | 2022-10-16T04:03:20.489747+00:00 | 1,730 | false | ```\nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n map<int, set<int>> mp;\n for(auto &it: nums) {\n mp[abs(it)].insert(it);\n }\n int maxi = INT_MIN;\n \n for(auto &it: mp) {\n if(it.second.size() == 2) {\n maxi = max(it... | 3 | 0 | ['C'] | 1 |
largest-positive-integer-that-exists-with-its-negative | simplest two pointer, explained | simplest-two-pointer-explained-by-pitche-mtkm | Intuitionwe need to find the sum of a negative number and a positive number to be 0we sort our array, initialize left as zero and right as final indexwe basical | pitcherpunchst | NORMAL | 2024-12-20T13:09:37.015698+00:00 | 2024-12-20T13:09:37.015698+00:00 | 54 | false | # Intuition
we need to find the sum of a negative number and a positive number to be 0
we sort our array, initialize left as zero and right as final index
we basically divide the array into negative and positive half,
left pointer starts from the most negative element to the least negative
right pointer starts from ... | 2 | 0 | ['C++'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Easy Solution using C++ for Beginners using For Loop | easy-solution-using-c-for-beginners-usin-f1tp | Intuition\nReturn the value if the maximum positive element has its negative value in the array\n Describe your first thoughts on how to solve this problem. \n\ | Viggu_Vignesh | NORMAL | 2024-09-24T08:13:56.764090+00:00 | 2024-09-24T08:13:56.764109+00:00 | 3 | false | # Intuition\nReturn the value if the maximum positive element has its negative value in the array\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n# Sort the array\n\n**Use 2 for loops**\n\n- 1st loop iterates from first element to last(small to big)\n\n- 2nd loop iterates from last e... | 2 | 0 | ['C++'] | 0 |
largest-positive-integer-that-exists-with-its-negative | use toSet() | use-toset-by-linhna3-g13s | \n# Code\n\nclass Solution {\n fun findMaxK(nums: IntArray): Int {\n val numsSet = nums.toSet()\n var result = -1\n for (num in nums) {\n if | LinhNA3 | NORMAL | 2024-05-03T10:57:25.561098+00:00 | 2024-05-03T10:57:25.561149+00:00 | 4 | false | \n# Code\n```\nclass Solution {\n fun findMaxK(nums: IntArray): Int {\n val numsSet = nums.toSet()\n var result = -1\n for (num in nums) {\n if (-num in numsSet && num > result) {\n result = num\n }\n }\n return result\n }\n}\n``` | 2 | 0 | ['Kotlin'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Simple Solution (Faster 100% Runtime) ✅ | simple-solution-faster-100-runtime-by-pr-xh6l | \n# Approach\n- Reduce the entire inputArray into unique elements using Sets\n- Split the elements into two subarrays; positiveNums and negativeNums (absolutive | ProbablyLost | NORMAL | 2024-05-02T13:26:02.486450+00:00 | 2024-05-02T14:13:19.589152+00:00 | 67 | false | \n# Approach\n- Reduce the entire inputArray into unique elements using `Sets`\n- Split the elements into two **subarrays**; `positiveNums` and `negativeNums` (absolutive value)\n- Get the largest **intersection** (common element) between the two subarrays, if none exists, return `-1`\n\n# Code\n```\nclass Solution {\n... | 2 | 0 | ['Array', 'Swift', 'Sorting'] | 0 |
largest-positive-integer-that-exists-with-its-negative | ✅Easiest Solution🔥||O(N)🔥||Beginner Friendly✅🔥 | easiest-solutiononbeginner-friendly-by-s-ctut | Intuition\n\n - The code uses a HashSet named hs to store unique values from the input array nums. This ensures that we only consider each value once, avoidin | siddhesh11p | NORMAL | 2024-05-02T13:16:48.490333+00:00 | 2024-05-02T13:16:48.490385+00:00 | 49 | false | # Intuition\n\n - The code uses a `HashSet` named `hs` to store unique values from the input array `nums`. This ensures that we only consider each value once, avoiding duplicate checks.\n - It then iterates through each value `valu` in the `HashSet`.\n - For each `valu`, it checks if its negation `-valu` exists i... | 2 | 0 | ['Array', 'Hash Table', 'Two Pointers', 'Sorting', 'Java'] | 2 |
largest-positive-integer-that-exists-with-its-negative | This solution is even more straight then you. | this-solution-is-even-more-straight-then-yad3 | Intuition\n Describe your first thoughts on how to solve this problem. \nHEY GUYS PLS UPVOTE PPL.\n# Approach\n Describe your approach to solving the problem. \ | Abhishekkant135 | NORMAL | 2024-05-02T12:48:32.823956+00:00 | 2024-05-02T12:48:32.823974+00:00 | 119 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nHEY GUYS PLS UPVOTE PPL.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n\n1. **Initializing Variables:**\n - `HashSet<Integer> hm = new HashSet<>()`: Creates a HashSet named `hm` to store the unique numbers enco... | 2 | 0 | ['Hash Table', 'Java'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Java Solution 🖥️ 4ms 💯Beats 91.11% 🏃🏼💨💨💨 | java-solution-4ms-beats-9111-by-purushar-vx1n | Intuition\n Describe your first thoughts on how to solve this problem. \nWe want to find the largest positive integer k such that -k also exists in the array.\n | purusharthcodeshere | NORMAL | 2024-05-02T10:23:01.493104+00:00 | 2024-05-02T11:34:22.066474+00:00 | 25 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe want to find the largest positive integer `k` such that `-k` also exists in the array.\nNow there are two ways two search for such an integer `k`:\n\n# **Brute Force Method:**\n \nBrute force method is usually the simplest approach tha... | 2 | 0 | ['Two Pointers', 'Sorting', 'Java'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Kotlin. Beats 100% (205 ms). Bit masks solution. | kotlin-beats-100-205-ms-bit-masks-soluti-fq5l | \n\n# Code\n\nclass Solution {\n fun findMaxK(nums: IntArray): Int {\n val counters = IntArray(1024)\n var max = -1\n for (n in nums) {\ | mobdev778 | NORMAL | 2024-05-02T06:39:09.979665+00:00 | 2024-05-02T06:45:08.287910+00:00 | 49 | false | \n\n# Code\n```\nclass Solution {\n fun findMaxK(nums: IntArray): Int {\n val counters = IntArray(1024)\n var max = -1\n for (n in nums) {\n val an = Math.abs(n)\n ... | 2 | 0 | ['Kotlin'] | 1 |
largest-positive-integer-that-exists-with-its-negative | ✅Simple Two Pointer Approach O(N/2) Solution ✅ | simple-two-pointer-approach-on2-solution-gbun | Intuition\nSum of the positive and negative of the same number is eaual to 0.\n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- | abhay0007 | NORMAL | 2024-05-02T06:02:56.550859+00:00 | 2024-05-02T06:02:56.550897+00:00 | 1 | false | # Intuition\nSum of the positive and negative of the same number is eaual to 0.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(N/2)\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n ... | 2 | 0 | ['Array', 'Two Pointers', 'Sorting', 'C++'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Beated 💯% | JAVA | 💪🏻🤟🏻 | beated-java-by-anubhavkumar19-owgb | Intuition\n Describe your first thoughts on how to solve this problem. \nWe can two pointer aproach to find the desired result.\n\n# Approach\n Describe your ap | anubhavkumar19 | NORMAL | 2024-05-02T05:24:15.875872+00:00 | 2024-05-02T05:24:15.875904+00:00 | 78 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe can two pointer aproach to find the desired result.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n> First, I\'ve sorted the **nums**. Then iterated through the **nums** using two pointers ***i*** and ***j***. ... | 2 | 0 | ['Java'] | 1 |
largest-positive-integer-that-exists-with-its-negative | Easy Approach ! | easy-approach-by-jasijasu959-kzy2 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | jasijasu959 | NORMAL | 2024-05-02T05:17:20.569263+00:00 | 2024-05-02T05:17:20.569297+00:00 | 25 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 2 | 0 | ['Dart'] | 0 |
largest-positive-integer-that-exists-with-its-negative | JS Easy One Line Solution | js-easy-one-line-solution-by-charnavoki-r8nm | \nvar findMaxK = nums => Math.max(...nums.filter(v => nums.includes(-v)), -1);\n | charnavoki | NORMAL | 2024-05-02T05:07:13.277674+00:00 | 2024-05-02T05:25:12.803153+00:00 | 21 | false | ```\nvar findMaxK = nums => Math.max(...nums.filter(v => nums.includes(-v)), -1);\n``` | 2 | 0 | ['JavaScript'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Solve without sort and in one linear loop | solve-without-sort-and-in-one-linear-loo-fz55 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nWe need to use a HashSet for storage and check each array element for the | raydensd | NORMAL | 2024-05-02T04:49:33.074356+00:00 | 2024-05-02T05:01:35.854542+00:00 | 104 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nWe need to use a HashSet for storage and check each array element for the opposite sign in the HashSet.\n\n# Complexity\n- Time complexity:\n $$O(n)$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```\npublic class Solution {\... | 2 | 0 | ['C#'] | 0 |
largest-positive-integer-that-exists-with-its-negative | best approach JS | best-approach-js-by-javad_pk-gbrv | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | javad_pk | NORMAL | 2024-05-02T04:35:13.269779+00:00 | 2024-05-02T04:35:13.269810+00:00 | 217 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 2 | 0 | ['JavaScript'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Single Pass Using Hash Set | Python | single-pass-using-hash-set-python-by-pra-0l9z | Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(n)\n\n# Code\n\nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n seen = se | pragya_2305 | NORMAL | 2024-05-02T03:52:23.260449+00:00 | 2024-05-02T03:52:23.260502+00:00 | 228 | false | # Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(n)\n\n# Code\n```\nclass Solution:\n def findMaxK(self, nums: List[int]) -> int:\n seen = set()\n ans = -float(\'inf\')\n\n for num in nums:\n if abs(num)>ans and -num in seen:\n ans = abs(num)\n ... | 2 | 0 | ['Array', 'Hash Table', 'Python', 'Python3'] | 1 |
largest-positive-integer-that-exists-with-its-negative | 🔥Beats 90% - No HashTable - O(1) Space | Clean Code | C++ | | beats-90-no-hashtable-o1-space-clean-cod-e98t | Code\n\nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n sort(nums.begin(), nums.end());\n \n int left = 0, right = nums. | Antim_Sankalp | NORMAL | 2024-05-02T03:42:26.808464+00:00 | 2024-05-02T03:42:26.808483+00:00 | 2 | false | # Code\n```\nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n sort(nums.begin(), nums.end());\n \n int left = 0, right = nums.size() - 1;\n while (left < right)\n {\n if (nums[left] == -nums[right])\n {\n return abs(nums[left]);\n... | 2 | 0 | ['C++'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Simple java one pass HashSet solution | simple-java-one-pass-hashset-solution-by-amyq | \n# Approach\n# Explanation of findMaxK Method\nThis method aims to find the maximum value k such that both k and -k exist in the given array nums. It returns k | rohitmalekar2117 | NORMAL | 2024-05-02T03:41:45.120246+00:00 | 2024-05-02T03:41:45.120276+00:00 | 210 | false | \n# Approach\n# Explanation of findMaxK Method\nThis method aims to find the maximum value k such that both k and -k exist in the given array nums. It returns k, or -1 if no such k exists.\n\n# Algorithm Overview\n1. Initialize a HashSet set to store encountered numbers and a variable maxNum to track the maximum value ... | 2 | 0 | ['Java'] | 2 |
largest-positive-integer-that-exists-with-its-negative | ✅Beats 96% |🔥O(n) time and space complexity 🔥|🔥 Easy, Fast and Efficient using HashSet🔥🔥1 pass | beats-96-on-time-and-space-complexity-ea-4lmw | Intuition\nTo find the largest positive integer k such that -k also exists in the array, we can make array into hashset and iterate through the hashset and chec | darshan_anghan | NORMAL | 2024-05-02T03:14:25.697646+00:00 | 2024-05-02T03:22:56.246100+00:00 | 12 | false | # Intuition\nTo find the largest positive integer k such that -k also exists in the array, we can make array into hashset and iterate through the hashset and check if the negative of each number exists in the hashset.\n\n# Approach\nUse HashMap \n\n# Complexity\n- Time complexity:\nO(n) time complexity and only one for... | 2 | 0 | ['Java'] | 1 |
largest-positive-integer-that-exists-with-its-negative | Java - using hashset | java-using-hashset-by-abhishekbalawan-fmjt | Store all the values in hashset.\n2. Iterate over all the numbers. For positive numbers, check if i\'ts negative counterpart exists. If so, check if it is large | abhishekbalawan | NORMAL | 2024-05-02T03:13:38.960880+00:00 | 2024-05-02T03:13:38.960911+00:00 | 22 | false | 1. Store all the values in hashset.\n2. Iterate over all the numbers. For positive numbers, check if i\'ts negative counterpart exists. If so, check if it is largest value encoutered so far and update the answer accordingly.\n# class Solution {\n public int findMaxK(int[] nums) {\n HashSet<Integer> set = new ... | 2 | 0 | [] | 0 |
largest-positive-integer-that-exists-with-its-negative | TWO POINTERS + SORT || Solution of largest positive integer that exists with its negative problem | two-pointers-sort-solution-of-largest-po-39ev | This was a daily challenge for May 2th 2024.\n\n# Approach\n- Given an integer array nums that does not contain any zeros, find the largest positive integer k s | tiwafuj | NORMAL | 2024-05-02T01:45:02.924181+00:00 | 2024-05-02T01:45:02.924232+00:00 | 31 | false | # This was a daily challenge for May 2th 2024.\n\n# Approach\n- Given an integer array nums that does not contain any zeros, find the largest positive integer `k` such that `-k` also exists in the array. Return the positive integer `k`. If there is no such integer, return `-1`.\n- We use two pointer technique for this ... | 2 | 0 | ['Array', 'Hash Table', 'Two Pointers', 'Sorting', 'Python3'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Easy Solution|| Two Pointer approach | easy-solution-two-pointer-approach-by-sr-d8m1 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | sraj94956 | NORMAL | 2024-05-02T01:24:47.930601+00:00 | 2024-05-02T01:24:47.930638+00:00 | 225 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g.... | 2 | 0 | ['C++'] | 0 |
largest-positive-integer-that-exists-with-its-negative | 🔥 🔥 🔥 Simple solution in Python 🔥 🔥 🔥 | simple-solution-in-python-by-bhanu_bhakt-thye | Intuition\n- Add all the existing nums in the set and search for the maxK which has -k and k.\n\n# Approach\n1. Add all the nums in the set.\n2. Assign maxNum a | bhanu_bhakta | NORMAL | 2024-05-02T00:57:28.716390+00:00 | 2024-05-02T00:57:28.716407+00:00 | 3 | false | # Intuition\n- Add all the existing nums in the set and search for the maxK which has -k and k.\n\n# Approach\n1. Add all the nums in the set.\n2. Assign maxNum as -1\n2. Iterate over the nums array and check if `-num` exists in the set, if so update the `maxNum` to: maxNum = max(maxNum, abs(num))\n3. Return the `maxNu... | 2 | 0 | ['Python3'] | 0 |
largest-positive-integer-that-exists-with-its-negative | 💯✅Runtime 5 ms Beats 84.11% of users with Java||💯✅Memory 44.88 MB Beats 43.00% of users with Java | runtime-5-ms-beats-8411-of-users-with-ja-jmgp | Intuition\n Describe your first thoughts on how to solve this problem. \n- The given code aims to find the maximum value of k in an array of integers such that | suyalneeraj09 | NORMAL | 2024-05-02T00:56:42.696708+00:00 | 2024-05-08T00:25:01.373238+00:00 | 255 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- The given code aims to find the maximum value of k in an array of integers such that both k and -k exist in the array.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- The findMaxK method first checks for edge cas... | 2 | 0 | ['Array', 'Java'] | 3 |
largest-positive-integer-that-exists-with-its-negative | ✅beats👊99% 💯Faster✅ Detailed Explanation | beats99-faster-detailed-explanation-by-d-rtzr | Intuition:\n# Given an array of integers, we need to find the maximum positive integer num such that its negation -num also exists in the array.\n# Approach:\n1 | Dhruv__parmar | NORMAL | 2024-05-02T00:24:20.935222+00:00 | 2024-05-02T00:24:20.935245+00:00 | 919 | false | # Intuition:\n# **Given an array of integers, we need to find the maximum positive integer num such that its negation -num also exists in the array.**\n# Approach:\n1. **Create a set s containing all elements of the input array nums.**\n2. **Initialize a variable pair to -1, which will store the maximum positive intege... | 2 | 0 | ['Array', 'Hash Table', 'Two Pointers', 'Sorting', 'C++', 'Java', 'Python3'] | 2 |
largest-positive-integer-that-exists-with-its-negative | O(n) Time, O(1) Space Solution | on-time-o1-space-solution-by-django42-2nsi | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Django42 | NORMAL | 2024-04-23T11:33:50.679246+00:00 | 2024-04-23T11:33:50.679282+00:00 | 19 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 2 | 0 | ['C#'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Two Pointer || Sorting || 93% T.C || 66% S.C || CPP | two-pointer-sorting-93-tc-66-sc-cpp-by-g-2wom | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Ganesh_ag10 | NORMAL | 2024-04-20T02:04:02.178113+00:00 | 2024-04-20T02:04:02.178149+00:00 | 168 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g.... | 2 | 0 | ['C++'] | 1 |
largest-positive-integer-that-exists-with-its-negative | Beginner friendly , 2 pointers , Sorting Approach | beginner-friendly-2-pointers-sorting-app-w3cg | Intuition\nMax value required , hence first sorted and for searching 2 pointers\n\n# Approach\nHere , it is required that if in case we have more than 1 number | salNegi404 | NORMAL | 2024-03-10T09:09:39.472171+00:00 | 2024-03-10T09:09:39.472203+00:00 | 99 | false | # Intuition\nMax value required , hence first sorted and for searching 2 pointers\n\n# Approach\nHere , it is required that if in case we have more than 1 number with +ve and -ve value we need to provide larger number.\n\nHence we first sorted the numbers. Then moving from end p2 (i.e larger value) we take its negative... | 2 | 0 | ['C++'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Simple easy cpp solution ✅✅ | simple-easy-cpp-solution-by-vaibhav2112-eh5p | \n\n# Complexity \n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \ | vaibhav2112 | NORMAL | 2023-08-30T09:18:06.898192+00:00 | 2023-08-30T09:18:06.898212+00:00 | 110 | false | \n\n# Complexity \n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n unordered_map<int,int> m;\n for(auto x: n... | 2 | 0 | ['C++'] | 0 |
largest-positive-integer-that-exists-with-its-negative | Easiest C++ Map Code | easiest-c-map-code-by-baibhavsingh07-516w | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | baibhavsingh07 | NORMAL | 2023-05-17T04:40:09.255213+00:00 | 2023-05-17T04:40:09.255246+00:00 | 171 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n)\n<!-- Add your space complexity here, e.g. $$O... | 2 | 0 | ['Array', 'Hash Table', 'C++'] | 1 |
largest-positive-integer-that-exists-with-its-negative | C++ Easy Solution | | 4 Line Solution | c-easy-solution-4-line-solution-by-rhyth-dk4i | \nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int ans=-1;\n for(int it : nums)\n {\n if(it>0 && count(num | rhythm_jain_ | NORMAL | 2023-04-10T19:55:38.519050+00:00 | 2023-04-10T19:55:38.519096+00:00 | 436 | false | ```\nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int ans=-1;\n for(int it : nums)\n {\n if(it>0 && count(nums.begin(),nums.end(),-it)) ans=max(ans,it);\n }\n return ans;\n }\n};\n``` | 2 | 0 | ['C', 'C++'] | 1 |
largest-positive-integer-that-exists-with-its-negative | Easiest 5 liner approach(please upvote if you like the solution) | easiest-5-liner-approachplease-upvote-if-0mbn | Code\n\nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int l=0, h=nums.size()-1;\n whi | Tushar_Seth | NORMAL | 2023-01-15T12:58:15.880787+00:00 | 2023-01-15T12:58:15.880839+00:00 | 30 | false | # Code\n```\nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int l=0, h=nums.size()-1;\n while(l < h)\n {\n if((nums[l] + nums[h]) == 0) return nums[h];\n else if((nums[l] + nums[h]) < 0) l++;\n else h--;\n... | 2 | 0 | ['C++'] | 0 |
find-nearest-point-that-has-the-same-x-or-y-coordinate | [Java/Python 3] Straight forward codes. | javapython-3-straight-forward-codes-by-r-leu3 | Q & A\nQ1: Why have you initialized index with -1 and not 0?\n\nA1: Make the code more general. e.g., If no point has the same x or y coordinate, then we can st | rock | NORMAL | 2021-03-06T16:11:49.455991+00:00 | 2021-04-29T15:42:08.035106+00:00 | 13,274 | false | **Q & A**\nQ1: Why have you initialized index with `-1` and not `0`?\n\nA1: Make the code more general. e.g., If no point has the same `x` or `y` coordinate, then we can still detect it by the return value. Otherwise, if the return value is `0`, we would NOT know whether the point at index `0` is the solution or not.\n... | 98 | 3 | [] | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.