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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
find-the-array-concatenation-value | Beat 95.65% 55ms Python3 two pointer | beat-9565-55ms-python3-two-pointer-by-am-i87w | \n\n# Code\n\nclass Solution:\n def findTheArrayConcVal(self, nums: List[int]) -> int:\n i, j, count = 0, len(nums)-1, 0\n while i <= j:\n | amitpandit03 | NORMAL | 2023-03-06T16:53:25.480533+00:00 | 2023-03-06T16:53:32.287885+00:00 | 37 | false | \n\n# Code\n```\nclass Solution:\n def findTheArrayConcVal(self, nums: List[int]) -> int:\n i, j, count = 0, len(nums)-1, 0\n while i <= j:\n if i != j: count += int(str(nums[i]) + str(nums[j]))\n else: count += nums[j]\n i += 1\n j -= 1\n return count... | 1 | 0 | ['Array', 'Two Pointers', 'Simulation', 'Python3'] | 0 |
find-the-array-concatenation-value | Simple Java Solution 0ms | beats 100% | two pointer approach and No conversion to String needed | simple-java-solution-0ms-beats-100-two-p-mb79 | Intuition\nUse the two pointer approach to iterate through the array from both ends and conactenate the correspinding numbers till start<end.\n\nNote: please ma | ayushprakash1912 | NORMAL | 2023-02-19T06:06:31.363565+00:00 | 2023-02-19T06:06:31.363619+00:00 | 10 | false | # Intuition\nUse the two pointer approach to iterate through the array from both ends and conactenate the correspinding numbers till start<end.\n\n**Note: please make sure to use \'long\' variable while adding otherwise theoutput will overflow.**\n\n# Approach\n1. Place two pointers and both left and right end of the a... | 1 | 0 | ['Java'] | 0 |
find-the-array-concatenation-value | Use StringBuilder to solve | use-stringbuilder-to-solve-by-niok-as2r | 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 | Niok | NORMAL | 2023-02-18T06:03:16.319923+00:00 | 2023-02-18T06:03:16.319953+00:00 | 648 | 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)$$ --... | 1 | 0 | ['Java'] | 1 |
find-the-array-concatenation-value | Simple Python Solution | simple-python-solution-by-saiavunoori418-2ssy | \n\nSolution:\n\nclass Solution:\n def findTheArrayConcVal(self, nums: List[int]) -> int:\n conc = 0\n if len(nums) == 1:\n return n | saiavunoori4187 | NORMAL | 2023-02-18T05:22:29.309346+00:00 | 2023-02-18T05:22:29.309396+00:00 | 78 | false | \n\nSolution:\n\n```class Solution:\n def findTheArrayConcVal(self, nums: List[int]) -> int:\n conc = 0\n if len(nums) == 1:\n return nums[0]\n while len(nums)>1:\n temp = int(str(nums[0])+str(nums[-1]))\n conc+=temp\n nums = nums[1:len(nums)-1]\n ... | 1 | 0 | [] | 0 |
find-the-array-concatenation-value | One-for solution | one-for-solution-by-ods967-7k4b | Code\n\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar findTheArrayConcVal = function(nums) {\n let res = 0;\n for (let i = 0; i < nums.len | ods967 | NORMAL | 2023-02-17T04:49:50.249762+00:00 | 2023-02-17T04:49:50.249903+00:00 | 95 | false | # Code\n```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar findTheArrayConcVal = function(nums) {\n let res = 0;\n for (let i = 0; i < nums.length / 2; i++) {\n const rightIndex = nums.length - 1 - i;\n res += i === rightIndex ? nums[i] : Number(\'\' + nums[i] + nums[rightIndex]);\n ... | 1 | 0 | ['JavaScript'] | 0 |
find-the-array-concatenation-value | JavaScript | Two pointer | O(n) | javascript-two-pointer-on-by-akey_9-07pz | Approach\n Describe your approach to solving the problem. \nTwo pointer\n\n# Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n | akey_9 | NORMAL | 2023-02-13T13:37:17.554923+00:00 | 2023-02-13T13:37:17.554968+00:00 | 94 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\nTwo pointer\n\n# 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 - I\n```\n/**\n * @param {number[]} nums\n * @ret... | 1 | 0 | ['Two Pointers', 'JavaScript'] | 0 |
find-the-array-concatenation-value | Simple JavaScript | simple-javascript-by-dsinkey-1yt2 | 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 | dsinkey | NORMAL | 2023-02-12T14:48:03.805149+00:00 | 2023-02-12T14:48:03.805184+00:00 | 280 | 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)$$ --... | 1 | 0 | ['JavaScript'] | 0 |
find-the-array-concatenation-value | Beats 100 % || 2 lines || 39ms | beats-100-2-lines-39ms-by-codequeror-65dr | Upvote it\n\nclass Solution:\n def findTheArrayConcVal(self, nums: List[int]) -> int:\n ans = sum(int(str(nums[i]) + str(nums[len(nums) - 1 - i])) for | Codequeror | NORMAL | 2023-02-12T13:07:09.460195+00:00 | 2023-02-12T13:07:09.460226+00:00 | 8 | false | # Upvote it\n```\nclass Solution:\n def findTheArrayConcVal(self, nums: List[int]) -> int:\n ans = sum(int(str(nums[i]) + str(nums[len(nums) - 1 - i])) for i in range(len(nums) // 2))\n return ans if len(nums) % 2 == 0 else ans + nums[len(nums) // 2]\n``` | 1 | 0 | ['Python3'] | 0 |
find-the-array-concatenation-value | Simple solution using String || Beginner Friendly || JAVA | simple-solution-using-string-beginner-fr-6h0j | \n\n# Code\n\nclass Solution {\n public long findTheArrayConcVal(int[] nums) {\n long out=0;\n\n for(int i=0;i<nums.length/2;i++)\n | PAPPURAJ | NORMAL | 2023-02-12T12:48:43.571756+00:00 | 2023-02-12T12:48:43.571787+00:00 | 115 | false | \n\n# Code\n```\nclass Solution {\n public long findTheArrayConcVal(int[] nums) {\n long out=0;\n\n for(int i=0;i<nums.length/2;i++)\n out+=Long.parseLong(String.valueOf(nums[i])+String.valueOf(nums[nums.length-1-i]));\n if(nums.length%2==1)\n out+=nums[nums.length/2];\n ... | 1 | 0 | ['Java'] | 0 |
find-the-array-concatenation-value | Beats 100% Speed easy Python solution | beats-100-speed-easy-python-solution-by-7wiqn | 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 | Pavellver | NORMAL | 2023-02-12T11:13:41.918978+00:00 | 2023-02-12T11:13:41.919040+00:00 | 68 | 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)$$ --... | 1 | 0 | ['Python3'] | 0 |
find-the-array-concatenation-value | Simple Easy Python Solution | simple-easy-python-solution-by-debasish3-77ke | Runtime: 62 ms, faster than 66.67% of Python3 online submissions for Find the Array Concatenation Value.\n\nMemory Usage: 14.1 MB, less than 61.11% of Python3 o | Debasish365 | NORMAL | 2023-02-12T09:29:04.984632+00:00 | 2023-02-12T09:29:04.984673+00:00 | 19 | false | Runtime: 62 ms, faster than 66.67% of Python3 online submissions for Find the Array Concatenation Value.\n\nMemory Usage: 14.1 MB, less than 61.11% of Python3 online submissions for Find the Array Concatenation Value.\n\n\n```class Solution:\n def findTheArrayConcVal(self, nums: List[int]) -> int:\n l = len(n... | 1 | 0 | [] | 0 |
find-the-array-concatenation-value | 4 Solutions || Brute >> Better >> Optimal || c++ || Faster than 100% || 0ms | 4-solutions-brute-better-optimal-c-faste-p1uy | Intuition\n\nwe need to concatinate the first and last digits \nfor example [7,52,2,4]\nans = 522 + 14 = 596 ;\nso 52 and 2 make 522 by (52 * 100) + 2\nsimilar | ketansarna | NORMAL | 2023-02-12T08:03:15.571875+00:00 | 2023-02-12T08:03:15.571911+00:00 | 159 | false | # Intuition\n\nwe need to concatinate the first and last digits \nfor example [7,52,2,4]\nans = 522 + 14 = 596 ;\nso 52 and 2 make 522 by (52 * 100) + 2\nsimilarly \nfor 7 and 4 \n(7 * 10) + 4 = 74\n\nin colclusion we just need to find the power of 10 which we need to multiply the first digit \n\n\n\n# Approach 1 \n//... | 1 | 0 | ['C++'] | 0 |
find-the-array-concatenation-value | 100% Fast Easy Simple C++ Solution ✔✔ | 100-fast-easy-simple-c-solution-by-akank-7y6b | 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 | akanksha984 | NORMAL | 2023-02-12T07:26:55.633954+00:00 | 2023-02-12T07:26:55.633987+00:00 | 40 | 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 {\npublic:\n long long findTheArrayConcVal(vector<int>& nums) {\n long long ans=0;\n i... | 1 | 0 | ['Array', 'Math', 'Two Pointers', 'String', 'C++'] | 0 |
find-the-array-concatenation-value | Easy Solution || C++ | easy-solution-c-by-kd_5304-237k | Code\n\n#define ll long long\nclass Solution {\npublic:\n ll concat(int a,int b){\n int c=b,d=1;\n while(c!=0){\n d*=10;\n | kd_5304 | NORMAL | 2023-02-12T05:39:00.531438+00:00 | 2023-02-12T05:39:00.531493+00:00 | 105 | false | # Code\n```\n#define ll long long\nclass Solution {\npublic:\n ll concat(int a,int b){\n int c=b,d=1;\n while(c!=0){\n d*=10;\n c/=10;\n }\n return (ll)(a*d+b);\n }\n ll findTheArrayConcVal(vector<int>& nums) {\n ll ans=0; int l=nums.size();\n if(... | 1 | 0 | ['Array', 'Math', 'C++'] | 0 |
find-the-array-concatenation-value | very easy java solution | very-easy-java-solution-by-logesh_7-0ads | \nclass Solution {\n public long findTheArrayConcVal(int[] nums) {\n ArrayList<Integer>a=new ArrayList();\n for(int x:nums){\n a.add | logesh_7_ | NORMAL | 2023-02-12T05:24:50.388283+00:00 | 2023-02-12T05:24:50.388323+00:00 | 24 | false | ```\nclass Solution {\n public long findTheArrayConcVal(int[] nums) {\n ArrayList<Integer>a=new ArrayList();\n for(int x:nums){\n a.add(x);\n \n }\n long sum=0;\n String b="";\n while(a.size()>0){\n if(a.size()>1){\n b+=a.get(0... | 1 | 0 | ['Java'] | 0 |
find-the-array-concatenation-value | c++ | c-by-prabhdeep0007-e107 | ~~~\nclass Solution {\npublic:\n long long findTheArrayConcVal(vector& nums) {\n long long n=nums.size(),ans=0;\n for(int i=0;i<n/2;i++)\n | prabhdeep0007 | NORMAL | 2023-02-12T05:24:33.372168+00:00 | 2023-02-12T05:24:33.372206+00:00 | 16 | false | ~~~\nclass Solution {\npublic:\n long long findTheArrayConcVal(vector<int>& nums) {\n long long n=nums.size(),ans=0;\n for(int i=0;i<n/2;i++)\n {\n string s1=to_string(nums[i]);\n string s2=to_string(nums[n-i-1]);\n s1=s1+s2;\n cout<<s1<<endl;\n ... | 1 | 0 | ['C'] | 0 |
find-the-array-concatenation-value | Easiest C++ solution using single for loop | easiest-c-solution-using-single-for-loop-f3b7 | 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 | vishu_0123 | NORMAL | 2023-02-12T04:58:57.495794+00:00 | 2023-02-12T04:58:57.495847+00:00 | 38 | 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)$$ --... | 1 | 0 | ['C++'] | 0 |
find-the-array-concatenation-value | Simple C++| | string to int | | int to string conversion | simple-c-string-to-int-int-to-string-con-cxyf | \n# Approach\nuse two pointer technique to solve the problem\n Describe your approach to solving the problem. \n\n# Complexity\n- Time complexity: O(n*n)\n Add | yashpal_97 | NORMAL | 2023-02-12T04:46:01.047037+00:00 | 2023-02-12T04:46:01.047081+00:00 | 55 | false | \n# Approach\nuse two pointer technique to solve the problem\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n*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... | 1 | 0 | ['C++'] | 0 |
find-the-array-concatenation-value | [Python3] simulation | python3-simulation-by-ye15-6rbp | \n\nclass Solution:\n def findTheArrayConcVal(self, nums: List[int]) -> int:\n n = len(nums)\n ans = 0 \n for i in range((n+1)//2): \n | ye15 | NORMAL | 2023-02-12T04:38:14.718112+00:00 | 2023-02-12T04:38:14.718140+00:00 | 214 | false | \n```\nclass Solution:\n def findTheArrayConcVal(self, nums: List[int]) -> int:\n n = len(nums)\n ans = 0 \n for i in range((n+1)//2): \n if i == n-1-i: ans += nums[i]\n else: ans += int(str(nums[i]) + str(nums[n-1-i]))\n return ans \n``` | 1 | 0 | ['Python3'] | 0 |
find-the-array-concatenation-value | easy short efficient clean code | easy-short-efficient-clean-code-by-maver-dxuy | \nclass Solution {\npublic:\ntypedef long long ll;\nlong long findTheArrayConcVal(vector<int>&v) {\n ll n=v.size(), ans=0, l=0, r=n-1;\n while(l<r){\n | maverick09 | NORMAL | 2023-02-12T04:24:37.366006+00:00 | 2023-02-12T04:28:43.573428+00:00 | 52 | false | ```\nclass Solution {\npublic:\ntypedef long long ll;\nlong long findTheArrayConcVal(vector<int>&v) {\n ll n=v.size(), ans=0, l=0, r=n-1;\n while(l<r){\n ans+=stoll(to_string(v[l++])+to_string(v[r--]));\n }\n if(l==r){\n ans+=v[l];\n }\n return ans;\n}\n};\n``` | 1 | 0 | ['C'] | 0 |
find-the-array-concatenation-value | Python Short and Simple | python-short-and-simple-by-aqxa2k-rfqg | Solution \n\nI use a left and right pointer and increment my answer at each step of the time, by concatenating the two numbers in their string form and converti | aqxa2k | NORMAL | 2023-02-12T04:03:17.292999+00:00 | 2023-02-12T04:03:17.293046+00:00 | 84 | false | # Solution \n\nI use a left and right pointer and increment my answer at each step of the time, by concatenating the two numbers in their string form and converting back to int. If the middle element is left (or if $N$ is odd), simply add it to the answer. \n\nAlternatively, you can just simulate what is stated in the ... | 1 | 0 | ['Python3'] | 0 |
find-the-array-concatenation-value | ✅ C++ || Easy | c-easy-by-lc_tushar-4rpx | \nclass Solution {\npublic:\n long long findTheArrayConcVal(vector<int>& nums) \n {\n long long ans = 0;\n int i = 0,j = nums.size()-1;\n | lc_Tushar | NORMAL | 2023-02-12T04:02:45.488321+00:00 | 2023-02-12T04:02:45.488371+00:00 | 65 | false | ```\nclass Solution {\npublic:\n long long findTheArrayConcVal(vector<int>& nums) \n {\n long long ans = 0;\n int i = 0,j = nums.size()-1;\n string temp = "";\n while(i<j)\n {\n temp = "";\n temp+=to_string(nums[i])+to_string(nums[j]);\n ans+=sto... | 1 | 0 | ['C', 'C++'] | 0 |
find-the-array-concatenation-value | C++ || simple to_string() use | c-simple-to_string-use-by-up1512001-rncn | \nclass Solution {\npublic:\n long long findTheArrayConcVal(vector<int>& nums) {\n long long ans=0;\n for(int i=0,j=nums.size()-1;i<nums.size() | up1512001 | NORMAL | 2023-02-12T04:02:13.112514+00:00 | 2023-02-12T04:02:13.112562+00:00 | 84 | false | ```\nclass Solution {\npublic:\n long long findTheArrayConcVal(vector<int>& nums) {\n long long ans=0;\n for(int i=0,j=nums.size()-1;i<nums.size()/2;i++,j--){\n string s = to_string(nums[i])+to_string(nums[j]);\n ans += stoll(s);\n }\n if(nums.size()%2==1) ans += num... | 1 | 0 | ['C', 'C++'] | 0 |
find-the-array-concatenation-value | C++ | c-by-s1ddharth-h97g | \nclass Solution {\npublic:\n long long findTheArrayConcVal(vector<int>& nums) {\n deque<int> dq;\n for(auto &it: nums) {\n dq.push_ | s1ddharth | NORMAL | 2023-02-12T04:01:57.615161+00:00 | 2023-02-12T04:01:57.615206+00:00 | 49 | false | ```\nclass Solution {\npublic:\n long long findTheArrayConcVal(vector<int>& nums) {\n deque<int> dq;\n for(auto &it: nums) {\n dq.push_back(it);\n }\n long long con = 0;\n while(dq.size() > 0) {\n if(dq.size() > 1) {\n auto first = to_string(dq.... | 1 | 0 | ['C'] | 0 |
find-the-array-concatenation-value | Two Pointer Simple C++ | two-pointer-simple-c-by-stupidly_logical-fgg9 | \n# Code\n\nclass Solution {\npublic:\n long long findTheArrayConcVal(vector<int>& nums) {\n int n = nums.size(), l, r;\n l = 0; r = n-1;\n | stupidly_logical | NORMAL | 2023-02-12T04:00:59.905079+00:00 | 2023-02-13T10:54:25.609528+00:00 | 102 | false | \n# Code\n```\nclass Solution {\npublic:\n long long findTheArrayConcVal(vector<int>& nums) {\n int n = nums.size(), l, r;\n l = 0; r = n-1;\n long long int ans = 0;\n while (l <= r) {\n if (l == r) {\n ans += nums[l];\n break;\n }\n ... | 1 | 0 | ['Two Pointers', 'C++'] | 0 |
find-the-array-concatenation-value | Two Pointer ✅ | Array 🦾 | Easy 😉 | Python3 | 🥳 | two-pointer-array-easy-python3-by-sourab-5t3p | IntuitionThe problem requires performing pairwise concatenation from both ends of the array until it's empty. A two-pointer approach came to mind: one pointer s | Sourabhishere | NORMAL | 2025-04-08T18:30:12.882924+00:00 | 2025-04-08T18:30:12.882924+00:00 | 1 | false | # Intuition
The problem requires performing pairwise concatenation from both ends of the array until it's empty. A two-pointer approach came to mind: one pointer starts at the beginning (i), and one at the end (j). We concatenate the values at these pointers as strings, convert the result back to an integer, and add to... | 0 | 0 | ['Array', 'Two Pointers', 'Python3'] | 0 |
find-the-array-concatenation-value | TypeScript solution, beats 100% | typescript-solution-beats-100-by-alkons-vwaq | IntuitionWe can solve this problem with O(n/2)ApproachWe need to iterate through a half of the array.
Starting from 0 and picking values: left = nums[0], right | alkons | NORMAL | 2025-04-02T08:57:56.719377+00:00 | 2025-04-02T08:57:56.719377+00:00 | 2 | false | # Intuition
We can solve this problem with O(n/2)
# Approach
We need to iterate through a half of the array.
Starting from 0 and picking values: left = nums[0], right = nums[nums.length - 1 - 0].
Then iterate until we calculate all the elements.
# Complexity
# Time complexity:
O(n)
(O(n/2) to be precise)
# Code... | 0 | 0 | ['TypeScript'] | 0 |
find-the-array-concatenation-value | ✅💯🔥Simple Code📌🚀| 🎓🧠using two pointers | O(n) Time Complexity💀💯 | simple-code-using-two-pointers-on-time-c-sddg | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | kotla_jithendra | NORMAL | 2025-03-31T11:12:45.689058+00:00 | 2025-03-31T11:12:45.689058+00:00 | 2 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Array', 'Two Pointers', 'Python', 'Python3'] | 0 |
find-the-array-concatenation-value | Java Solution Optimized Simple Approach Beat 85% ✅💯 | java-solution-optimized-simple-approach-s593n | Intuition1. Initialization:
ans: A variable of type long is used to store the result, which is the sum of concatenated values.
si: A pointer to the start of the | UnratedCoder | NORMAL | 2025-03-29T06:29:54.713364+00:00 | 2025-03-29T06:29:54.713364+00:00 | 2 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
**1. Initialization:**
- ans: A variable of type long is used to store the result, which is the sum of concatenated values.
- si: A pointer to the start of the array (initialized to 0).
- ei: A pointer to the end of the array (initialized t... | 0 | 0 | ['Array', 'Two Pointers', 'Simulation', 'Java'] | 0 |
find-the-array-concatenation-value | Optimized simple solution - beats 95.78%🔥 | optimized-simple-solution-beats-9578-by-25ydm | Complexity
Time complexity: O(N)
Space complexity: O(1)
Code | cyrusjetson | NORMAL | 2025-03-28T11:24:54.906692+00:00 | 2025-03-28T11:24:54.906692+00:00 | 2 | false | # Complexity
- Time complexity: O(N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```java []
class Solution {
public long findTheArrayConcVal(int[] nums) {
long ans = 0;
int l = 0;
int r = nums... | 0 | 0 | ['Java'] | 0 |
find-the-array-concatenation-value | Simple and 100% beats solution | simple-and-100-beats-solution-by-vignesh-vnn3 | Intuition ApproachWe have two pointers in which one moves from left and other from right, while doing this we concatenate the numbera concatenate b is given bya | vignesharavindh_ | NORMAL | 2025-03-28T06:44:30.352693+00:00 | 2025-03-28T06:44:30.352693+00:00 | 2 | false | # Intuition Approach
<!-- Describe your first thoughts on how to solve this problem. -->
We have two pointers in which one moves from left and other from right, while doing this we concatenate the number
a concatenate b is given by
a * number of places to move for b + b
number of places to move for b is given by t... | 0 | 0 | ['Math', 'Two Pointers', 'C++'] | 0 |
find-the-array-concatenation-value | find-the-array-concatenation-value | find-the-array-concatenation-value-by-ad-ntbh | IntuitionApproachComplexity
Time complexity:
O(n)
Space complexity:
O(1)
Code | Aditya1234563 | NORMAL | 2025-03-24T14:14:15.692785+00:00 | 2025-03-24T14:14:15.692785+00:00 | 3 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
O(n)
- Space complexity:
O(1)
# Code
```java []
class Solution {
public long findTheArrayConcVal(int[] nums) {
int n=nums.len... | 0 | 0 | ['Java'] | 0 |
find-the-array-concatenation-value | Easy Solution | easy-solution-by-adhi_m_s-gbd5 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Adhi_M_S | NORMAL | 2025-03-24T07:01:36.952613+00:00 | 2025-03-24T07:01:36.952613+00:00 | 2 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Python3'] | 0 |
find-the-array-concatenation-value | TP | tp-by-sangram1989-8eaj | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Sangram1989 | NORMAL | 2025-03-23T13:38:06.154458+00:00 | 2025-03-23T13:38:06.154458+00:00 | 2 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Java'] | 0 |
find-the-array-concatenation-value | Sum of Concatenated Pairs in an Array | sum-of-concatenated-pairs-in-an-array-by-c0fd | IntuitionApproachInitialize two pointers:i at the start (0)j at the end (len(nums) - 1)Maintain a variable concat to store the sum of concatenated numbers.Use a | jadhav_omkar_12 | NORMAL | 2025-03-22T19:16:52.078420+00:00 | 2025-03-22T19:16:52.078420+00:00 | 1 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->The problem requires forming numbers by concatenating the first and last elements of the array and summing them. If the array has an odd length, the middle element is added separately. The two-pointer approach is a natural way to solve this,... | 0 | 0 | ['Python3'] | 0 |
maximum-number-of-consecutive-values-you-can-make | [Java/C++/Python] Accumulate the Coins | javacpython-accumulate-the-coins-by-lee2-f918 | Intuition\n"Return the maximum number ... you can make with your coins starting from and including 0"\nthis equals to\n"Return the minimum number that you can | lee215 | NORMAL | 2021-03-20T16:01:38.530454+00:00 | 2021-03-21T05:27:06.571414+00:00 | 8,876 | false | # **Intuition**\n"Return the maximum number ... you can make with your coins starting from and **including 0**"\nthis equals to\n"Return the minimum number that you can not make .."\n<br>\n\n# **Explanation**\nBecause samll values can only discompose to samller numbers,\nwe sort the input array and check from the smal... | 257 | 4 | [] | 41 |
maximum-number-of-consecutive-values-you-can-make | C++/Java/Python with picture | cjavapython-with-picture-by-votrubac-bpa4 | The intuition for this one is cool. Got a few TLE before figuring it out.\n\nThis is the realization: if we reached number i, that means that we can make all va | votrubac | NORMAL | 2021-03-20T16:01:29.290903+00:00 | 2021-03-26T18:12:35.789115+00:00 | 5,402 | false | The intuition for this one is cool. Got a few TLE before figuring it out.\n\nThis is the realization: if we reached number `i`, that means that we can make all values `0...i`. So, if we add a coin with value `j`, we can also make values `i+1...i+j`.\n\nThe only case when we can have a gap is the coin value is greater t... | 142 | 4 | [] | 12 |
maximum-number-of-consecutive-values-you-can-make | ✅Short & Easy w/ Explanation | Greedy Approach | short-easy-w-explanation-greedy-approach-5l80 | We can understand this algorithm through an example. \nIf we have coins [1], we can form the sequence 0, 1. For extending sequence we need coin <= 2.\nIf we hav | archit91 | NORMAL | 2021-03-20T16:04:18.376983+00:00 | 2021-03-20T16:33:51.313480+00:00 | 2,256 | false | We can understand this algorithm through an example. \nIf we have coins `[1]`, we can form the sequence `0, 1`. For extending sequence we need coin <= 2.\nIf we have coing `[1, 2]`, we can form `0, 1, 2, 3`. For extending sequence we need coin <= 4.\nIf we have coing `[1, 2, 3]`, we can form `0, 1, 2, 3, 4, 5, 6`. For ... | 55 | 1 | ['C'] | 2 |
maximum-number-of-consecutive-values-you-can-make | C++/Python/Javascript Solution, O(NLogN) Time and O(logn) space | cpythonjavascript-solution-onlogn-time-a-8ojk | The space complexity is O(logn), There are logN stack frame when running quick sort.\nThanks @lee215 to point it out.\n\n#### Idea\n- sort the Array\n- We start | chejianchao | NORMAL | 2021-03-20T16:00:24.153796+00:00 | 2021-03-20T16:28:22.675602+00:00 | 1,048 | false | The space complexity is O(logn), There are logN stack frame when running quick sort.\nThanks @lee215 to point it out.\n\n#### Idea\n- sort the Array\n- We start from 0 as current, means we can cover all the number from 0 ~ current, and if current + 1 >= next_number, that means we can cover all the number from 0 ~ curre... | 15 | 4 | [] | 3 |
maximum-number-of-consecutive-values-you-can-make | [Python 3] with explanation. | python-3-with-explanation-by-bakerston-kgxs | Suppose we have a coin of value c[i], we can use this coin to extend current consecutive values, only if we have already built consecutive values no less than c | Bakerston | NORMAL | 2021-03-20T16:04:46.364234+00:00 | 2021-03-20T17:07:15.829204+00:00 | 687 | false | Suppose we have a coin of value ```c[i]```, we can use this coin to extend current consecutive values, only if we have already built consecutive values no less than ```c[i] - 1```. \n\nSo just sort coins by value, for each ```coin[i]```, check if ```c[i]``` satisfies ```c[i] <= cur_max + 1```. If so, increase the maxim... | 9 | 0 | [] | 1 |
maximum-number-of-consecutive-values-you-can-make | Java Simple Explanation (beats 99) | java-simple-explanation-beats-99-by-vani-yu7e | \nclass Solution {\n public int getMaximumConsecutive(int[] c) {\n Arrays.sort(c);\n int n = c.length;\n int sum = 1;\n for(int i | vanir | NORMAL | 2021-04-03T11:43:05.104555+00:00 | 2021-04-03T12:30:30.038008+00:00 | 519 | false | ```\nclass Solution {\n public int getMaximumConsecutive(int[] c) {\n Arrays.sort(c);\n int n = c.length;\n int sum = 1;\n for(int i=0;i<n;i++){\n if(c[i]<=sum) sum=sum+c[i];\n else break;\n }\n return sum;\n \n \n }\n}\n```\n\nYou want... | 7 | 0 | [] | 0 |
maximum-number-of-consecutive-values-you-can-make | [C++] O(nlgn) Time, Constant Space DP Solution Explained | c-onlgn-time-constant-space-dp-solution-5v96x | I started to tackle this problem in a kind of crude DP fashion (you know, preparing all the cells up to the sum of all the provided coins), when it occurred to | ajna | NORMAL | 2021-03-20T20:57:06.537903+00:00 | 2021-03-20T20:57:06.537940+00:00 | 1,159 | false | I started to tackle this problem in a kind of crude DP fashion (you know, preparing all the cells up to the sum of all the provided coins), when it occurred to me that there was a simpler way, less memory demanding way and that is the one I am going to explore and explaing now :)\n\nTo proceed, we will first of all ini... | 7 | 0 | ['Dynamic Programming', 'C', 'Combinatorics', 'C++'] | 3 |
maximum-number-of-consecutive-values-you-can-make | Python O(NlogN) time solution. Explained | python-onlogn-time-solution-explained-by-rd9v | The idea behind it is simple:\nsort the coins, and every time we take the smallest available (greedy and dp like)\ncur_max tracks the max consecutive we can mak | dyxuki | NORMAL | 2021-08-29T11:08:56.094043+00:00 | 2021-08-30T07:36:21.056461+00:00 | 487 | false | The idea behind it is simple:\nsort the coins, and every time we take the smallest available (greedy and dp like)\ncur_max tracks the max consecutive we can make.\n* if we have a "1", then we know for sure we can make the next number (so: cur_max +=1) (Actually this case is already covered in the next if condition "coi... | 5 | 1 | ['Python'] | 0 |
maximum-number-of-consecutive-values-you-can-make | Clean Python 3, Greedy O(sort) | clean-python-3-greedy-osort-by-lenchen11-b54c | Sort first, and use largest to save the current possible consecutive largest value\nif current coin is larger than largest, it should be largest + 1.\nOtherwise | lenchen1112 | NORMAL | 2021-03-20T16:01:07.685074+00:00 | 2021-03-20T16:01:29.903027+00:00 | 379 | false | Sort first, and use `largest` to save the current possible consecutive largest value\nif current coin is larger than `largest`, it should be largest + 1.\nOtherwise there will be a gap.\n\nTime: `O(sort)`\nSpace: `O(sort)`\n```\nclass Solution:\n def getMaximumConsecutive(self, coins: List[int]) -> int:\n lar... | 5 | 2 | [] | 0 |
maximum-number-of-consecutive-values-you-can-make | C++ | Short Iterative Greedy solution | Explained | Fast solution with less memory usage | c-short-iterative-greedy-solution-explai-2fto | Intuition\n Describe your first thoughts on how to solve this problem. \nNote: For complete code, please scroll to the end. Detailed explanation continues below | DebasritoLahiri | NORMAL | 2022-12-21T23:54:36.374975+00:00 | 2022-12-22T00:02:28.099264+00:00 | 289 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n***Note:*** *For complete code, please scroll to the end. Detailed explanation continues below.*\n\nSuppose we have already achieved a value of x. Now our next coin can be either equal to x+1 or less/greater than x+1. If our next coin is ... | 4 | 0 | ['C++'] | 0 |
maximum-number-of-consecutive-values-you-can-make | Greedy Solution || Java || Time O(NlogN) and Space:O(1) | greedy-solution-java-time-onlogn-and-spa-lay7 | \n\n public int getMaximumConsecutive(int[] coins) {\n Arrays.sort(coins);\n int result=1;\n \n int idx=0;\n while(idx<coins. | himanshuchhikara | NORMAL | 2021-03-20T16:39:16.956244+00:00 | 2021-03-20T16:39:16.956268+00:00 | 366 | false | \n```\n public int getMaximumConsecutive(int[] coins) {\n Arrays.sort(coins);\n int result=1;\n \n int idx=0;\n while(idx<coins.length && result>=coins[idx]){\n result+=coins[idx];\n idx++;\n }\n return result;\n }\n\t``` | 3 | 1 | ['Greedy', 'Sorting', 'Java'] | 0 |
maximum-number-of-consecutive-values-you-can-make | Easy C++ Solution | easy-c-solution-by-nehagupta_09-am97 | \n\n# Code\n\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin(),coins.end());\n int count=1;\n | NehaGupta_09 | NORMAL | 2024-06-21T07:57:17.685744+00:00 | 2024-06-21T07:57:17.685772+00:00 | 50 | false | \n\n# Code\n```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin(),coins.end());\n int count=1;\n for(int i=0;i<coins.size();i++)\n {\n if(coins[i]<=count){\n count+=coins[i];\n }\n else\n ... | 2 | 0 | ['Array', 'Greedy', 'Sorting', 'C++'] | 0 |
maximum-number-of-consecutive-values-you-can-make | c++ | easy | fast | c-easy-fast-by-venomhighs7-9h74 | \n\n# Code\n\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& A) {\n sort(A.begin(), A.end());\n int res = 1;\n f | venomhighs7 | NORMAL | 2022-11-21T05:35:04.657504+00:00 | 2022-11-21T05:35:04.657549+00:00 | 486 | false | \n\n# Code\n```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& A) {\n sort(A.begin(), A.end());\n int res = 1;\n for (int a: A) {\n if (a > res) break;\n res += a;\n }\n return res;\n }\n};\n``` | 2 | 0 | ['C++'] | 0 |
maximum-number-of-consecutive-values-you-can-make | TIME O(nlogn) || SPACE O(1) || C++ || SIMPLE | time-onlogn-space-o1-c-simple-by-abhay_1-4d33 | \nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin(),coins.end());\n int ans = 0;\n int su | abhay_12345 | NORMAL | 2022-10-01T10:47:54.997976+00:00 | 2022-10-01T10:47:54.998008+00:00 | 646 | false | ```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin(),coins.end());\n int ans = 0;\n int sum = 0;\n for(auto &i: coins){\n if(sum+1<i){\n return sum+1;\n }\n sum += i;\n }\n retur... | 2 | 0 | ['Greedy', 'C', 'Sorting', 'C++'] | 0 |
maximum-number-of-consecutive-values-you-can-make | c++ solution using Hashing | c-solution-using-hashing-by-bhardwajsahi-5jg0 | \nint getMaximumConsecutive(vector<int>& a) {\n \n map<int, int> mp;\n \n int n = a.size();\n \n for(int i=0;i<n;i++){ | bhardwajsahil | NORMAL | 2021-08-01T05:34:51.110645+00:00 | 2021-08-01T05:34:51.110689+00:00 | 309 | false | ```\nint getMaximumConsecutive(vector<int>& a) {\n \n map<int, int> mp;\n \n int n = a.size();\n \n for(int i=0;i<n;i++){\n if(!mp[a[i]]){\n mp[a[i]] = 0;\n }\n mp[a[i]]++;\n }\n \n int ans = 0;\n \n ... | 2 | 0 | [] | 2 |
maximum-number-of-consecutive-values-you-can-make | [Python] step-by-step explanation | python-step-by-step-explanation-by-kuanc-udy6 | python\nclass Solution:\n def getMaximumConsecutive(self, coins: List[int]) -> int:\n # 1) if we can use first k coins to make values 0...v,\n | kuanc | NORMAL | 2021-07-28T00:29:28.653119+00:00 | 2021-07-28T00:29:28.653166+00:00 | 210 | false | ```python\nclass Solution:\n def getMaximumConsecutive(self, coins: List[int]) -> int:\n # 1) if we can use first k coins to make values 0...v,\n # it means the combination of first k coins can cover values 0...v\n # 2) what\'s the condition for k + 1 coin s.t. we can make v + 1\n # ... | 2 | 0 | [] | 0 |
maximum-number-of-consecutive-values-you-can-make | Python3 Simple Solution | python3-simple-solution-by-victor72-7z1q | Time Complexity: 94% (approximately)\nSpace Complexity: 84% (approximately)\n\n\nclass Solution:\n def getMaximumConsecutive(self, coins: List[int]) -> int:\ | victor72 | NORMAL | 2021-04-11T17:54:27.190507+00:00 | 2021-04-11T17:54:27.190544+00:00 | 330 | false | **Time Complexity:** 94% (approximately)\n**Space Complexity:** 84% (approximately)\n\n```\nclass Solution:\n def getMaximumConsecutive(self, coins: List[int]) -> int:\n coins.sort()\n \n res = 1\n \n for coin in coins:\n if (res >= coin):\n res += coin\n ... | 2 | 1 | ['Python', 'Python3'] | 0 |
maximum-number-of-consecutive-values-you-can-make | [Python] Thinking from presum | python-thinking-from-presum-by-qubenhao-k4ck | Given a list of numbers, the maximum we could reach is the sum of the array. What if we keep trying from left to right (after sorting)? For every coins[i], it c | qubenhao | NORMAL | 2021-03-21T01:36:43.101939+00:00 | 2021-03-21T02:18:49.532187+00:00 | 523 | false | Given a list of numbers, the maximum we could reach is the sum of the array. What if we keep trying from left to right (after sorting)? For every coins[i], it can construct every number from `coins[i]` to `coins[i] + persum[i-1]`.\n\n```\n def getMaximumConsecutive(self, coins):\n """\n :type coins: Li... | 2 | 0 | ['Python'] | 0 |
maximum-number-of-consecutive-values-you-can-make | python3 Sorting O(nlogn) solution | python3-sorting-onlogn-solution-by-swap2-0wp0 | ```\nclass Solution:\n def getMaximumConsecutive(self, coins: List[int]) -> int:\n coins.sort()\n ans = 0\n for i in range(len(coins)):\ | swap2001 | NORMAL | 2021-03-20T16:10:55.811362+00:00 | 2021-03-20T16:10:55.811387+00:00 | 263 | false | ```\nclass Solution:\n def getMaximumConsecutive(self, coins: List[int]) -> int:\n coins.sort()\n ans = 0\n for i in range(len(coins)):\n if coins[i]<=ans+1:\n ans += coins[i]\n else:\n break\n return ans+1 | 2 | 1 | ['Sorting', 'Python3'] | 1 |
maximum-number-of-consecutive-values-you-can-make | [Java] greedy | java-greedy-by-66brother-tepj | \nclass Solution {\n public int getMaximumConsecutive(int[] A) {\n Arrays.sort(A);\n int res=1;\n for(int i=0;i<A.length;i++){\n | 66brother | NORMAL | 2021-03-20T16:02:38.827740+00:00 | 2021-03-20T16:02:38.827768+00:00 | 82 | false | ```\nclass Solution {\n public int getMaximumConsecutive(int[] A) {\n Arrays.sort(A);\n int res=1;\n for(int i=0;i<A.length;i++){\n if(A[i]>res)break;\n res+=A[i];\n }\n \n return res;\n \n }\n}\n``` | 2 | 0 | [] | 0 |
maximum-number-of-consecutive-values-you-can-make | [Python3] greedy | python3-greedy-by-ye15-milc | \n\nclass Solution:\n def getMaximumConsecutive(self, coins: List[int]) -> int:\n ans = 1\n for x in sorted(coins): \n if ans < x: b | ye15 | NORMAL | 2021-03-20T16:01:47.052813+00:00 | 2021-03-21T00:42:00.460881+00:00 | 243 | false | \n```\nclass Solution:\n def getMaximumConsecutive(self, coins: List[int]) -> int:\n ans = 1\n for x in sorted(coins): \n if ans < x: break \n ans += x\n return ans\n``` | 2 | 1 | ['Python3'] | 0 |
maximum-number-of-consecutive-values-you-can-make | GREEDY | INTUITION | C++ SOLUTION | greedy-intuition-c-solution-by-haribhakt-iv3g | Intuition\nWe can have a prefixSum which will indicate sum of all elements from start till current index. If curr_index >= prefixSum + 1, which means it is unat | HariBhakt | NORMAL | 2024-06-18T02:27:35.679833+00:00 | 2024-06-18T02:27:35.679852+00:00 | 229 | false | # Intuition\nWe can have a prefixSum which will indicate sum of all elements from start till current index. If curr_index >= prefixSum + 1, which means it is unattainable.\n\n# Approach\nHave a prefixSum which checks if coins[curr_idx] >= prefixSum + 1.If yes, break the loop and return ans;\n\n# Complexity\n- Time comp... | 1 | 0 | ['C++'] | 0 |
maximum-number-of-consecutive-values-you-can-make | [Python3] O(NlogN) Greedy solution + explanation | python3-onlogn-greedy-solution-explanati-1prg | Intuition\nThe problem requires determining the maximum number of consecutive integer values that can be made using the given coins, starting from 0. The key ob | pipilongstocking | NORMAL | 2024-06-16T05:46:50.162088+00:00 | 2024-06-16T05:46:50.162115+00:00 | 121 | false | # Intuition\nThe problem requires determining the maximum number of consecutive integer values that can be made using the given coins, starting from 0. The key observation here is that if we can create all values up to a certain integer `x`, and the next coin has a value less than or equal to `x`, then we can extend th... | 1 | 0 | ['Greedy', 'Sorting', 'Python3'] | 0 |
maximum-number-of-consecutive-values-you-can-make | Easy Java Solution || Beats 100% | easy-java-solution-beats-100-by-ravikuma-n2ti | 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 | ravikumar50 | NORMAL | 2024-04-26T16:58:11.846773+00:00 | 2024-04-26T16:58:11.846809+00:00 | 341 | 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)$$ --... | 1 | 0 | ['Java'] | 0 |
maximum-number-of-consecutive-values-you-can-make | solution | solution-by-shree_govind_jee-z5ql | Intuition\nThis is the realization: if we reached number i, that means that we can make all values 0...i. So, if we add a coin with value j, we can also make va | Shree_Govind_Jee | NORMAL | 2024-01-22T02:44:02.946301+00:00 | 2024-01-22T02:44:02.946325+00:00 | 238 | false | # Intuition\nThis is the realization: if we reached number i, that means that we can make all values 0...i. So, if we add a coin with value j, we can also make values i+1...i+j.\n\nThe only case when we can have a gap is the coin value is greater than i + 1 . So we sort the coins to make sure we process smaller coins f... | 1 | 0 | ['Array', 'Greedy', 'Java'] | 0 |
maximum-number-of-consecutive-values-you-can-make | [Python3] memory usage: less than 100% | python3-memory-usage-less-than-100-by-le-02ri | ```\nclass Solution:\n def getMaximumConsecutive(self, coins: List[int]) -> int:\n cur = ans = sum(coins);\n coins.sort();\n while cur > | leehjworking | NORMAL | 2022-08-23T01:54:25.734673+00:00 | 2022-08-23T01:57:36.617977+00:00 | 221 | false | ```\nclass Solution:\n def getMaximumConsecutive(self, coins: List[int]) -> int:\n cur = ans = sum(coins);\n coins.sort();\n while cur > 1 and coins: \n half = cur//2;\n cur += -coins.pop(); \n #we cannot make half with the remaining coins\n... | 1 | 0 | [] | 0 |
maximum-number-of-consecutive-values-you-can-make | Easy and clean C++ code | easy-and-clean-c-code-by-19je0894-canm | ```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector& coins) {\n sort(coins.begin() , coins.end());\n \n // initially we ha | 19JE0894 | NORMAL | 2022-08-07T11:38:29.062886+00:00 | 2022-08-07T11:38:29.062918+00:00 | 213 | false | ```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin() , coins.end());\n \n // initially we have zero as max and min values\n int mn = 0 , mx = 0;\n \n for(auto x : coins){\n int temp_mn = mn + x;\n int tem... | 1 | 0 | [] | 0 |
maximum-number-of-consecutive-values-you-can-make | C++ Simple Explanation | Clean Code | O(NlogN) time, O(1) space | c-simple-explanation-clean-code-onlogn-t-p1rq | just try to dry run this after reading this explanation!\non this example\n\n[1,2,4,9,10,11]\n\nAfter sorting the array what we basically try to do is traverse | kartikeya_0607 | NORMAL | 2022-06-21T21:39:57.154706+00:00 | 2022-06-22T08:45:17.077468+00:00 | 235 | false | just try to dry run this after reading this explanation!\non this example\n```\n[1,2,4,9,10,11]\n```\nAfter sorting the array what we basically try to do is traverse the array and in each iteration we check whether its possible to move ahead. If yes we do otherwise we simply break.\n\n1. the ``sum`` variable basically ... | 1 | 0 | ['Greedy', 'Sorting'] | 0 |
maximum-number-of-consecutive-values-you-can-make | [cpp] simple 6 liner code | cpp-simple-6-liner-code-by-tushargupta98-jr3f | \nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin(), coins.end());\n int min = 0;\n for(i | tushargupta9800 | NORMAL | 2022-05-07T17:13:03.347542+00:00 | 2022-05-07T17:13:03.347588+00:00 | 66 | false | ```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin(), coins.end());\n int min = 0;\n for(int i: coins){\n if(i <= min+1) min = i+min;\n else break;\n }\n \n return min+1;\n }\n};\n``` | 1 | 0 | [] | 0 |
maximum-number-of-consecutive-values-you-can-make | Short C++, O(NLogN) Time and O(1) Space | short-c-onlogn-time-and-o1-space-by-adar-6xw4 | \tclass Solution {\n\tpublic:\n int getMaximumConsecutive(vector& coins) {\n int n=coins.size();\n sort(coins.begin(),coins.end());\n in | adarsh_190701 | NORMAL | 2022-02-03T07:04:25.128433+00:00 | 2022-02-03T07:04:25.128470+00:00 | 228 | false | \tclass Solution {\n\tpublic:\n int getMaximumConsecutive(vector<int>& coins) {\n int n=coins.size();\n sort(coins.begin(),coins.end());\n int ans=1;\n for(int i=0;i<n;i++){\n if(coins[i]<=ans) ans+=coins[i];\n }\n return ans;\n }\n\t}; | 1 | 0 | ['C', 'C++'] | 0 |
maximum-number-of-consecutive-values-you-can-make | very easy maths logic C++ | very-easy-maths-logic-c-by-adarshxd-ofpw | \nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin(), coins.end());\n if (!coins.size()) return 1 | AdarshxD | NORMAL | 2021-12-05T19:35:48.532116+00:00 | 2022-01-26T11:32:00.023286+00:00 | 185 | false | ```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin(), coins.end());\n if (!coins.size()) return 1;\n if(coins.size()==1 and coins[0]==1) return 2;\n \n //then we have 2 or more than 2\n int max=0;\n if(coins[0]==1){\n ... | 1 | 0 | ['Sorting'] | 1 |
maximum-number-of-consecutive-values-you-can-make | C++ | Sort | Similar to Patching Array | c-sort-similar-to-patching-array-by-shru-zyd9 | ```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector& coins) {\n int mis = 1, i =0;\n sort(coins.begin(),coins.end());\n wh | shruti985 | NORMAL | 2021-09-12T08:59:02.764472+00:00 | 2021-09-12T08:59:02.764501+00:00 | 121 | false | ```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n int mis = 1, i =0;\n sort(coins.begin(),coins.end());\n while(i<coins.size() && mis>=coins[i])\n mis += coins[i++];\n return mis;\n }\n}; | 1 | 0 | [] | 0 |
maximum-number-of-consecutive-values-you-can-make | Java Solution | java-solution-by-jxie418-nlkd | \nclass Solution {\n public int getMaximumConsecutive(int[] coins) {\n Arrays.sort(coins);\n int x = 0;\n\t\tfor (int v: coins) {\n\t\t\tif (v | jxie418 | NORMAL | 2021-08-07T17:59:40.056340+00:00 | 2021-08-07T17:59:40.056383+00:00 | 105 | false | ```\nclass Solution {\n public int getMaximumConsecutive(int[] coins) {\n Arrays.sort(coins);\n int x = 0;\n\t\tfor (int v: coins) {\n\t\t\tif (v <=x+) \n\t\t\t x +=v;\n\t\t\telse\n\t\t\t break;\n\t\t}\n\t\treturn x+1;\n }\n}\n``` | 1 | 2 | [] | 1 |
maximum-number-of-consecutive-values-you-can-make | Proof that sorting + greedy works | proof-that-sorting-greedy-works-by-decom-dgez | The coding part is straightforward from the hints. However, it is the proof that sorting + greedy works the interviewer would be asking.\n1. If coins[:i] has su | decomplexifier | NORMAL | 2021-07-26T05:02:25.191042+00:00 | 2021-07-26T05:05:32.948552+00:00 | 148 | false | The coding part is straightforward from the hints. However, it is the proof that sorting + greedy works the interviewer would be asking.\n1. If `coins[:i]` has subset sums `0, 1, ..., x`, then for `coins[:i+1]` we can have these new sums by adding `v=coins[i]`: `v, v+1, ..., v+x`. If `v <= x+1`, then there is no gap be... | 1 | 0 | [] | 0 |
maximum-number-of-consecutive-values-you-can-make | o(nlog(n)) | cpp | easy to solve | onlogn-cpp-easy-to-solve-by-mayankpatel8-6myw | class Solution {\npublic:\n int getMaximumConsecutive(vector& coins) {\n \n sort(coins.begin(),coins.end());\n long long i,j,k=0,l,m;\n | mayankpatel8011 | NORMAL | 2021-05-27T13:17:37.967108+00:00 | 2021-07-08T02:36:43.638815+00:00 | 177 | false | class Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n \n sort(coins.begin(),coins.end());\n long long i,j,k=0,l,m;\n i=j=0;\n while(j<coins.size())\n {\n if(k>=coins[j])\n {\n k+=coins[j];\n j++;\n ... | 1 | 0 | [] | 1 |
maximum-number-of-consecutive-values-you-can-make | Easy Java O(nlogn) Solution | easy-java-onlogn-solution-by-jalwal-rn5a | \nclass Solution {\n public int getMaximumConsecutive(int[] nums) {\n int len = nums.length;\n Arrays.sort(nums);\n int ans = 1;\n | jalwal | NORMAL | 2021-05-16T14:48:38.150443+00:00 | 2021-05-16T14:48:38.150474+00:00 | 288 | false | ```\nclass Solution {\n public int getMaximumConsecutive(int[] nums) {\n int len = nums.length;\n Arrays.sort(nums);\n int ans = 1;\n for(int i = 0 ; i < len ; i++) {\n if(nums[i] > ans) break;\n ans += nums[i];\n }\n return ans;\n }\n}\n``` | 1 | 0 | ['Greedy', 'Sorting', 'Java'] | 0 |
maximum-number-of-consecutive-values-you-can-make | Simple c++ solution with detailed explaintion | simple-c-solution-with-detailed-explaint-tnbl | \n/*\n\tIf we are able to form any number in the range [s,e].\n\tIf we take a number A and include it with every number of the range [s,e]. We will be able to f | akhil_trivedi | NORMAL | 2021-04-19T05:33:30.550927+00:00 | 2021-04-19T05:33:30.550969+00:00 | 164 | false | ```\n/*\n\tIf we are able to form any number in the range [s,e].\n\tIf we take a number A and include it with every number of the range [s,e]. We will be able to form ant number in the range[s+A,e+A].\n\tNow lets consider the two ranges:\n\t\t[s,e] - formed without taking A\n\t\t[s+A,e+A] - formed by taking A with ever... | 1 | 0 | [] | 0 |
maximum-number-of-consecutive-values-you-can-make | Incorrect test? | incorrect-test-by-icholy-tw1p | I\'m getting the following test failure:\n\n\nInput: [1,3,4]\nOutput: 3\nExpected: 2\n\n\nI might be misunderstanding the problem, but it seems like the longest | icholy | NORMAL | 2021-04-04T17:16:24.530111+00:00 | 2021-04-04T17:16:24.530160+00:00 | 118 | false | I\'m getting the following test failure:\n\n```\nInput: [1,3,4]\nOutput: 3\nExpected: 2\n```\n\nI might be misunderstanding the problem, but it seems like the longest consecutive values are 3,4,5:\n\n```\n- 3: take [3]\n- 4: take [4]\n- 5: take [4, 1]\n``` | 1 | 1 | [] | 2 |
maximum-number-of-consecutive-values-you-can-make | Short Easy C++ Code | short-easy-c-code-by-aryan29-6qrw | \nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin(),coins.end());\n int n=coins.size();\n | aryan29 | NORMAL | 2021-03-25T06:27:27.185128+00:00 | 2021-03-25T06:27:27.185170+00:00 | 146 | false | ```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin(),coins.end());\n int n=coins.size();\n int till=1; //1 + point where we can reach now\n for(int i=0;i<n;i++)\n {\n if(coins[i]>till) // we could only make sum to (till-1)... | 1 | 0 | [] | 0 |
maximum-number-of-consecutive-values-you-can-make | C++ (there was a leetcode problem really similar to this?) | c-there-was-a-leetcode-problem-really-si-bu84 | Cannot remember the # of that problem. But the underlying algorithm is almost the same.\n\n\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int | wzypangpang | NORMAL | 2021-03-22T01:56:07.817539+00:00 | 2021-03-22T01:56:07.817569+00:00 | 162 | false | Cannot remember the # of that problem. But the underlying algorithm is almost the same.\n\n```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin(), coins.end());\n int sum = 0;\n for(int i=0; i<coins.size(); i++) {\n if(coins[i] > sum + 1)... | 1 | 0 | [] | 1 |
maximum-number-of-consecutive-values-you-can-make | Java solution 100% faster without using Arrays.sort() | java-solution-100-faster-without-using-a-h84y | \nclass Solution {\n public int getMaximumConsecutive(int[] coins) {\n if(coins.length==0 && coins==null)\n return 0;\n TreeMap<Integer,In | kanojiyakaran | NORMAL | 2021-03-21T17:58:10.323455+00:00 | 2021-03-21T17:58:10.323492+00:00 | 191 | false | ```\nclass Solution {\n public int getMaximumConsecutive(int[] coins) {\n if(coins.length==0 && coins==null)\n return 0;\n TreeMap<Integer,Integer> map=new TreeMap<Integer,Integer>();\n for(int i:coins)\n map.put(i,map.getOrDefault(i,0)+1);\n int range=0;\n for(int i:map.ke... | 1 | 0 | ['Tree', 'Java'] | 0 |
maximum-number-of-consecutive-values-you-can-make | javascript greedy 176ms | javascript-greedy-176ms-by-henrychen222-1sh9 | \nconst getMaximumConsecutive = (c) => {\n c.sort((x, y) => x - y);\n let res = 0;\n for (const e of c) {\n if (e <= res + 1) res += e;\n }\n | henrychen222 | NORMAL | 2021-03-20T17:40:10.159335+00:00 | 2021-03-20T17:40:10.159365+00:00 | 154 | false | ```\nconst getMaximumConsecutive = (c) => {\n c.sort((x, y) => x - y);\n let res = 0;\n for (const e of c) {\n if (e <= res + 1) res += e;\n }\n return res + 1;\n};\n``` | 1 | 0 | ['Greedy', 'JavaScript'] | 0 |
maximum-number-of-consecutive-values-you-can-make | sort and use prefix sum c++ | sort-and-use-prefix-sum-c-by-sguox002-j5ay | stop when there is a gap.\n\n int getMaximumConsecutive(vector<int>& coins) {\n sort(begin(coins),end(coins));\n int n=coins.size();\n i | sguox002 | NORMAL | 2021-03-20T16:13:36.572846+00:00 | 2021-03-21T02:15:27.402712+00:00 | 137 | false | stop when there is a gap.\n```\n int getMaximumConsecutive(vector<int>& coins) {\n sort(begin(coins),end(coins));\n int n=coins.size();\n int mx=0,pre=0;\n for(int i: coins){\n if(i>pre+1) return pre+1;\n pre+=i;\n }\n return pre+1;\n }\n``` | 1 | 0 | [] | 0 |
maximum-number-of-consecutive-values-you-can-make | Javascript Solution With Explanation | javascript-solution-with-explanation-by-90k1y | \n// we iterate from the smallest number while maintaining an integer sum. sum means that we can produce all number from 0 to sum.\n// when we can make numbers | thebigbadwolf | NORMAL | 2021-03-20T16:02:47.550815+00:00 | 2021-03-20T16:02:47.550857+00:00 | 148 | false | ```\n// we iterate from the smallest number while maintaining an integer sum. sum means that we can produce all number from 0 to sum.\n// when we can make numbers from 0 to sum, and we encounter a new number, lets say arr[2].\n// it is obvious that we can create all numbers from sum to sum + arr[2].\n// if there is a g... | 1 | 0 | ['JavaScript'] | 1 |
maximum-number-of-consecutive-values-you-can-make | [Java / Python / C++] Clean and Correct solution | java-python-c-clean-and-correct-solution-v25h | Java:\n\nclass Solution {\n int getMaximumConsecutive(int[] coins) {\n Arrays.sort(coins);\n int val=0;\n for(int i : coins){\n | lokeshsk1 | NORMAL | 2021-03-20T16:01:30.149843+00:00 | 2021-03-20T16:05:03.279840+00:00 | 222 | false | **Java:**\n```\nclass Solution {\n int getMaximumConsecutive(int[] coins) {\n Arrays.sort(coins);\n int val=0;\n for(int i : coins){\n if(i <= val+1)\n val += i;\n else\n break;\n }\n return val+1;\n }\n}\n```\n\n**Python:**\n``... | 1 | 0 | [] | 0 |
maximum-number-of-consecutive-values-you-can-make | Java Simple and Short | java-simple-and-short-by-mayank12559-esmg | \n public int getMaximumConsecutive(int[] coins) {\n Arrays.sort(coins);\n int max = 1;\n for(Integer i: coins){\n if(i > max | mayank12559 | NORMAL | 2021-03-20T16:00:35.799574+00:00 | 2021-03-20T16:00:35.799605+00:00 | 167 | false | ```\n public int getMaximumConsecutive(int[] coins) {\n Arrays.sort(coins);\n int max = 1;\n for(Integer i: coins){\n if(i > max)\n return max;\n max += i;\n }\n return max;\n }\n``` | 1 | 1 | [] | 0 |
maximum-number-of-consecutive-values-you-can-make | easy java solution | easy-java-solution-by-phani40-ao5z | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | phani40 | NORMAL | 2025-03-23T06:08:16.249716+00:00 | 2025-03-23T06:08:16.249716+00:00 | 2 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Java'] | 0 |
maximum-number-of-consecutive-values-you-can-make | 1798. Maximum Number of Consecutive Values You Can Make | 1798-maximum-number-of-consecutive-value-k9zs | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | G8xd0QPqTy | NORMAL | 2025-01-15T03:42:26.018543+00:00 | 2025-01-15T03:42:26.018543+00:00 | 10 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Python3'] | 0 |
maximum-number-of-consecutive-values-you-can-make | [Python3] O(n) | Simple Solution | python3-on-simple-solution-by-huangweiji-qxu5 | IntuitionGiven that I can express values ranging from 0 to x with n coins, when a new coin of value y is introduced, I can express values from 0 to x + y using | huangweijing | NORMAL | 2025-01-09T02:30:01.244789+00:00 | 2025-01-09T02:30:01.244789+00:00 | 5 | false | # Intuition
Given that I can express values ranging from 0 to x with n coins, when a new coin of value y is introduced, I can express values from 0 to x + y using these n + 1 coins.
# Complexity
- Time complexity:
$$O(n)$$
- Space complexity:
$$O(1)$$
# Code
```python3 []
from typing import List
class Solution:
... | 0 | 0 | ['Python3'] | 0 |
maximum-number-of-consecutive-values-you-can-make | Greedy Prefix | greedy-prefix-by-theabbie-xbry | \nclass Solution:\n def getMaximumConsecutive(self, coins: List[int]) -> int:\n coins.sort()\n if coins[0] > 1:\n return 1\n | theabbie | NORMAL | 2024-10-15T15:58:16.260137+00:00 | 2024-10-15T15:58:16.260195+00:00 | 2 | false | ```\nclass Solution:\n def getMaximumConsecutive(self, coins: List[int]) -> int:\n coins.sort()\n if coins[0] > 1:\n return 1\n p = 0\n for i in range(len(coins)):\n p += coins[i]\n if i == len(coins) - 1 or p + 1 < coins[i + 1]:\n return p ... | 0 | 0 | ['Python'] | 0 |
maximum-number-of-consecutive-values-you-can-make | Python Medium | python-medium-by-lucasschnee-9jd1 | python3 []\nclass Solution:\n def getMaximumConsecutive(self, coins: List[int]) -> int:\n coins.sort()\n \n\n best = 1\n\n\n for | lucasschnee | NORMAL | 2024-08-28T01:18:16.978500+00:00 | 2024-08-28T01:18:16.978520+00:00 | 1 | false | ```python3 []\nclass Solution:\n def getMaximumConsecutive(self, coins: List[int]) -> int:\n coins.sort()\n \n\n best = 1\n\n\n for x in coins:\n if x <= best:\n best += x\n else:\n return best\n\n return best\n``` | 0 | 0 | ['Python3'] | 0 |
maximum-number-of-consecutive-values-you-can-make | simple solution - Beats 100% Runtime | simple-solution-beats-100-runtime-by-las-b3e4 | Intuition\nThe problem requires finding the maximum number of consecutive integers starting from 1 that can be formed using the given set of coins. The first th | lashaka | NORMAL | 2024-08-15T04:55:48.776045+00:00 | 2024-08-15T04:55:48.776071+00:00 | 1 | false | # Intuition\nThe problem requires finding the maximum number of consecutive integers starting from 1 that can be formed using the given set of coins. The first thought is to sort the coins and then iteratively check whether each coin can extend the range of consecutive numbers that can be formed. If a coin is greater t... | 0 | 0 | ['C#'] | 0 |
maximum-number-of-consecutive-values-you-can-make | Easy CPP Solution | easy-cpp-solution-by-clary_shadowhunters-zvrn | \n# Code\n\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) \n {\n sort(coins.begin(),coins.end());\n int cur=0;\n | Clary_ShadowHunters | NORMAL | 2024-08-14T18:50:25.627155+00:00 | 2024-08-14T18:50:25.627172+00:00 | 4 | false | \n# Code\n```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) \n {\n sort(coins.begin(),coins.end());\n int cur=0;\n for (auto it: coins)\n {\n if (it<=cur) cur+=it;\n else if (it==cur+1) cur+=it;\n else return cur+1;\n }\n ... | 0 | 0 | ['C++'] | 0 |
maximum-number-of-consecutive-values-you-can-make | O(nlogn) Soln | onlogn-soln-by-ozzyozbourne-sba0 | 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. O(n) \n\n# | ozzyozbourne | NORMAL | 2024-07-23T12:58:55.028387+00:00 | 2024-07-23T12:58:55.028418+00:00 | 20 | false | # 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. $$O(n)$$ -->\n\n# Code\n``` java []\nfinal class Solution {\n public int getMaximumConsecutive(final int[] coins) {\n Arrays.sort(coins)... | 0 | 0 | ['Prefix Sum', 'Python', 'Java', 'Rust', 'Elixir', 'Erlang'] | 0 |
maximum-number-of-consecutive-values-you-can-make | beats 100 in performance | beats-100-in-performance-by-ayoublaar-z4iu | Intuition\n Describe your first thoughts on how to solve this problem. \nSuppose we have a list starting from 0 to n :\n[ 0, 1, 2, ...., n ]\nIf you add a numbe | AyoubLaar | NORMAL | 2024-07-19T12:47:01.686269+00:00 | 2024-07-19T12:47:01.686301+00:00 | 1 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSuppose we have a list starting from 0 to n :\n[ 0, 1, 2, ...., n ]\nIf you add a number m to all elements in the list, you\'ll have a new list like this :\n[ m, m+1, m+2, ...., n+m]\nJoin the two lists and you\'ll have :\n[ 0, 1, 2, ....... | 0 | 0 | ['C'] | 0 |
maximum-number-of-consecutive-values-you-can-make | TIME O(nlogn) || SPACE O(1) || C++ || SIMPLE | time-onlogn-space-o1-c-simple-by-priyans-wzjy | Intuition\nThe problem requires us to find the maximum number of consecutive integers (starting from 1) that can be formed using given coins. Intuitively, if we | priyanshu_2012 | NORMAL | 2024-06-22T17:02:06.425081+00:00 | 2024-06-22T17:02:06.425108+00:00 | 2 | false | # Intuition\nThe problem requires us to find the maximum number of consecutive integers (starting from 1) that can be formed using given coins. Intuitively, if we sort the coins and iterate through them, we can keep a running sum of the coin values. As long as the next coin can be added to this sum to form a consecutiv... | 0 | 0 | ['Array', 'Greedy', 'Sorting', 'C++'] | 0 |
maximum-number-of-consecutive-values-you-can-make | beat 100% | beat-100-by-ankushgurjar839-v2wg | \n# Complexity\n- Time complexity:\nO(n)+O(nlogn)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int> | ankushgurjar839 | NORMAL | 2024-06-20T12:56:04.153990+00:00 | 2024-06-20T12:56:04.154029+00:00 | 1 | false | \n# Complexity\n- Time complexity:\nO(n)+O(nlogn)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n\n sort(coins.begin(),coins.end());\n int i=0;\n int n=coins.size();\n int range=0;\n\n while(i<n){\n ... | 0 | 0 | ['C++'] | 0 |
maximum-number-of-consecutive-values-you-can-make | !!!! | Easy && Best | C++ Solution | using sorting | | easy-best-c-solution-using-sorting-by-su-f7cc | Intuition\n- sort the numbers\n- try to generate consecutive number greedily\n\n# Approach\nGreedy Approach\n\n# Complexity\n- Time complexity:\nO(nlogn)\n\n- S | sumitcoder01 | NORMAL | 2024-06-18T07:35:40.728949+00:00 | 2024-06-18T07:35:40.728974+00:00 | 7 | false | # Intuition\n- sort the numbers\n- try to generate consecutive number greedily\n\n# Approach\nGreedy Approach\n\n# Complexity\n- Time complexity:\n$$O(nlogn)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n int ans = 1;\n s... | 0 | 0 | ['C++'] | 0 |
maximum-number-of-consecutive-values-you-can-make | Greedy :: Sorting :: Beats 91.67% | greedy-sorting-beats-9167-by-akhil_pathi-l3s0 | 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 | akhil_pathivada_ | NORMAL | 2024-06-17T08:15:10.246198+00:00 | 2024-06-17T08:15:10.246227+00:00 | 8 | 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)$$ --... | 0 | 0 | ['Greedy', 'Sorting', 'Java'] | 0 |
maximum-number-of-consecutive-values-you-can-make | Nlog(N) || Easy to understand | nlogn-easy-to-understand-by-arpit2804-6b5i | \n\n# Code\n\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin(),coins.end());\n int l = 0,r=0;\n | arpit2804 | NORMAL | 2024-06-17T06:26:14.324557+00:00 | 2024-06-17T06:26:14.324592+00:00 | 2 | false | \n\n# Code\n```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin(),coins.end());\n int l = 0,r=0;\n int maxi = 0;\n for(int i=0;i<coins.size();i++){\n int newl = l+coins[i];\n int newr = r+coins[i];\n\n if(new... | 0 | 0 | ['Greedy', 'Sorting', 'C++'] | 0 |
maximum-number-of-consecutive-values-you-can-make | Basic greedy solution with some intuition | basic-greedy-solution-with-some-intuitio-9zvc | Intuition\n Describe your first thoughts on how to solve this problem. \nwhat is the amount you can reach with no coins? i.e 0 and with 1 coin of value 1? i.e 1 | Pawaneet56 | NORMAL | 2024-06-16T21:15:15.874275+00:00 | 2024-06-16T21:15:15.874313+00:00 | 8 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nwhat is the amount you can reach with no coins? i.e 0 and with 1 coin of value 1? i.e 1 , but what if i have another coin of value 3 then you will not be able to reach 2 , but if you had a coin of value 2 you can reach 2 , 3->(1+2) so the... | 0 | 0 | ['C++'] | 0 |
maximum-number-of-consecutive-values-you-can-make | scala unfold oneliner | scala-unfold-oneliner-by-vititov-h89z | same as "330. Patching Array" ( https://leetcode.com/problems/patching-array )\n\nobject Solution {\n def getMaximumConsecutive(coins: Array[Int]): Int =\n | vititov | NORMAL | 2024-06-16T12:46:57.299066+00:00 | 2024-06-16T12:46:57.299093+00:00 | 3 | false | same as "330. Patching Array" ( https://leetcode.com/problems/patching-array )\n```\nobject Solution {\n def getMaximumConsecutive(coins: Array[Int]): Int =\n (1 +: LazyList.unfold((1,coins.toList.sorted)){case (num, l) =>\n //Option.unless(l.headOption.forall(num < _)){(num+l.head,(num+l.head, l.tail))}\n ... | 0 | 0 | ['Greedy', 'Recursion', 'Line Sweep', 'Sorting', 'Scala'] | 0 |
maximum-number-of-consecutive-values-you-can-make | Easy C++ Greedy Solution With Explanation | easy-c-greedy-solution-with-explanation-vn8rj | Approach\nTo solve the problem, we can use a greedy algorithm. The key insight is to sort the coins and then iteratively check if the current coin can extend th | whatspumpkin | NORMAL | 2024-06-16T10:07:22.560733+00:00 | 2024-06-16T10:07:22.560763+00:00 | 19 | false | # Approach\nTo solve the problem, we can use a greedy algorithm. The key insight is to sort the coins and then iteratively check if the current coin can extend the range of consecutive values we can form.\n\n1. **Sort the Coins**:\n - First, we sort the array of coins. This allows us to consider the smallest coins f... | 0 | 0 | ['Greedy', 'C++'] | 0 |
maximum-number-of-consecutive-values-you-can-make | Simple C Solution | simple-c-solution-by-p_more-lhz0 | Code\n\nint cmp(const void * a , const void *b)\n{\n return *(int*)a - *(int*)b;\n}\nint getMaximumConsecutive(int* coins, int coinsSize) {\n int prev = 0 | P_More | NORMAL | 2024-06-16T09:28:25.516046+00:00 | 2024-06-16T09:28:25.516096+00:00 | 2 | false | # Code\n```\nint cmp(const void * a , const void *b)\n{\n return *(int*)a - *(int*)b;\n}\nint getMaximumConsecutive(int* coins, int coinsSize) {\n int prev = 0 ;\n qsort(coins,coinsSize,sizeof(int),cmp);\n for(int i = 0 ; i < coinsSize ; i++)\n {\n if(prev + 1 < coins[i])\n return prev ... | 0 | 0 | ['C'] | 0 |
maximum-number-of-consecutive-values-you-can-make | 1798. Maximum Number of Consecutive Values You Can Make.cpp | 1798-maximum-number-of-consecutive-value-gcu0 | Code\n\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin(),coins.end());\n int ans=0;\n in | 202021ganesh | NORMAL | 2024-06-16T08:16:13.779298+00:00 | 2024-06-16T08:16:13.779339+00:00 | 1 | false | **Code**\n```\nclass Solution {\npublic:\n int getMaximumConsecutive(vector<int>& coins) {\n sort(coins.begin(),coins.end());\n int ans=0;\n int curr=1;\n int n=coins.size();\n for( int i=0;i<n;i++){\n if(curr==coins[i]){ \n curr*=2;\n ... | 0 | 0 | ['C'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.