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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
special-array-with-x-elements-greater-than-or-equal-x | java o(nlogn),step by step easy explain and intuition of hint | java-onlognstep-by-step-easy-explain-and-vnfb | \nclass Solution {\n private static int binSrc(int [] nums , int target){\n int low = 0 ; \n int high = nums.length - 1;\n // when targ | mrrp | NORMAL | 2020-10-05T17:49:33.543588+00:00 | 2020-10-05T18:02:37.014537+00:00 | 377 | false | ```\nclass Solution {\n private static int binSrc(int [] nums , int target){\n int low = 0 ; \n int high = nums.length - 1;\n // when target < min number in array\n if(target < nums[low])\n return low ;\n // when target > max number in array\n if(target > nums[h... | 5 | 0 | [] | 1 |
special-array-with-x-elements-greater-than-or-equal-x | Good explanation with simple approach. | good-explanation-with-simple-approach-by-q3bd | Intuition\n Describe your first thoughts on how to solve this problem. \n\nThe problem seems to be about finding a "special" integer in an array. A special inte | aria_vikneesh | NORMAL | 2024-05-28T06:39:39.247470+00:00 | 2024-05-28T06:39:39.247494+00:00 | 31 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nThe problem seems to be about finding a "special" integer in an array. A special integer is one where the count of elements greater than or equal to it is exactly equal to the value of the integer itself.\n# Approach\n<!-- Describe your... | 4 | 0 | ['C'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Python✅ In-Built✅ Function.. Beats 100%🔥🔥 | python-in-built-function-beats-100-by-21-g0lf | Here we are using bisect concept that will tell us where the element is to fitted as a binary search parameter !! we just have to check from descending order w | 21eca01 | NORMAL | 2024-05-27T03:53:36.647014+00:00 | 2024-05-27T03:59:18.284536+00:00 | 923 | false | Here we are using bisect concept that will tell us where the element is to fitted as a binary search parameter !! we just have to check from descending order whether the value satisfies the condition or not!!\n# Code\n```\nimport bisect\n\nclass Solution:\n def specialArray(self, nums: List[int]) -> int:\n n... | 4 | 0 | ['Python3'] | 3 |
special-array-with-x-elements-greater-than-or-equal-x | C++||beats 100%||0 ms|| binary search | cbeats-1000-ms-binary-search-by-jayasury-i25t | 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 | jayasurya1922 | NORMAL | 2023-04-10T08:04:37.752983+00:00 | 2023-04-10T08:04:57.742954+00:00 | 625 | 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)$$ --... | 4 | 0 | ['C++'] | 2 |
special-array-with-x-elements-greater-than-or-equal-x | Beats 100% Easy CPP SOL | beats-100-easy-cpp-sol-by-zenitsu02-x0vg | PLEASE UPVOTE ME\uD83E\uDD79\n# Complexity\n- Time complexity: NLog(n)\n\n- Space complexity: O(1)\n\n# Code\n\nclass Solution {\npublic:\n\n\n // function f | Zenitsu02 | NORMAL | 2023-04-08T04:56:46.425658+00:00 | 2023-04-08T04:56:46.425691+00:00 | 342 | false | # **PLEASE UPVOTE ME\uD83E\uDD79**\n# Complexity\n- Time complexity: NLog(n)\n\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution {\npublic:\n\n\n // function for find element \n int findElement(vector<int>&nums, int no){\n int ans = 0;\n for(int i = 0; i<nums.size(); i++){\n if(num... | 4 | 0 | ['C++'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | 0ms || Faster || Easy C++ | 0ms-faster-easy-c-by-amit2024-e4z6 | Intuition\nBinary Search\n\n# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(1) \n\n# Code\n\nclass Solution {\npublic:\n\n int specialAr | amit2024 | NORMAL | 2023-03-11T10:05:06.393297+00:00 | 2023-04-30T13:54:25.674866+00:00 | 560 | false | # Intuition\nBinary Search\n\n# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(1) \n\n# Code\n```\nclass Solution {\npublic:\n\n int specialArray(vector<int>& nums) {\n int max = INT_MIN;\n for(auto x: nums){\n if(x>max){\n max=x;\n }\n }\... | 4 | 0 | ['Binary Search', 'C'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | java || binary search | java-binary-search-by-bhardwajankit1412-emqr | \n\n# Code\n\nclass Solution {\n public int specialArray(int[] nums) {\n int end=nums.length;\n int start=0;\n while(start<=end){\n | bhardwajankit1412 | NORMAL | 2023-01-30T18:31:26.791015+00:00 | 2023-01-30T18:31:26.791064+00:00 | 442 | false | \n\n# Code\n```\nclass Solution {\n public int specialArray(int[] nums) {\n int end=nums.length;\n int start=0;\n while(start<=end){\n int mid=start+(end-start)/2;\n int count=0;\n for(int i=0;i<nums.length;i++){\n if(nums[i]>=mid) count++;\n ... | 4 | 0 | ['Binary Search', 'Java'] | 2 |
special-array-with-x-elements-greater-than-or-equal-x | Two java solutions with explanation🔥|| Easy To Understand | two-java-solutions-with-explanation-easy-aeg3 | In this post I shall share two solutions in Java language but can be easily understood by any language user.\n1. Linear search of number of elements greater tha | anujpanchal2001 | NORMAL | 2022-10-20T14:34:30.422572+00:00 | 2022-10-22T13:21:26.445044+00:00 | 988 | false | In this post I shall share two solutions in Java language but can be easily understood by any language user.\n1. **Linear search of number of elements greater than x**\n\tTime Complexity: O(n * log(max(nums)))\n\tSpace Complexity: O(1)\n\tRuntime: 1ms\n\tBeats: 92.31%\n\tIn this method we binary search over the answer ... | 4 | 0 | ['Binary Tree', 'Java'] | 2 |
special-array-with-x-elements-greater-than-or-equal-x | Python Bucket sort O(n) | python-bucket-sort-on-by-xinyulrsm-gz86 | Since the possible value are less than 1000, we shoud consider bucket sort instead of quick sort or merge sort. Bucket sort nake the solution has time O(n) and | xinyulrsm | NORMAL | 2022-10-19T23:49:49.303581+00:00 | 2022-10-20T00:05:17.550972+00:00 | 512 | false | Since the possible value are less than 1000, we shoud consider bucket sort instead of quick sort or merge sort. Bucket sort nake the solution has time O(n) and space O(1). Hope the code is self explanatory.\n\n```\nclass Solution:\n def specialArray(self, nums: List[int]) -> int:\n \n N, MAX_SIZE = l... | 4 | 0 | ['Bucket Sort', 'Python'] | 2 |
special-array-with-x-elements-greater-than-or-equal-x | Java Binary Search! EASY 100% faster! | java-binary-search-easy-100-faster-by-de-4ugx | Just take the search space of 0 to length of array!\n\nclass Solution {\n public int specialArray(int[] nums) {\n int high=nums.length;\n int l | deity0503 | NORMAL | 2022-10-08T22:57:36.011429+00:00 | 2022-10-08T22:57:36.011466+00:00 | 809 | false | **Just take the search space of 0 to length of array!**\n```\nclass Solution {\n public int specialArray(int[] nums) {\n int high=nums.length;\n int low=0;\n while(low<=high){\n int mid=low+(high-low)/2;\n int count=0;\n for(int i=0;i<nums.length;i++){\n ... | 4 | 0 | ['Binary Tree', 'Java'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Java Solution with Detailed Explanation (Binary Search) | java-solution-with-detailed-explanation-li6oo | Please upvote if this helps you! :)\n\nAs per the description we need to find a value x which may/may not exist in the array that has exactly x numbers in the a | eshikarya | NORMAL | 2022-10-01T15:29:31.940369+00:00 | 2022-10-02T10:06:03.657302+00:00 | 426 | false | ### Please upvote if this helps you! :)\n\nAs per the description we need to find a value x which may/may not exist in the array that has exactly x numbers in the array greater than or equal to it.\n\n\n*Code Breakdown:*\n\nclass Solution {\n public int specialArray(int[] nums) {\n\n1.\tInititalise start and end var... | 4 | 0 | ['Binary Tree', 'Java'] | 1 |
special-array-with-x-elements-greater-than-or-equal-x | c++|| simple solution using binary search | c-simple-solution-using-binary-search-by-fb97 | \nclass Solution {\npublic:\n int count(int x,vector<int> nums){\n int index=lower_bound(nums.begin(),nums.end(),x)-nums.begin();\n return nums | ALS_Venky | NORMAL | 2022-07-22T07:52:23.884417+00:00 | 2022-07-22T07:52:23.884457+00:00 | 148 | false | ```\nclass Solution {\npublic:\n int count(int x,vector<int> nums){\n int index=lower_bound(nums.begin(),nums.end(),x)-nums.begin();\n return nums.size()-index;\n }\n int specialArray(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int max=nums[nums.size()-1],min=0,mid;\n ... | 4 | 0 | ['Binary Search'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Runtime: 1 ms, easiest solution | runtime-1-ms-easiest-solution-by-rustee_-un6f | \npublic int specialArray(int[] nums) {\n int high=0;\n for(int i=0;i<nums.length;i++){\n if(high<nums[i]){\n high=nums[ | rustee_95 | NORMAL | 2021-12-04T10:50:53.266685+00:00 | 2021-12-04T10:50:53.266714+00:00 | 325 | false | ```\npublic int specialArray(int[] nums) {\n int high=0;\n for(int i=0;i<nums.length;i++){\n if(high<nums[i]){\n high=nums[i];\n }\n }\n \n for(int i=0;i<=high;i++){\n int count=0;\n for(int j=0;j<nums.length;j++){\n ... | 4 | 0 | ['Java'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Python binary search O(nLogn) faster than 95%. With explanation | python-binary-search-onlogn-faster-than-awy44 | Our goal is to find if there exists a number x such that there are exactly x numbers in nums that are greater than or equal to x. Lets say the special number is | akashveneno | NORMAL | 2021-07-20T16:24:18.416607+00:00 | 2021-08-08T13:47:00.444808+00:00 | 251 | false | Our goal is to find if there exists a number `x` such that there are exactly x numbers in `nums` that are greater than or equal to `x`. Lets say the special number is two, which means there are exactly two numbers greater than or equal to 2. The value of x can be between `0` and `max(nums)`. So we sort the array and u... | 4 | 0 | [] | 2 |
special-array-with-x-elements-greater-than-or-equal-x | a few solutions | a-few-solutions-by-claytonjwong-pntj | Let N be the cardinality of A, then consider all possible values from 0..N inclusive as the ith special value. Return i if and only if the lower bound of i in | claytonjwong | NORMAL | 2020-10-04T04:00:40.091716+00:00 | 2023-05-16T02:08:53.364300+00:00 | 1,356 | false | Let `N` be the cardinality of `A`, then consider all possible values from `0..N` inclusive as the `i`<sup>th</sup> special value. Return `i` if and only if the lower bound of `i` in the sorted array `A` equals `N - i`, otherwise return `-1`.\n \n**Note:** Javascript does *not* have built-in language support for bin... | 4 | 0 | [] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Beats 100% | Most elaborative solution | JAVA || | beats-100-most-elaborative-solution-java-18yk | Intuition\nThe problem is about finding a special integer x such that there are exactly x elements in the array nums that are greater than or equal to x. To ach | theDummy | NORMAL | 2024-09-07T05:31:48.706060+00:00 | 2024-09-07T05:31:48.706083+00:00 | 57 | false | # Intuition\nThe problem is about finding a special integer x such that there are exactly x elements in the array nums that are greater than or equal to x. To achieve this, the approach checks every possible value of x (from 0 to nums.length) and counts how many elements in the array are greater than or equal to x.\n\n... | 3 | 0 | ['Array', 'Binary Search', 'Sorting', 'Java'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | How to Quickly find if the Array is Speacial or not | how-to-quickly-find-if-the-array-is-spea-zyxp | 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 | vansh0123 | NORMAL | 2024-08-06T18:07:21.806783+00:00 | 2024-08-06T18:07:21.806816+00:00 | 11 | 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 |
special-array-with-x-elements-greater-than-or-equal-x | ✅EASY AND SIMPLE SOLUTION✅(Beats 100.00% of users with C++) | easy-and-simple-solutionbeats-10000-of-u-us3h | \n\n# Code\n\nclass Solution {\npublic:\n int specialArray(vector<int>& nums) {\n sort(nums.begin(), nums.end());\n\n int start = 0;\n i | deleted_user | NORMAL | 2024-05-27T15:23:50.393616+00:00 | 2024-05-27T15:26:40.451439+00:00 | 443 | false | \n\n# Code\n```\nclass Solution {\npublic:\n int specialArray(vector<int>& nums) {\n sort(nums.begin(), nums.end());\n\n int start = 0;\n int end = nums.size();\n\n while (start <= end) {\n int mid = start + (end - start) / 2;\n int ans = 0;\n\n for (int n... | 3 | 0 | ['C++'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Use Prefix Sum Over Frequencies of the Numbers To Find X | Java | C++ | use-prefix-sum-over-frequencies-of-the-n-76o4 | Intuition, approach, and complexity dicussed in video solution in detail.\nhttps://youtu.be/YU4NKz6Yd4w\n# Code\nC++\n\nclass Solution {\npublic:\n int speci | Lazy_Potato_ | NORMAL | 2024-05-27T15:04:38.597336+00:00 | 2024-05-27T15:04:38.597358+00:00 | 308 | false | # Intuition, approach, and complexity dicussed in video solution in detail.\nhttps://youtu.be/YU4NKz6Yd4w\n# Code\nC++\n```\nclass Solution {\npublic:\n int specialArray(vector<int>& nums) {\n int size = nums.size();\n \n vector<int> freq(size + 1, 0);\n for (int indx = 0; indx < size; in... | 3 | 0 | ['Hash Table', 'Prefix Sum', 'C++', 'Java'] | 1 |
special-array-with-x-elements-greater-than-or-equal-x | Using Binary Search beats 100% | using-binary-search-beats-100-by-anoop_g-0ird | Intuition\n Binary Search : Lower_bound function use\n\n# Approach\n- Firstly we sorted a array took a largest element as the upper limit to check if there exis | anoop_ghimire08 | NORMAL | 2024-05-27T11:22:09.205368+00:00 | 2024-05-27T11:22:09.205387+00:00 | 15 | false | # Intuition\n Binary Search : Lower_bound function use\n\n# Approach\n- Firstly we sorted a array took a largest element as the upper limit to check if there exist a solution.\n- In for loop we are checking through all the value from 0 to maxm\n- We used lower bound for finding the minimum index at which value is just ... | 3 | 0 | ['Binary Search', 'C++'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Java Easy to Understand Solution with Explanation || 100% beats | java-easy-to-understand-solution-with-ex-wv9a | Intuition\n> This approach involves creating a hash table to store the count of each number in the array. If a number is greater than the size of the array, its | leo_messi10 | NORMAL | 2024-05-27T10:25:48.818234+00:00 | 2024-05-27T10:25:48.818251+00:00 | 154 | false | # Intuition\n> This approach involves creating a hash table to store the count of each number in the array. If a number is greater than the size of the array, its count is stored in a separate hash slot at index \'size + 1\'. After building the hash table, we iterate through it in reverse order to identify any special ... | 3 | 0 | ['Array', 'Hash Table', 'Java'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Easy C++ Solution | Beats 100 💯✅ | easy-c-solution-beats-100-by-shobhitkush-kb6u | Intuition and Approach\n\n### Problem Understanding\nThe problem is to find a special integer x such that there are exactly x numbers in the array that are grea | shobhitkushwaha1406 | NORMAL | 2024-05-27T10:19:32.489705+00:00 | 2024-05-27T10:19:32.489723+00:00 | 285 | false | ## Intuition and Approach\n\n### Problem Understanding\nThe problem is to find a special integer `x` such that there are exactly `x` numbers in the array that are greater than or equal to `x`. If such an `x` does not exist, return `-1`.\n\n### Approach\nTo solve this problem, we need to determine a value of `x` that sa... | 3 | 0 | ['Array', 'Binary Search', 'Sorting', 'C++'] | 1 |
special-array-with-x-elements-greater-than-or-equal-x | simple python solution beats 99%. | simple-python-solution-beats-99-by-utkar-qt05 | \n\n# Code\n\nclass Solution:\n def specialArray(self, nums: List[int]) -> int:\n nums.sort()\n n=len(nums)\n for i in range(n+1):\n | Utkarshydv | NORMAL | 2024-05-27T08:36:09.547956+00:00 | 2024-05-27T08:36:09.547998+00:00 | 378 | false | \n\n# Code\n```\nclass Solution:\n def specialArray(self, nums: List[int]) -> int:\n nums.sort()\n n=len(nums)\n for i in range(n+1):\n c=i\n for j in nums:\n if j>=i:\n c-=1\n if c<0:\n break\n ... | 3 | 0 | ['Python3'] | 1 |
special-array-with-x-elements-greater-than-or-equal-x | 0ms - Beats 100% ✅🔥🔥🔥| Python, C++💻 | EASY, CLEAR Explanation📗 | 0ms-beats-100-python-c-easy-clear-explan-iicq | 0ms - Beats 100% \u2705\uD83D\uDD25\uD83D\uDD25\uD83D\uDD25| Python, C++\uD83D\uDCBB | EASY, CLEAR Explanation\uD83D\uDCD7\n\n## 1. Proof\n Describe your first | kcp_1410 | NORMAL | 2024-05-27T07:11:45.476760+00:00 | 2024-05-27T07:11:45.476786+00:00 | 81 | false | # 0ms - Beats 100% \u2705\uD83D\uDD25\uD83D\uDD25\uD83D\uDD25| Python, C++\uD83D\uDCBB | EASY, CLEAR Explanation\uD83D\uDCD7\n\n## 1. Proof\n<!-- Describe your first thoughts on how to solve this problem. -->\n### 1.1. C++\n {\n // because of constraints specified take array of 1001\n vector<int> c(1001, 0);\n\n // flag is for edge case, we\'ll co... | 3 | 0 | ['C++'] | 3 |
special-array-with-x-elements-greater-than-or-equal-x | Using Hash Map | Python | using-hash-map-python-by-pragya_2305-vjb0 | Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(n)\n\n# Code\n\nclass Solution:\n def specialArray(self, nums: List[int]) -> int:\n count | pragya_2305 | NORMAL | 2024-05-27T03:27:35.649311+00:00 | 2024-05-27T03:27:35.649334+00:00 | 428 | false | # Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(n)\n\n# Code\n```\nclass Solution:\n def specialArray(self, nums: List[int]) -> int:\n count = Counter(nums)\n total_so_far = 0\n\n for i in range(max(nums),-1,-1):\n total_so_far += count[i]\n if total_so_far==... | 3 | 0 | ['Array', 'Hash Table', 'Python', 'Python3'] | 1 |
special-array-with-x-elements-greater-than-or-equal-x | Easy || Java || Binary Search || Fully Explained || Please Upvote | easy-java-binary-search-fully-explained-gsfds | The problem is to find a special number $ x $ in an array ${nums}$ such that there are exactly $ x $ numbers in ${nums}$ that are greater than or equal to$ x $. | va-run-6626 | NORMAL | 2024-05-27T01:02:48.455761+00:00 | 2024-05-27T01:13:30.456193+00:00 | 472 | false | The problem is to find a special number $ x $ in an array ${nums}$ such that there are exactly $ x $ numbers in ${nums}$ that are greater than or equal to$ x $. If such a number $ x $ exists, return it; otherwise, return $-1$. It\'s proven that if $ x $ exists, it is unique.\n\n### Intuition\n1. **Sorting Insight**: By... | 3 | 0 | ['Array', 'Binary Search', 'Sorting', 'Java'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | ✅ Easy C++ Solution | easy-c-solution-by-moheat-4e02 | Code\n\nclass Solution {\npublic:\n int specialArray(vector<int>& nums) {\n int n = nums.size();\n\n sort(nums.begin(),nums.end());\n\n | moheat | NORMAL | 2024-05-27T00:46:50.964272+00:00 | 2024-05-27T00:46:50.964288+00:00 | 2,227 | false | # Code\n```\nclass Solution {\npublic:\n int specialArray(vector<int>& nums) {\n int n = nums.size();\n\n sort(nums.begin(),nums.end());\n\n for(int i=1;i<=n;i++)\n {\n int count = 0;\n for(int j=n-1;j>=0;j--)\n {\n if(nums[j] >= i)\n ... | 3 | 0 | ['C++'] | 1 |
special-array-with-x-elements-greater-than-or-equal-x | Binary Search easy solution Beats 100% 🚀🚀🔥 | binary-search-easy-solution-beats-100-by-i31b | Intuition\n Describe your first thoughts on how to solve this problem. \nOur aims is to find a number x such that there are exactly x elements in the input arr | skill_improve | NORMAL | 2024-04-26T12:20:27.085730+00:00 | 2024-04-26T12:20:27.085769+00:00 | 165 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nOur aims is to find a number x such that there are exactly x elements in the input array nums that are greater than or equal to x.Here searching so directly think of binary Search on ans.\n\n# Approach\n<!-- Describe your approach to sol... | 3 | 0 | ['Array', 'Binary Search', 'Sorting', 'C++'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Kotlin binary search solution without sorting | kotlin-binary-search-solution-without-so-6xbn | \n\n# Code\n\nclass Solution {\n fun specialArray(nums: IntArray): Int {\n var low = 0\n var high = nums.size\n while(low <= high) {\n | chayangkoon | NORMAL | 2024-04-02T14:19:49.855609+00:00 | 2024-04-02T17:28:42.471584+00:00 | 35 | false | \n\n# Code\n```\nclass Solution {\n fun specialArray(nums: IntArray): Int {\n var low = 0\n var high = nums.size\n while(low <= high) {\n val middle ... | 3 | 0 | ['Kotlin'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Easiest Solution using Binary Search | easiest-solution-using-binary-search-by-w001p | Intuition\n Describe your first thoughts on how to solve this problem. \nThis problem can be solved using Binary Search + Linear Search.\n\n# Approach\n Describ | saket_1 | NORMAL | 2023-07-25T08:35:52.647562+00:00 | 2023-07-25T08:35:52.647582+00:00 | 61 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThis problem can be solved using **Binary Search + Linear Search.**\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nIn Binary search we do search on a range of values. So first think that the answer will always lie... | 3 | 0 | ['Binary Search', 'Sorting', 'C++'] | 2 |
special-array-with-x-elements-greater-than-or-equal-x | Easy two for loops in java | easy-two-for-loops-in-java-by-bhupendra0-cwv0 | 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 | bhupendra082002 | NORMAL | 2023-04-07T14:08:42.882024+00:00 | 2023-04-07T14:08:42.882058+00:00 | 264 | 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 |
special-array-with-x-elements-greater-than-or-equal-x | JAVA | Simple Solution | Sorting & BinarySearch | java-simple-solution-sorting-binarysearc-zw6j | Complexity\n- Time complexity: O(n * log(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) | ilyastuit | NORMAL | 2023-04-07T06:16:13.512469+00:00 | 2023-05-28T06:08:00.257610+00:00 | 1,010 | false | # Complexity\n- Time complexity: $$O(n * log(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\n public int specialArray(int[] nums) {\n Arrays.sort(nums);\n int n = num... | 3 | 0 | ['Array', 'Binary Search', 'Sorting', 'Java'] | 2 |
special-array-with-x-elements-greater-than-or-equal-x | EASY JAVA Solution | Beats 100% | easy-java-solution-beats-100-by-kunal_ka-5qyr | \n# Code\n\nclass Solution {\n public int specialArray(int[] nums) {\n int start=0;\n int end=nums.length;\n while(start<=end){\n | kunal_kamble | NORMAL | 2023-03-27T05:43:44.582486+00:00 | 2023-03-27T05:43:44.582530+00:00 | 361 | false | \n# Code\n```\nclass Solution {\n public int specialArray(int[] nums) {\n int start=0;\n int end=nums.length;\n while(start<=end){\n int mid=start+(end-start)/2;\n int count=0;\n for(int i=0;i<nums.length;i++){\n if(nums[i]>=mid){\n ... | 3 | 0 | ['Binary Search', 'Java'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Python - O(n) Solution | python-on-solution-by-prateekgoel7248-qmk5 | \tclass Solution:\n\t\tdef specialArray(self, nums: List[int]) -> int:\n\t\t\tfreq=[0 for _ in range(max(nums)+1)]\n\t\t\tfor i in nums:\n\t\t\t\tfreq[i]+=1\n\t | prateekgoel7248 | NORMAL | 2022-10-16T09:41:51.686520+00:00 | 2022-10-16T09:41:51.686565+00:00 | 1,138 | false | \tclass Solution:\n\t\tdef specialArray(self, nums: List[int]) -> int:\n\t\t\tfreq=[0 for _ in range(max(nums)+1)]\n\t\t\tfor i in nums:\n\t\t\t\tfreq[i]+=1\n\t\t\tsuff=[freq[-1]]\n\t\t\tfor i in freq[::-1][1:]:\n\t\t\t\tsuff.append(suff[-1]+i)\n\t\t\tsuff=suff[::-1]\n\t\t\tfor i in range(max(nums)+1):\n\t\t\t\tif suff... | 3 | 0 | ['Python', 'C++', 'Java', 'Python3'] | 1 |
special-array-with-x-elements-greater-than-or-equal-x | C++ | Binary Search | c-binary-search-by-nikhil1947-313f | \nclass Solution {\npublic:\n int specialArray(vector<int>& nums) {\n\t\n sort(nums.begin(),nums.end());\n int i=nums.size();\n\t\t\n wh | nikhil1947 | NORMAL | 2022-10-03T20:09:12.825429+00:00 | 2022-10-19T21:04:21.862931+00:00 | 1,060 | false | ```\nclass Solution {\npublic:\n int specialArray(vector<int>& nums) {\n\t\n sort(nums.begin(),nums.end());\n int i=nums.size();\n\t\t\n while(i>0){\n int start=0,end=nums.size()-1;\n int count=0;\n while(start<=end){\n int mid=start+(end-start)/2;... | 3 | 0 | ['C', 'Binary Tree'] | 1 |
special-array-with-x-elements-greater-than-or-equal-x | Simple binary search + Inbuilt sorting | simple-binary-search-inbuilt-sorting-by-aapem | ```\nclass Solution {\n public int specialArray(int[] nums) {\n Arrays.sort(nums);\n\t\t//Count the number of elements greater than or equal to x for | Abhinav_0561 | NORMAL | 2022-06-15T10:06:25.429909+00:00 | 2022-06-15T10:06:25.429944+00:00 | 246 | false | ```\nclass Solution {\n public int specialArray(int[] nums) {\n Arrays.sort(nums);\n\t\t//Count the number of elements greater than or equal to x for each x in the range [0, nums.length].\n int start = 0 , end = nums.length;\n while (start<=end){\n int mid = start + (end - start)/2;\n... | 3 | 0 | ['Sorting', 'Binary Tree', 'Java'] | 1 |
special-array-with-x-elements-greater-than-or-equal-x | Python O(n) Soln, short and fast | python-on-soln-short-and-fast-by-archit_-0mze | \nclass Solution:\n def specialArray(self, nums: List[int]) -> int:\n count, nums = 0, Counter(nums)\n for i in range(max(nums), -1, -1):\n | Archit_Sharma | NORMAL | 2022-04-13T12:25:58.493668+00:00 | 2022-04-13T12:25:58.493711+00:00 | 212 | false | ```\nclass Solution:\n def specialArray(self, nums: List[int]) -> int:\n count, nums = 0, Counter(nums)\n for i in range(max(nums), -1, -1):\n count += nums[i]\n if count == i: \n return count\n return -1 \n``` | 3 | 0 | ['Python'] | 1 |
special-array-with-x-elements-greater-than-or-equal-x | Java | 2 methods | Explained | java-2-methods-explained-by-prashant404-qdp8 | Method 1: Sort and Binary Search\n>T/S: O(n lg n)/O(n), where n = size(nums)\n\npublic int specialArray(int[] nums) {\n\tvar n = nums.length;\n\treverseSort(num | prashant404 | NORMAL | 2022-01-18T06:16:50.868250+00:00 | 2024-05-27T01:21:39.332878+00:00 | 422 | false | **Method 1:** Sort and Binary Search\n>**T/S:** O(n lg n)/O(n), where n = size(nums)\n```\npublic int specialArray(int[] nums) {\n\tvar n = nums.length;\n\treverseSort(nums, n);\n\treturn binarySearch(nums, n);\n}\n\n// O(n lg n)/O(n)\nprivate void reverseSort(int[] nums, int n) {\n\tArrays.sort(nums);\n\t\n\tfor (var ... | 3 | 0 | ['Binary Search', 'Java'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Intuitive java solution | Binary Search on size array | 100% faster | intuitive-java-solution-binary-search-on-czf3 | ```\nclass Solution {\n public int specialArray(int[] nums) {\n int l = nums.length;\n int lo = 0, hi = l - 1;\n while(lo <= hi)\n | white_harmony | NORMAL | 2021-09-28T07:55:23.241605+00:00 | 2021-09-28T07:55:23.241644+00:00 | 107 | false | ```\nclass Solution {\n public int specialArray(int[] nums) {\n int l = nums.length;\n int lo = 0, hi = l - 1;\n while(lo <= hi)\n {\n int mid = (lo + hi) / 2;\n int diff = special(nums, mid + 1);\n if(diff < 0)\n {\n hi = mid - 1... | 3 | 0 | [] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Java || Sorting + Binary Search + Counting || 0ms || beats 100% || T.C - O(n) S.C - O(n) | java-sorting-binary-search-counting-0ms-a6heq | \n\t// Linear Search + Sorting\n\t// O(n^2) O(1)\n\tpublic int specialArray1(int[] nums) {\n\n\t\tint len = nums.length;\n\n\t\tfor (int i = 1; i <= len; i++) { | LegendaryCoder | NORMAL | 2021-07-05T11:58:38.789925+00:00 | 2021-07-05T11:58:38.789962+00:00 | 110 | false | \n\t// Linear Search + Sorting\n\t// O(n^2) O(1)\n\tpublic int specialArray1(int[] nums) {\n\n\t\tint len = nums.length;\n\n\t\tfor (int i = 1; i <= len; i++) {\n\t\t\tint count = 0;\n\t\t\tfor (int j = len - 1; j >= 0; j--) {\n\t\t\t\tif (nums[j] >= i)\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t\tif (count == i)\n\t\t\t\tretur... | 3 | 0 | [] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | 98% :: Python | Binary Search (Very similar to H- Index) | 98-python-binary-search-very-similar-to-9i8aq | \nimport bisect\nclass Solution:\n def specialArray(self, nums: List[int]) -> int:\n nums.sort()\n for i in range(1, len(nums) + 1):\n | tuhinnn_py | NORMAL | 2021-05-20T15:41:26.093814+00:00 | 2021-05-20T15:41:26.093856+00:00 | 386 | false | ```\nimport bisect\nclass Solution:\n def specialArray(self, nums: List[int]) -> int:\n nums.sort()\n for i in range(1, len(nums) + 1):\n startIndex = bisect.bisect_left(nums, i)\n if len(nums) - startIndex == i:\n return i\n return -1\n``` | 3 | 0 | ['Binary Tree', 'Python'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Very simple/intuitive python solution | very-simpleintuitive-python-solution-by-54g1u | \nclass Solution:\n def specialArray(self, nums: List[int]) -> int:\n \n for i in range(len(nums), -1, -1):\n if [j >= i for j in nu | loag | NORMAL | 2021-02-13T14:34:55.363524+00:00 | 2021-02-13T14:34:55.363548+00:00 | 140 | false | ```\nclass Solution:\n def specialArray(self, nums: List[int]) -> int:\n \n for i in range(len(nums), -1, -1):\n if [j >= i for j in nums].count(True) == i:\n return i\n return -1\n``` | 3 | 0 | [] | 1 |
special-array-with-x-elements-greater-than-or-equal-x | Python, sort. Time: O(N log N), Space: O(N) | python-sort-time-on-log-n-space-on-by-bl-f5ms | \nclass Solution:\n def specialArray(self, nums: List[int]) -> int:\n nums.sort()\n for i in range(len(nums)):\n x = len(nums) - i \ | blue_sky5 | NORMAL | 2020-11-08T00:15:20.751762+00:00 | 2020-11-08T00:16:39.543050+00:00 | 421 | false | ```\nclass Solution:\n def specialArray(self, nums: List[int]) -> int:\n nums.sort()\n for i in range(len(nums)):\n x = len(nums) - i \n if (i == 0 or nums[i-1] < x) and x <= nums[i]:\n return x\n \n return -1\n``` | 3 | 0 | ['Python', 'Python3'] | 2 |
special-array-with-x-elements-greater-than-or-equal-x | sort explained (with pictures)^^ | sort-explained-with-pictures-by-andrii_k-htb7 | Idea and pictures\n\nNote that that possible outcomes of the algorithm are 0...size(n) (and -1). \nThus we should check these numbers only.\nIf we sort the arra | andrii_khlevniuk | NORMAL | 2020-10-04T22:09:13.318203+00:00 | 2020-10-06T11:52:52.266528+00:00 | 382 | false | **Idea and pictures**\n\nNote that that possible outcomes of the algorithm are `0...size(n)` (and `-1`). \nThus we should check these numbers only.\nIf we sort the array in the ascending order we aim to find an index `i` from interval `[0, size(n)]` such that `n[i-1] >= i and n[i] < i`.\nThus we traverse the array from... | 3 | 0 | ['C', 'C++'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Beats 100% | C++ | No-Sort Solution to Special Array With X Elements Greater Than or Equal X | beats-100-c-no-sort-solution-to-special-3qjny | IntuitionThe problem requires finding a value x such that there are exactly x elements in the array greater than or equal to x. The key observation is that sort | anorangefalcon | NORMAL | 2025-01-14T18:23:50.827404+00:00 | 2025-01-14T18:23:50.827404+00:00 | 97 | false | # Intuition
The problem requires finding a value `x` such that there are exactly `x` elements in the array greater than or equal to `x`. The key observation is that sorting the array is unnecessary since we only need to count occurrences and aggregate values efficiently. By maintaining a frequency array for elements le... | 2 | 0 | ['Array', 'C++'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Binary Search Approach for Finding | binary-search-approach-for-finding-by-ha-2tp8 | Intuition\nTo find the special value x such that there are exactly x numbers in the array that are greater than or equal to x, we can leverage the properties of | hamzawp404 | NORMAL | 2024-05-27T15:33:45.885834+00:00 | 2024-05-27T15:33:45.885862+00:00 | 10 | false | # Intuition\nTo find the special value x such that there are exactly x numbers in the array that are greater than or equal to x, we can leverage the properties of a sorted array to efficiently determine the count of such elements.\n\n# Approach\n1. Sort the Array: Sorting helps to efficiently count the elements greater... | 2 | 0 | ['Binary Search', 'C++'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Easy Approach in JS 90% | easy-approach-in-js-90-by-machip3r-0335 | Intuition\nI only think in the for loop to iterate from 0 to nums.length checking each numbers of nums. But viewing the best times in JS, I can do it better wit | MacHip3r | NORMAL | 2024-05-27T14:49:37.549631+00:00 | 2024-05-27T14:49:37.549652+00:00 | 149 | false | # Intuition\nI only think in the *for loop* to iterate from 0 to *nums.length* checking each numbers of *nums*. But viewing the best times in JS, I can do it better with binary search.\nIt is what it is.\n\n# Approach\nReading the intuition is easy to do the approach, so that is.\nIterate from 0 to *nums.length*, then ... | 2 | 0 | ['Array', 'JavaScript'] | 1 |
special-array-with-x-elements-greater-than-or-equal-x | Beats 20.04% of users with Python3 | beats-2004-of-users-with-python3-by-kawi-epag | 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 | KawinP | NORMAL | 2024-05-27T14:34:27.893654+00:00 | 2024-05-27T14:34:27.893673+00:00 | 14 | 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- **Space Complexity** : \\(O(1)\\)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n<!-- Add your space ... | 2 | 0 | ['Python3'] | 0 |
special-array-with-x-elements-greater-than-or-equal-x | Only (N) Without sorting 🚀 || concise 🎗️|| newbie friendly 🔥|| simple explanation 🧩|| 4 lang 🎉 | only-n-without-sorting-concise-newbie-fr-y779 | Screenshot \uD83C\uDF89\n\n\n\n---\n# Intuition \uD83E\uDD14\n This is a pretty good problem ... Let\'s discuss first-->\n\nGiven --> \n\n1. We are given an | Prakhar-002 | NORMAL | 2024-05-27T14:25:25.570170+00:00 | 2024-05-27T20:25:06.920520+00:00 | 189 | false | # Screenshot \uD83C\uDF89\n\n\n\n---\n# Intuition \uD83E\uDD14\n This is a pretty good problem ... Let\'s discuss first-->\n\n`Given -->` \n\n`1.` We are given `an array` with `some positive values` only\n... | 2 | 0 | ['Array', 'Binary Search', 'C', 'Sorting', 'Java', 'Python3', 'JavaScript'] | 1 |
special-array-with-x-elements-greater-than-or-equal-x | simple solution | simple-solution-by-abhishekd1163-g5hc | 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 | abhishekd1163 | NORMAL | 2024-05-27T10:31:00.445045+00:00 | 2024-05-27T10:31:00.445061+00:00 | 21 | 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++'] | 1 |
minimum-number-of-operations-to-make-array-continuous | [Python] Binary Search - Clean & Concise | python-binary-search-clean-concise-by-hi-9rcn | Idea\n- Store the original length, n = len(nums).\n- Firstly, make elements in nums unique and sort nums array.\n- Try elements in nums as the start of the cont | hiepit | NORMAL | 2021-09-18T16:00:34.530195+00:00 | 2021-10-01T08:16:31.115426+00:00 | 9,456 | false | **Idea**\n- Store the original length, `n = len(nums)`.\n- Firstly, **make** elements in `nums` **unique** and **sort** `nums` array.\n- Try elements in `nums` as the start of the continuous array, let say `start`.\n\t- Elements in the continuous array must in range `[start, end]`, where `end = start + n - 1`.\n\t- Bin... | 144 | 6 | [] | 12 |
minimum-number-of-operations-to-make-array-continuous | C++ Sliding Window | c-sliding-window-by-lzl124631x-a14t | See my latest update in repo LeetCode\n## Solution 1. Sliding Window\n\nCheck out "C++ Maximum Sliding Window Cheatsheet Template!" which can help you solve all | lzl124631x | NORMAL | 2021-09-18T16:00:48.170437+00:00 | 2021-10-02T22:21:03.896365+00:00 | 13,910 | false | See my latest update in repo [LeetCode](https://github.com/lzl124631x/LeetCode)\n## Solution 1. Sliding Window\n\nCheck out "[C++ Maximum Sliding Window Cheatsheet Template!](https://leetcode.com/problems/frequency-of-the-most-frequent-element/discuss/1175088/C%2B%2B-Maximum-Sliding-Window-Cheatsheet-Template!)" which ... | 131 | 1 | [] | 7 |
minimum-number-of-operations-to-make-array-continuous | 【Video】Give me 15 minutes - How we think about a solution | video-give-me-15-minutes-how-we-think-ab-1edl | Welcome to my post! This post starts with "How we think about a solution". In other words, that is my thought process to solve the question. This post explains | niits | NORMAL | 2023-10-10T08:54:30.152063+00:00 | 2023-10-11T10:25:55.641141+00:00 | 3,994 | false | Welcome to my post! This post starts with "How we think about a solution". In other words, that is my thought process to solve the question. This post explains how I get to my solution instead of just posting solution codes or out of blue algorithms. I hope it is helpful for someone.\n\n# Intuition\nSorting input array... | 99 | 0 | ['C++', 'Java', 'Python3', 'JavaScript'] | 4 |
minimum-number-of-operations-to-make-array-continuous | Simple Solution || Beginner Friendly || Easy to Understand ✅ | simple-solution-beginner-friendly-easy-t-pkim | Approach\n Describe your approach to solving the problem. \n- Sort the input array nums in ascending order.\n- Traverse the sorted array to remove duplicates an | Anirban_Pramanik10 | NORMAL | 2023-10-10T01:46:08.213985+00:00 | 2023-10-10T03:52:11.606213+00:00 | 14,721 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\n- Sort the input array `nums` in ascending order.\n- Traverse the sorted array to remove duplicates and count unique elements in `uniqueLen`.\n- Initialize `ans` to the length of the input array, representing the maximum operations initially.\n- Itera... | 91 | 5 | ['Binary Search', 'C', 'Sliding Window', 'Python', 'C++', 'Java', 'Python3'] | 7 |
minimum-number-of-operations-to-make-array-continuous | [Python] Explanation with Pictures, Binary Search | python-explanation-with-pictures-binary-j2dme | For any valid result, we can focus on the minimum number a in that list, since there are n unique numbers, all the numbers are: a, a + 1, a + 2, ... , a + n - 1 | Bakerston | NORMAL | 2021-09-18T16:02:21.872858+00:00 | 2021-09-25T17:49:34.479126+00:00 | 2,632 | false | For any valid result, we can focus on the minimum number ```a``` in that list, since there are ```n``` unique numbers, all the numbers are: ```a, a + 1, a + 2, ... , a + n - 1```. Traverse the list ```A```, for the current number a, if the result list has ```a``` as the smallest number, we need to find out how many uni... | 63 | 0 | [] | 4 |
minimum-number-of-operations-to-make-array-continuous | [Java] Sort + sliding window | java-sort-sliding-window-by-tobias2code-cxr0 | The intuition is to find the maximum number of distinct elements fitting in a window of length maxNumsInWindow, by iterating over the sorted array. \n=> The rem | tobias2code | NORMAL | 2021-09-18T18:04:02.368715+00:00 | 2021-10-23T10:34:44.550130+00:00 | 4,385 | false | The intuition is to find the maximum number of distinct elements fitting in a window of length `maxNumsInWindow`, by iterating over the sorted array. \n=> The remaining `N - maxNumsInWindow` elements need to be replaced.\n\n\n` numbers. \n\n**C++**\n```cpp\nint minO... | 23 | 3 | [] | 3 |
minimum-number-of-operations-to-make-array-continuous | [Python] How Leetcode (and interviewers) will try to trick you with test cases | python-how-leetcode-and-interviewers-wil-m7fc | Me: "I was so sloppy during today\'s contest. I\'m going to write a discussion post to make myself feel better."\n\nMy girlfriend: "Whatever"\n\n--- \n\nIn this | grawlixes | NORMAL | 2021-09-18T16:00:44.963960+00:00 | 2021-09-18T16:00:44.964001+00:00 | 1,541 | false | Me: "I was so sloppy during today\'s contest. I\'m going to write a discussion post to make myself feel better."\n\nMy girlfriend: "Whatever"\n\n--- \n\nIn this problem, we have to form a consecutive set of numbers `[i, j]` with as many elements from the input array `nums` as possible. Let\'s call the set `[i, j]` with... | 22 | 1 | [] | 0 |
minimum-number-of-operations-to-make-array-continuous | 3C++ using sort &binary search/sliding window/queue||beats 100% | 3c-using-sort-binary-searchsliding-windo-igpc | Intuition\n Describe your first thoughts on how to solve this problem. \n1st method uses binary search.\n2nd method uses sliding windows which runs in 91ms and | anwendeng | NORMAL | 2023-10-10T01:20:08.445577+00:00 | 2023-10-10T05:58:01.148802+00:00 | 2,825 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n1st method uses binary search.\n2nd method uses sliding windows which runs in 91ms and beats 100%.\n3rd method uses queue/deque which is in fact a variant for sliding window.\n\n[Please turn on English subtitle if necessary]\n[https://you... | 17 | 0 | ['Binary Search', 'Queue', 'Sliding Window', 'Sorting', 'C++'] | 1 |
minimum-number-of-operations-to-make-array-continuous | Sort and Sliding Window || C++ || O(NlogN) and O(N) | sort-and-sliding-window-c-onlogn-and-on-ojobp | INTUITION\nElements in the continuous array will be like:i, i+1, i+2, ..., i + arr.size()-1, for some integer i, because, max(arr) - min(arr) = i + arr.size() - | NAHDI51 | NORMAL | 2021-09-21T07:28:45.840545+00:00 | 2021-09-21T17:01:47.845582+00:00 | 1,479 | false | # INTUITION\nElements in the continuous array will be like:``` i, i+1, i+2, ..., i + arr.size()-1```, for some integer i, because, ```max(arr) - min(arr) = i + arr.size() - 1 - i = arr.size()-1,``` which is provided.\n\nThus, we will maintain a sliding window of ```a.size()``` (e.g ```a[i] - a[j] + 1<= a.size()```, the... | 17 | 0 | ['C', 'Sliding Window', 'Sorting'] | 2 |
minimum-number-of-operations-to-make-array-continuous | Easy Sliding Window C++ Solution 180ms | easy-sliding-window-c-solution-180ms-by-2b023 | Important points are added as comments.\n\nclass Solution {\npublic:\n int minOperations(vector<int>& nums) {\n int k = nums.size() - 1; // max size | hrishikesh_deshpande | NORMAL | 2021-10-05T16:29:22.855726+00:00 | 2022-10-17T21:22:31.413286+00:00 | 1,429 | false | Important points are added as comments.\n```\nclass Solution {\npublic:\n int minOperations(vector<int>& nums) {\n int k = nums.size() - 1; // max size of sliding window is the target gap between min and max elements\n sort(nums.begin(), nums.end()); // sorting in O(nlogn) time so that we can remove d... | 15 | 0 | ['C', 'Sliding Window', 'C++'] | 0 |
minimum-number-of-operations-to-make-array-continuous | From Dumb to Pro with Just One Visit-My Promise to You with A Smart Approach to Minimize Operations | from-dumb-to-pro-with-just-one-visit-my-spdi5 | Intuition\n\nThe goal is to determine the minimum number of operations needed to make the numbers consecutive. To do this, we want to find the maximum unique el | curio_sity | NORMAL | 2023-10-10T04:03:27.935499+00:00 | 2023-10-10T04:03:27.935522+00:00 | 2,574 | false | # Intuition\n\nThe goal is to determine the minimum number of operations needed to make the numbers consecutive. To do this, we want to find the maximum unique element within a certain range, specifically from \'n\' to \'n + nums.size() - 1\', where \'n\' can be any element from the array. \n\nThe idea is that if we ch... | 14 | 1 | ['Sliding Window', 'Sorting', 'C++', 'Java', 'Python3'] | 2 |
minimum-number-of-operations-to-make-array-continuous | 100% Beats 🤩 | Java - Sliding Window | | 100-beats-java-sliding-window-by-akhiles-jilb | \n\nHere\'s a step-by-step explanation of the code:\n\n1. The minOperations method takes an array of integers nums as input and returns an integer representing | Akhilesh21 | NORMAL | 2023-10-10T00:53:29.439094+00:00 | 2023-10-10T00:53:29.439112+00:00 | 1,153 | false | \n\nHere\'s a step-by-step explanation of the code:\n\n1. The `minOperations` method takes an array of integers `nums` as input and returns an integer representing the minimum number of operations required to make the array continuous.\n\n2. It starts by sorting the input array `nums` in ascending order using `Arrays.s... | 14 | 0 | ['Sliding Window', 'Java'] | 1 |
minimum-number-of-operations-to-make-array-continuous | simple c++ solution || Beginner Friendly || Sorting+Binary search | simple-c-solution-beginner-friendly-sort-mw3c | \n# Approach\n Describe your approach to solving the problem. \nour target is make continuous array \nmax element - min element = array size - 1\nif array size | utkarshR_Patel | NORMAL | 2023-10-10T08:42:47.892261+00:00 | 2023-10-10T08:42:47.892279+00:00 | 1,077 | false | \n# Approach\n<!-- Describe your approach to solving the problem. -->\nour target is make continuous array \nmax element - min element = array size - 1\nif array size 5 possible array [1,2,3,4,5] , [2,3,4,5,6] , [3,4,5,6,7] etc\n\n \npossible answer range \narray is already continuous answer=>0 \narray all number are r... | 11 | 0 | ['Binary Search', 'Sorting', 'C++'] | 1 |
minimum-number-of-operations-to-make-array-continuous | Detailed explanation | Sorting + Binary Search | detailed-explanation-sorting-binary-sear-4c23 | \nClearly, if input array is of length n, then our final continuous array must be of form:\n\n[start, start + 1, ... start + n - 1], where start is some startin | khaufnak | NORMAL | 2021-09-18T16:00:35.325383+00:00 | 2021-09-18T16:05:32.388641+00:00 | 776 | false | \nClearly, if input array is of length ```n```, then our final continuous array must be of form:\n\n[start, start + 1, ... start + n - 1], where ```start``` is some starting element. \n\nKey idea: We can ```start``` our final continuous array from one of the given elements of the input array to get the minimum operatio... | 11 | 3 | [] | 2 |
minimum-number-of-operations-to-make-array-continuous | O(1) Space || O(nlogn) Time || Sort --> Binary Search | o1-space-onlogn-time-sort-binary-search-fqa7q | Complexity\n- Time complexity:\nO(nlogn) Add your time complexity here, e.g. O(n) \n\n- Space complexity:\nO(1) Add your space complexity here, e.g. O(n) \n\n# | abhijeet5000kumar | NORMAL | 2023-10-10T15:11:56.401503+00:00 | 2023-10-10T15:13:16.701979+00:00 | 697 | false | # Complexity\n- Time complexity:\n$$O(nlogn)$$<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n$$O(1)$$<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n int minOperations(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n ... | 9 | 1 | ['Array', 'Binary Search', 'Sliding Window', 'Sorting', 'C++'] | 0 |
minimum-number-of-operations-to-make-array-continuous | [Python] Simple sort & queue, 2-liner | python-simple-sort-queue-2-liner-by-vu-d-yavy | Intuition\n\nThe continuous array that the problem asks for is simply an array with the form [x, x + 1, x + 2, x + 3, ..., x + n - 1], but scrambled. Let\'s cal | vu-dinh-hung | NORMAL | 2023-10-10T00:37:36.883632+00:00 | 2023-10-10T00:51:18.545987+00:00 | 627 | false | # Intuition\n\nThe continuous array that the problem asks for is simply an array with the form `[x, x + 1, x + 2, x + 3, ..., x + n - 1]`, but scrambled. Let\'s call that original sorted form **sorted continuous**.\n\nTo simplify the problem, we simply need to find the longest incomplete **sorted continuous** array fro... | 9 | 0 | ['Queue', 'Python3'] | 2 |
minimum-number-of-operations-to-make-array-continuous | ✅ C++ naive solution that works 😎 | c-naive-solution-that-works-by-tyrex_19-d5zm | Intuition\n\nThe idea is to remove duplicates from the array \u2728, then use a brute force approach where you consider each element as the minimum of the resul | Tyrex_19 | NORMAL | 2023-10-10T04:51:10.999553+00:00 | 2023-10-10T05:59:29.787900+00:00 | 1,203 | false | # Intuition\n\nThe idea is to remove duplicates from the array \u2728, then use a brute force approach where you consider each element as the minimum of the resulting array \uD83D\uDE0E. The goal is to find how many elements you should add to make the condition of continuity respected \uD83D\uDD04. By evaluating each e... | 8 | 2 | ['C++'] | 3 |
minimum-number-of-operations-to-make-array-continuous | Easy To Understand || Sliding Window || C++ || Java | easy-to-understand-sliding-window-c-java-7i3b | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nSorting and Removing Duplicates:\nFirst, the code sorts the input array n | me_avi | NORMAL | 2023-10-10T03:17:02.597387+00:00 | 2023-10-10T03:17:02.597419+00:00 | 1,165 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nSorting and Removing Duplicates:\nFirst, the code sorts the input array nums in ascending order. This is done to make it easier to find the maximum and minimum elements.\nIt also removes any duplicate elements, ensuring that... | 7 | 0 | ['C++', 'Java', 'Python3'] | 0 |
minimum-number-of-operations-to-make-array-continuous | 100% Beats 🤩 | Java | C++ | Sliding Window | | 100-beats-java-c-sliding-window-by-akhil-b0ti | Java 100 % Beats\nC++ 87 % Beats\n\n# Java\nHere\'s a step-by-step explanation of the code:\n\n1. The minOperations method takes an array of integers nums as in | Akhilesh21 | NORMAL | 2023-10-10T01:16:26.221468+00:00 | 2023-10-10T01:17:10.858779+00:00 | 153 | false | Java 100 % Beats\nC++ 87 % Beats\n\n# Java\nHere\'s a step-by-step explanation of the code:\n\n1. The `minOperations` method takes an array of integers `nums` as input and returns an integer representing the minimum number of operations required to make the array continuous.\n\n2. It starts by sorting the input array `... | 7 | 0 | ['Sliding Window', 'C++', 'Java'] | 0 |
minimum-number-of-operations-to-make-array-continuous | [Python3] sliding window | python3-sliding-window-by-ye15-zjvp | Please check out this commit for the solutions of biweekly 61. \n\nclass Solution:\n def minOperations(self, nums: List[int]) -> int:\n n = len(nums)\ | ye15 | NORMAL | 2021-09-18T21:40:54.774119+00:00 | 2021-09-18T22:25:25.089140+00:00 | 608 | false | Please check out this [commit](https://github.com/gaosanyong/leetcode/commit/0dcbb71853720dc380becdd8968bf94bdf419b7d) for the solutions of biweekly 61. \n```\nclass Solution:\n def minOperations(self, nums: List[int]) -> int:\n n = len(nums)\n nums = sorted(set(nums))\n \n ans = ii = 0\n... | 7 | 1 | ['Python3'] | 1 |
minimum-number-of-operations-to-make-array-continuous | Simple java logic | simple-java-logic-by-ramudarsingh46-todd | 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 | ramudarsingh46 | NORMAL | 2023-10-10T15:00:39.868745+00:00 | 2023-10-10T15:00:39.868777+00:00 | 16 | 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)$$ --... | 6 | 0 | ['Java'] | 0 |
minimum-number-of-operations-to-make-array-continuous | C++ || Basic Beginners Approach || My Notes || Detailed Solution || Easy to Understand | c-basic-beginners-approach-my-notes-deta-iugd | Approach\n Describe your approach to solving the problem. \n\n\n\n\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nN*log(M)\n\n# Code\n\nclass | vaibhav_chachra | NORMAL | 2023-10-10T05:34:51.723937+00:00 | 2023-10-10T05:34:51.723968+00:00 | 545 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\n\n\n\n\n\n# Complexity\n- Tim... | 6 | 0 | ['Binary Search', 'Sorting', 'C++'] | 1 |
minimum-number-of-operations-to-make-array-continuous | Prefix Sum Solution. TC: O(NLog(N)) SC: O(N) | prefix-sum-solution-tc-onlogn-sc-on-by-1-gm6s | Since the array must be continuous, if the array starts with an element a, it will be continuous, and the last element will be a + size of the array - 1.\n\nWe | 1mknown | NORMAL | 2022-06-06T19:59:46.728495+00:00 | 2022-06-06T20:02:05.108790+00:00 | 619 | false | Since the array must be continuous, if the array starts with an element a, it will be continuous, and the last element will be a + size of the array - 1.\n\nWe can try to find an optimal starting position \'a\' for which we will need to change as few elements of the array as possible.\n\nTo do that, let us create an or... | 6 | 0 | ['C', 'Prefix Sum'] | 3 |
minimum-number-of-operations-to-make-array-continuous | Easy to understand || Concise C++ Solution || Sliding Window | easy-to-understand-concise-c-solution-sl-vftb | Intuition\nThe idea is to find the minimum number of operations to make the array continuous by removing elements while maintaining uniqueness.\n# Approach\n1. | Ankita_Chaturvedi | NORMAL | 2023-10-10T02:17:27.013881+00:00 | 2023-10-10T02:17:27.013902+00:00 | 692 | false | # Intuition\nThe idea is to find the minimum number of operations to make the array continuous by removing elements while maintaining uniqueness.\n# Approach\n1. Create a set to ensure uniqueness.\n2. Find unique elements from the input array.\n3. Iterate through unique elements to form a consecutive subarray.\n4. Calc... | 5 | 1 | ['Sliding Window', 'C++'] | 0 |
minimum-number-of-operations-to-make-array-continuous | Beats 100% on runtime [EXPLAINED] | beats-100-on-runtime-explained-by-r9n-l1zl | Intuition\nMake the array continuous by ensuring all numbers are unique and that they span a range equal to their count. This can be achieved by replacing eleme | r9n | NORMAL | 2024-10-22T05:18:53.723631+00:00 | 2024-10-22T05:18:53.723665+00:00 | 22 | false | # Intuition\nMake the array continuous by ensuring all numbers are unique and that they span a range equal to their count. This can be achieved by replacing elements in the array while minimizing the number of replacements needed.\n\n# Approach\nUse a sliding window technique to find the longest subsequence of unique n... | 4 | 0 | ['C#'] | 0 |
minimum-number-of-operations-to-make-array-continuous | Sliding Window -Intuitive -C++ Solution. | sliding-window-intuitive-c-solution-by-m-3i5r | Intuition\nConvert the problem into a known problem which can be a little intuitive here.\nSort the array first.. Now we can reduce the problem to some extent b | mitthunkrishna | NORMAL | 2023-10-10T02:17:45.688586+00:00 | 2023-10-10T17:50:54.217897+00:00 | 339 | false | # Intuition\nConvert the problem into a known problem which can be a little intuitive here.\nSort the array first.. Now we can reduce the problem to some extent by just checking the window which has maximum number of elements where the maximum element and the minimum element in the array is <= (n-1).\n\n\nExample :-\n ... | 4 | 0 | ['C++'] | 0 |
minimum-number-of-operations-to-make-array-continuous | 🗓️ Daily LeetCoding Challenge October, Day 10 | daily-leetcoding-challenge-october-day-1-adyh | This problem is the Daily LeetCoding Challenge for October, Day 10. Feel free to share anything related to this problem here! You can ask questions, discuss wha | leetcode | OFFICIAL | 2023-10-10T00:00:06.335509+00:00 | 2023-10-10T00:00:06.335535+00:00 | 2,495 | false | This problem is the Daily LeetCoding Challenge for October, Day 10.
Feel free to share anything related to this problem here!
You can ask questions, discuss what you've learned from this problem, or show off how many days of streak you've made!
---
If you'd like to share a detailed solution to the problem, please c... | 4 | 0 | [] | 16 |
minimum-number-of-operations-to-make-array-continuous | c++ silding Window | c-silding-window-by-solvedorerror-1zgg | Intution:-\n1.First i will sort the array, and make a new non repeating array in sorted form.\n2.From each value in "non-repeating-array" , I will try to find o | solvedORerror | NORMAL | 2022-10-26T18:16:22.639865+00:00 | 2022-10-26T18:16:22.639911+00:00 | 1,068 | false | **Intution:-**\n1.First i will sort the array, and make a new non repeating array in sorted form.\n2.From each value in "non-repeating-array" , I will try to find out maximum possible elements in continous array, if formed from that element.\n```\nclass Solution {\npublic:\n int minOperations(vector<int>& nums) {\n ... | 4 | 0 | ['Sorting'] | 0 |
minimum-number-of-operations-to-make-array-continuous | C++ | Simple Binary Search | c-simple-binary-search-by-av1shek-byy1 | \nclass Solution {\npublic:\n int minOperations(vector<int>& nums) {\n int n = nums.size();\n sort(nums.begin(), nums.end());\n nums.res | av1shek | NORMAL | 2022-08-04T03:27:03.922132+00:00 | 2022-08-04T03:27:03.922172+00:00 | 566 | false | ```\nclass Solution {\npublic:\n int minOperations(vector<int>& nums) {\n int n = nums.size();\n sort(nums.begin(), nums.end());\n nums.resize(unique(nums.begin(), nums.end()) - nums.begin());\n \n int ans = INT_MAX;\n for(int i=0; i<nums.size(); i++)\n {\n ... | 4 | 0 | ['Binary Search', 'C', 'Binary Tree'] | 0 |
minimum-number-of-operations-to-make-array-continuous | C++ Solution, unique and queue. | c-solution-unique-and-queue-by-chejianch-05yy | \n### Idea\n- make a new array with all unique element and sort.\n- keep pushing an element into queue, and pop out the front element which is queue.back() - qu | chejianchao | NORMAL | 2021-09-18T16:00:33.644704+00:00 | 2021-09-18T16:04:22.704854+00:00 | 385 | false | \n### Idea\n- make a new array with all unique element and sort.\n- keep pushing an element into queue, and pop out the front element which is `queue.back() - queue.front() > n -1`, these elements in the queue are guaranteed that we don\'t need to change.\n- answer is n - queue.size();\n\n```\nclass Solution {\npublic:... | 4 | 1 | [] | 1 |
minimum-number-of-operations-to-make-array-continuous | Easy Solution | Binary Search Solution with Explanation | easy-solution-binary-search-solution-wit-8yrm | Intuition\n Describe your first thoughts on how to solve this problem. \n- There should have a range of numbers after replacing the numbers if needed. \n- Findi | KhaledAhmmedAnik | NORMAL | 2023-10-10T18:35:04.377242+00:00 | 2023-10-11T08:13:34.081305+00:00 | 37 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- There should have a **range** of numbers after replacing the numbers if needed. \n- Finding the end value will be easy if we can find the start value\n- The **end value** will be **(starting value + array length - 1)** to match with the... | 3 | 0 | ['C++'] | 2 |
minimum-number-of-operations-to-make-array-continuous | 🔥💥Simple C++ Solution using Sliding Window 💥🔥 | simple-c-solution-using-sliding-window-b-n1jx | Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem revolves around finding the minimum number of operations required to reduce | eknath_mali_002 | NORMAL | 2023-10-10T05:14:31.317616+00:00 | 2023-10-10T05:14:31.317665+00:00 | 199 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem revolves around finding the minimum number of operations required to reduce an array to a unique element by repeatedly choosing an element and reducing its value. The approach involves sorting the array, removing duplicates, a... | 3 | 0 | ['Binary Search', 'Sliding Window', 'Ordered Set', 'C++'] | 0 |
minimum-number-of-operations-to-make-array-continuous | [C++] Sliding Window on the Sorted and Unique Array | c-sliding-window-on-the-sorted-and-uniqu-0f6r | Intuition\n Describe your first thoughts on how to solve this problem. \nFind the maximum window that meets the problem\'s conditions.\n\n# Approach\n Describe | pepe-the-frog | NORMAL | 2023-10-10T04:40:11.367257+00:00 | 2023-10-10T04:40:11.367284+00:00 | 1,510 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFind the maximum window that meets the problem\'s conditions.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n* get the sorted and unique integers\n* slide the window within a valid range\n\n# Complexity\n- Time co... | 3 | 0 | ['Sliding Window', 'Sorting', 'C++'] | 0 |
minimum-number-of-operations-to-make-array-continuous | C++ || Binary search || Explained | c-binary-search-explained-by-amol_2004-b0cl | \n# Approach\n Describe your approach to solving the problem. \n- sort the array and remove all the dublicate element\n- For every index do a binary search to g | amol_2004 | NORMAL | 2023-10-10T04:32:00.038877+00:00 | 2023-10-10T04:32:00.038905+00:00 | 235 | false | \n# Approach\n<!-- Describe your approach to solving the problem. -->\n- sort the array and remove all the dublicate element\n- For every index do a binary search to get the possible right end of the window and calculate the possible answer.\n\n# Complexity\n- Time complexity: $$O(nlogn)$$\n<!-- Add your time complexit... | 3 | 0 | ['Array', 'Binary Search', 'C++'] | 1 |
minimum-number-of-operations-to-make-array-continuous | Easyiest Solution | easyiest-solution-by-vaibhav0077-aicv | \nclass Solution:\n def minOperations(self, nums: List[int]) -> int:\n \n n = len(nums)\n arr = sorted(set(nums))\n\n j = 0\n | vaibhav0077 | NORMAL | 2023-10-10T04:09:08.292183+00:00 | 2023-10-10T04:09:08.292202+00:00 | 53 | false | ```\nclass Solution:\n def minOperations(self, nums: List[int]) -> int:\n \n n = len(nums)\n arr = sorted(set(nums))\n\n j = 0\n for item in arr:\n j += item - arr[j] > n-1\n\n return j + n - len(arr)\n``` | 3 | 0 | ['Python', 'Python3'] | 0 |
minimum-number-of-operations-to-make-array-continuous | 💡Swift - Optimal Solution - Sliding Window | swift-optimal-solution-sliding-window-by-hbpv | Solution\nswift\nclass Solution {\n func minOperations(_ nums: [Int]) -> Int {\n // There is no point in using duplicated numbers since we\'re require | bernikovich | NORMAL | 2023-10-10T03:06:31.964937+00:00 | 2023-10-11T01:08:11.137001+00:00 | 138 | false | # Solution\n```swift\nclass Solution {\n func minOperations(_ nums: [Int]) -> Int {\n // There is no point in using duplicated numbers since we\'re required to\n // perform an operation on them anyway.\n let uniqueNums = Array(Set(nums)).sorted()\n let n = uniqueNums.count\n\n var ... | 3 | 0 | ['Swift', 'Sliding Window'] | 0 |
minimum-number-of-operations-to-make-array-continuous | python3 Solution | python3-solution-by-motaharozzaman1996-jsa2 | \n\nclass Solution:\n def minOperations(self, nums: List[int]) -> int:\n n=len(nums)\n nums=sorted(set(nums))\n ans=sys.maxsize\n | Motaharozzaman1996 | NORMAL | 2023-10-10T02:58:33.184279+00:00 | 2023-10-10T02:58:33.184354+00:00 | 127 | false | \n```\nclass Solution:\n def minOperations(self, nums: List[int]) -> int:\n n=len(nums)\n nums=sorted(set(nums))\n ans=sys.maxsize\n for i,s in enumerate(nums):\n e=s+n-1\n idx=bisect_right(nums,e)\n ans=min(ans,n-idx+i)\n return ans \n``` | 3 | 0 | ['Python', 'Python3'] | 0 |
minimum-number-of-operations-to-make-array-continuous | Rust | 25ms | 6 lines | rust-25ms-6-lines-by-rbird111-zhz0 | Code\nrust\nimpl Solution {\n pub fn min_operations(mut nums: Vec<i32>) -> i32 {\n let n = nums.len() as i32;\n nums.sort_unstable();\n | RBird111 | NORMAL | 2023-10-10T01:41:52.901474+00:00 | 2023-10-10T01:41:52.901491+00:00 | 80 | false | # Code\n```rust\nimpl Solution {\n pub fn min_operations(mut nums: Vec<i32>) -> i32 {\n let n = nums.len() as i32;\n nums.sort_unstable();\n nums.dedup();\n nums.iter().enumerate().fold(n, |ops, (i, l)| {\n ops.min(n - (nums.partition_point(|&m| m < l + n) - i) as i32)\n ... | 3 | 0 | ['Rust'] | 1 |
minimum-number-of-operations-to-make-array-continuous | Minimum Number of Operations to Make Array Continuous | minimum-number-of-operations-to-make-arr-niih | Code\n\nvar minOperations = function(nums) {\n const n = nums.length;\n const set = new Set(nums);\n const distinctNums = Array.from(set).sort((a, b) = | dhruvabhat | NORMAL | 2023-10-10T01:38:41.058724+00:00 | 2023-10-10T01:38:41.058743+00:00 | 317 | false | # Code\n```\nvar minOperations = function(nums) {\n const n = nums.length;\n const set = new Set(nums);\n const distinctNums = Array.from(set).sort((a, b) => a - b);\n const targetLen = distinctNums.length;\n\n let left = 0;\n let right = 0;\n let maxLen = 0;\n\n while (right < targetLen) {\n ... | 3 | 0 | ['JavaScript'] | 0 |
minimum-number-of-operations-to-make-array-continuous | Python 3 binary search O(nlogn) simple solution | python-3-binary-search-onlogn-simple-sol-jvz2 | \nimport bisect\nclass Solution:\n def minOperations(self, nums: List[int]) -> int:\n n=len(nums)\n nums=list(set(nums))\n nums.sort()\n | saisanjith15 | NORMAL | 2022-05-01T09:58:31.365875+00:00 | 2022-05-01T09:58:31.365905+00:00 | 217 | false | ```\nimport bisect\nclass Solution:\n def minOperations(self, nums: List[int]) -> int:\n n=len(nums)\n nums=list(set(nums))\n nums.sort()\n minn=float(\'inf\')\n for i,val in enumerate(nums):\n index=bisect_right(nums,val+n-1)\n minn=min(minn,n-(index-i))\n ... | 3 | 0 | ['Binary Search'] | 0 |
minimum-number-of-operations-to-make-array-continuous | C++ | SET | IMPLEMENTATION | c-set-implementation-by-chikzz-1pzh | \nclass Solution {\npublic:\n int minOperations(vector<int>& nums) {\n \n //length of the initial array\n int len=nums.size();\n | chikzz | NORMAL | 2021-12-19T15:15:38.652885+00:00 | 2021-12-19T15:15:38.652928+00:00 | 475 | false | ```\nclass Solution {\npublic:\n int minOperations(vector<int>& nums) {\n \n //length of the initial array\n int len=nums.size();\n \n //remove duplicate elements and sort them\n set<int>S;\n for(auto &x:nums)\n S.insert(x);\n \n vector<int>te... | 3 | 0 | ['Sorting', 'Ordered Set'] | 1 |
minimum-number-of-operations-to-make-array-continuous | C++, Easy to understand, well commented, Binary Search, Sorting | c-easy-to-understand-well-commented-bina-lkr8 | \n// Problem Link : https://leetcode.com/problems/minimum-number-of-operations-to-make-array-continuous/\nclass Solution {\npublic:\n // Binary Search\n / | prit_manvar | NORMAL | 2021-12-09T08:17:21.134963+00:00 | 2021-12-09T08:17:21.134996+00:00 | 377 | false | ```\n// Problem Link : https://leetcode.com/problems/minimum-number-of-operations-to-make-array-continuous/\nclass Solution {\npublic:\n // Binary Search\n // it will give index of target and if target is not present then it will give largest element which is smaller than target\n int bsearch(vector<int>& nums... | 3 | 0 | ['Binary Search', 'Sorting'] | 0 |
minimum-number-of-operations-to-make-array-continuous | Using Ordered Set | C++ | O(nlogn) | using-ordered-set-c-onlogn-by-narayanban-3frk | The time complexity is high but easy to understand.\nEvery time we just go to every element and find how many elements we need to change to make the array conti | narayanbansal35 | NORMAL | 2021-10-08T18:45:53.143903+00:00 | 2021-10-08T18:46:45.812154+00:00 | 318 | false | The time complexity is high but easy to understand.\nEvery time we just go to every element and find how many elements we need to change to make the array contiguous which can easily be achived using the ordered_set \n```\n#include <ext/pb_ds/assoc_container.hpp>\n#include <ext/pb_ds/tree_policy.hpp>\nusing namespace _... | 3 | 0 | ['C', 'Ordered Set'] | 0 |
minimum-number-of-operations-to-make-array-continuous | SLIDING WINDOW | sliding-window-by-mk_kr_24-qs0g | \nclass Solution {\npublic:\n int minOperations(vector<int>& nums) {\n set<int> s;\n for(int i: nums)\n s.insert(i);\n int l1 | mk_kr_24 | NORMAL | 2021-09-25T11:22:56.283744+00:00 | 2021-09-25T11:22:56.283774+00:00 | 176 | false | ```\nclass Solution {\npublic:\n int minOperations(vector<int>& nums) {\n set<int> s;\n for(int i: nums)\n s.insert(i);\n int l1= nums.size();\n int ans= l1;\n int l2= s.size();\n set<int>:: iterator itr1;\n itr1= s.begin();\n int i= 0, j= 0;\n ... | 3 | 0 | [] | 0 |
minimum-number-of-operations-to-make-array-continuous | Java Set+Sorting+Binary Search | java-setsortingbinary-search-by-yashoda_-c6fx | \nclass Solution {\n public int minOperations(int[] nums) {\n //get unique elemets\n Set<Integer> set=new HashSet();\n for(int i:nums)\n | yashoda_agrawal | NORMAL | 2021-09-19T06:02:06.873778+00:00 | 2021-09-19T06:02:06.873824+00:00 | 175 | false | ```\nclass Solution {\n public int minOperations(int[] nums) {\n //get unique elemets\n Set<Integer> set=new HashSet();\n for(int i:nums)\n {\n set.add(i);\n }\n int[] res=new int[set.size()];\n int in=0;\n for(int i:set)\n {\n res[... | 3 | 0 | [] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.