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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Python 3 || 2 lines, calculus problem || T/S: 96% / 58% | python-3-2-lines-calculus-problem-ts-96-hr9y8 | This is a multivariable calculus problem masquerading as a programming exercise.\n\nFirst, it\'s clear the optimum stategy is to perform the increment steps fir | Spaulding_ | NORMAL | 2024-03-24T17:47:01.618655+00:00 | 2024-10-27T16:25:08.087015+00:00 | 219 | false | This is a multivariable calculus problem masquerading as a programming exercise.\n\nFirst, it\'s clear the optimum stategy is to perform the increment steps first, then perform the duplicate steps.\n\nSecond, if we perform *x* increment steps and *y* duplicate steps, the total number of moves is expressed by the functi... | 10 | 0 | ['C++', 'Java', 'Python3'] | 2 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | 1-line ceil(sqrt(4*k))-2 arithmetic mean>=geometric mean | 1-line-ceilsqrt4k-2-arithmetic-meangeome-d4ss | Intuition\n Describe your first thoughts on how to solve this problem. \nLet a denote the times for increase its value by 1, and b denote the times for duplica | anwendeng | NORMAL | 2024-03-24T15:53:20.913170+00:00 | 2024-03-24T16:07:13.215192+00:00 | 150 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nLet a denote the times for increase its value by 1, and b denote the times for duplicating. Then we have \n$$(a+1)(b+1)\\geq k$$\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThen usual math\n$\\implies 1+(a+b)+ab... | 8 | 0 | ['Math', 'C++'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easiest Java Solution | easiest-java-solution-by-1asthakhushi1-swo6 | \n\nclass Solution {\n public int minOperations(int k) {\n int ans=Integer.MAX_VALUE;\n int final=0;\n for(int i=1;i<=k/2;i++){\n | 1asthakhushi1 | NORMAL | 2024-03-24T04:14:15.729483+00:00 | 2024-03-24T04:19:00.839155+00:00 | 556 | false | \n```\nclass Solution {\n public int minOperations(int k) {\n int ans=Integer.MAX_VALUE;\n int final=0;\n for(int i=1;i<=k/2;i++){\n // i=1--> 1+1+1+1+1+1+1+1+1+1+1 --> To get first 1 -->(1-1=0 operation) + leftover 10 more 1\'s --> final=10\n // i=2--> 2+2+2+2+2+2+2 --> To... | 8 | 0 | ['Java'] | 3 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | 3 lines Code || Easiest Possible Solution Ever || Beginner Friendly | 3-lines-code-easiest-possible-solution-e-63ug | APPROACH\n\nfor i in range(1, k + 1): This loop iterates over numbers from 1 to k inclusive. It represents the number of groups we are going to divide the input | sumit4199 | NORMAL | 2024-03-24T04:26:55.776691+00:00 | 2024-03-24T04:57:12.403137+00:00 | 1,199 | false | # APPROACH\n\n**for i in range(1, k + 1):** This loop iterates over numbers from 1 to k inclusive. It represents the number of groups we are going to divide the input into.\n\n**res = min(res, i - 1 + (k + i - 1) // i - 1):** In this line, for each value of i, it calculates the number of operations needed based on the ... | 6 | 0 | ['Array', 'Hash Table', 'Two Pointers', 'Dynamic Programming', 'C', 'Python', 'C++', 'Java', 'Python3'] | 2 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | ✅ DP and Greedy | Recursive | Easy to Understand | 2 Solutions | dp-and-greedy-recursive-easy-to-understa-z7gu | 1. Dynamic Programming\nTried explaining the logic behind linear dp (Feel free to share your thoughts):\n\nThe Sum and Max are not that much different from each | spats7 | NORMAL | 2024-03-24T05:16:42.070882+00:00 | 2024-03-24T23:00:36.775768+00:00 | 559 | false | # 1. Dynamic Programming\n**Tried explaining the logic behind linear dp (Feel free to share your thoughts):**\n\nThe Sum and Max are not that much different from each other, and at any point, I am not considering the current sum to determine the max number of operations. Max is undergoing operations and it is having a ... | 3 | 0 | ['Dynamic Programming', 'Recursion', 'Memoization', 'Java'] | 6 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | ✅ 2 Approaches || 3Lines || 5 lines || Detailed Explaination || Optimal Solution || Beats 100% ✅ | 2-approaches-3lines-5-lines-detailed-exp-vcw2 | Intuition\nWe need to find two numbers for the minimum number of operations .\nFor eg. when k = 11 , 12 = 3X4 is the number we can obtain greater or equal than | TLE_17 | NORMAL | 2024-03-24T04:47:05.551718+00:00 | 2024-03-24T15:34:43.389057+00:00 | 259 | false | # Intuition\nWe need to find two numbers for the minimum number of operations .\nFor eg. when k = 11 , 12 = 3X4 is the number we can obtain greater or equal than 11 in min. operations.\nSo we will make [1]->[2]->[3]->[3,3]->[3,3,3]->[3,3,3,3]\nhere , [1]->[2]->[3]->[4]->[4,4]->[4,4,4] also possible as 12=4X3\n\n# Appr... | 3 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Python one-liner beats 100% TC=O(1) SC=O(1) | python-one-liner-beats-100-tco1-sco1-by-pd1x3 | Complexity\n- Time complexity:O(1)\n- Space complexity:O(1)\n\n# Code\n\nclass Solution:\n def minOperations(self, k: int) -> int:\n return ceil(sqrt( | Divyanshu52Singhal | NORMAL | 2024-03-24T04:42:09.543641+00:00 | 2024-03-24T04:42:09.543659+00:00 | 176 | false | # Complexity\n- Time complexity:O(1)\n- Space complexity:O(1)\n\n# Code\n```\nclass Solution:\n def minOperations(self, k: int) -> int:\n return ceil(sqrt(k)) -1 + k //ceil(sqrt(k)) - (k%ceil(sqrt(k))==0)\n``` | 3 | 0 | ['Math', 'Python3'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | [Python3] Math - Simple Solution | python3-math-simple-solution-by-dolong21-c7am | 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# Code\n\n##### 1. Br | dolong2110 | NORMAL | 2024-03-24T04:10:00.337283+00:00 | 2024-03-24T04:10:00.337311+00:00 | 293 | 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# Code\n\n##### 1. Brute-Force\n```\nclass Solution:\n def minOperations(self, k: int) -> int:\n res = k\n for i in range(1, math.ceil(math.sqrt(k))... | 3 | 0 | ['Math', 'Python3'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | [C++|Java|Python3|Javascript|Typescript] math | cjavapython3javascripttypescript-math-by-vz45 | Please pull this commit for my solutions of weekly 390. \n\nC++\n\nclass Solution {\npublic:\n int minOperations(int k) {\n int p = sqrt(k), q = (k+p- | ye15 | NORMAL | 2024-03-24T04:04:23.807062+00:00 | 2024-03-24T19:32:24.706969+00:00 | 654 | false | Please pull this [commit](https://github.com/gaosanyong/leetcode/commit/cdc5e101ce1f1fae525345dec774217fbbdba2c4) for my solutions of [weekly 390](https://leetcode.com/contest/weekly-contest-390/). \n\n**C++**\n```\nclass Solution {\npublic:\n int minOperations(int k) {\n int p = sqrt(k), q = (k+p-1)/p; \n ... | 3 | 0 | ['C', 'Java', 'TypeScript', 'Python3', 'JavaScript'] | 2 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Beats 100% | Best Solution | Less Code ✅✅ | beats-100-best-solution-less-code-by-ika-s5xl | Please Upvote \u2705\u2705\n\n# Code\n\nclass Solution {\n public int minOperations(int k) {\n if(k == 1) return 0;\n int ans = Integer.MAX_VA | Ikapoor123 | NORMAL | 2024-03-24T04:01:30.493484+00:00 | 2024-03-24T04:01:30.493507+00:00 | 170 | false | # Please Upvote \u2705\u2705\n\n# Code\n```\nclass Solution {\n public int minOperations(int k) {\n if(k == 1) return 0;\n int ans = Integer.MAX_VALUE;\n \n for(int i=1;i<k;i++){\n int steps = 0;\n int j=2;\n int number = i;\n while(number<k){\... | 3 | 0 | ['Math', 'Java'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | 100% Beats || C++ || O(1) || Maths | 100-beats-c-o1-maths-by-arrrrrpit-9ix1 | Intuition\nIt\'s optimal to first increase the value and then copy it.\n\n# Approach\nLet x be the value to which we will increase, and then we will multiply it | Arrrrrpit | NORMAL | 2024-07-02T09:30:25.628620+00:00 | 2024-07-02T09:31:07.887827+00:00 | 45 | false | # Intuition\nIt\'s optimal to first increase the value and then copy it.\n\n# Approach\nLet $$x$$ be the value to which we will increase, and then we will multiply it. Let $$f(x)$$ be the number of moves required to first turn $$1 \\rightarrow x$$ and then $$x \\rightarrow k$$. So, $$f(x) = (x - 1) + \\dfrac{k}{x}$$. T... | 2 | 0 | ['C++'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | O(1) Full Explanation Mathematical Solution with derivation of Formula | See It Once | | o1-full-explanation-mathematical-solutio-q9q4 | Intuition\n\nFirstly I went for Recursive Method to check the understanding of the question and it gave TLE (obvious) . I have posted that solution as well.\n\n | Divyansh__Gupta | NORMAL | 2024-05-30T08:42:46.607298+00:00 | 2024-05-30T08:42:46.607316+00:00 | 22 | false | # Intuition\n\nFirstly I went for Recursive Method to check the understanding of the question and it gave TLE (obvious) . I have posted that solution as well.\n\nThen after seeing it is Some formula based question I looked for hint where I got that we should first increment the number than copy the number in total sum... | 2 | 0 | ['Math', 'C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Simplest Math Logic | Inverted Parabola | C++ | simplest-math-logic-inverted-parabola-c-cjt5c | Intuition\n Describe your first thoughts on how to solve this problem. \nTo solve this problem, the first thought that should come to our mind is that for the o | looneyd_noob | NORMAL | 2024-03-24T18:47:17.764822+00:00 | 2024-03-24T18:54:44.653196+00:00 | 69 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTo solve this problem, the first thought that should come to our mind is that for the operations to be minimum we should `increment` the values at `first` then `duplicate` them. This is because if we duplicate at first, then we will be le... | 2 | 0 | ['Math', 'Binary Search', 'C', 'C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | [Python] brute force (beats 100%) | python-brute-force-beats-100-by-pbelskiy-i7pv | \nclass Solution:\n def minOperations(self, k: int) -> int:\n best = float(\'inf\')\n for n in range(1, 10**5):\n length = math.ceil | pbelskiy | NORMAL | 2024-03-24T16:21:13.112474+00:00 | 2024-03-24T16:21:13.112506+00:00 | 19 | false | ```\nclass Solution:\n def minOperations(self, k: int) -> int:\n best = float(\'inf\')\n for n in range(1, 10**5):\n length = math.ceil(k / n) # length of array of [n, n, ...]\n ops = (length - 1) + (n - 1) # operations to make such array \n if ops > best:\n ... | 2 | 0 | ['Python'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | 🔥1st and 2nd Operation Combination | Clean Code | C++ | | 1st-and-2nd-operation-combination-clean-xbcee | Code\n\nclass Solution {\npublic:\n int minOperations(int k) {\n if (k == 1)\n return 0;\n \n int cnt = INT_MAX;\n int | Antim_Sankalp | NORMAL | 2024-03-24T06:53:39.796061+00:00 | 2024-03-24T06:53:39.796088+00:00 | 401 | false | # Code\n```\nclass Solution {\npublic:\n int minOperations(int k) {\n if (k == 1)\n return 0;\n \n int cnt = INT_MAX;\n int num = 1;\n \n while (num <= k)\n {\n cnt = min(cnt, static_cast<int>(ceil(static_cast<double>(k) / num)) - 1 + (num - 1));... | 2 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Beats 100% ,C++ easy Maths Solution. | beats-100-c-easy-maths-solution-by-adity-g9z7 | Intuition\nTo use Maths to get the solution. The use of division felt easy. Just by dividing we have to think about increment. \n\n# Approach\nIncrement = i-1\ | adityamohanbhosale123 | NORMAL | 2024-03-24T04:59:26.350255+00:00 | 2024-03-24T04:59:26.350277+00:00 | 428 | false | # Intuition\nTo use Maths to get the solution. The use of division felt easy. Just by dividing we have to think about increment. \n\n# Approach\nIncrement = i-1\nDuplicates= (K/i)\nAnswer =Increment + Duplicates\nBut we have to look if remainder is present then, \nDuplicates=(K/i)+1\nThen we maintain Soluton variable ... | 2 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Mathematic approach. Beats 100%. Python 3 | mathematic-approach-beats-100-python-3-b-x70v | Intuition\n Describe your first thoughts on how to solve this problem. \nTry to brute force then realize the mathematic pattern\n\n# Approach\n Describe your ap | datluu | NORMAL | 2024-03-24T04:58:39.991491+00:00 | 2024-03-24T04:58:39.991519+00:00 | 42 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTry to brute force then realize the mathematic pattern\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Each step calculate maximum possible number we can get\n- For step i. It would span options of x * (i+2-x). l... | 2 | 0 | ['Python3'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easy to Understand O(k) -> O(1) Solution | easy-to-understand-ok-o1-solution-by-frv-7jqj | Solution 1 (Greedy)\nNot the fastest, but it works. \n\nUses the fact that we always increment (operation 1) before any duplications (operation 2) inorder to ma | frvnk | NORMAL | 2024-03-24T04:49:06.105433+00:00 | 2024-03-24T05:53:54.982084+00:00 | 211 | false | # Solution 1 (Greedy)\nNot the fastest, but it works. \n\nUses the fact that we always **increment** (operation 1) before any **duplications** (operation 2) inorder to maximize the total sum of our array.\n\nRuntime: $O(n)$\nSpace: $O(1)$\n\nIncrement $i$ times, value of array then $[i+1]$\nTakes $\\lceil\\frac{k}{i+1}... | 2 | 0 | ['C++'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | ✅ Java Solution | Easy to understand | java-solution-easy-to-understand-by-hars-5q97 | CODE\nJava []\npublic int minOperations(int k) {\n\tint min = k-1, sqrt=(int)Math.sqrt(k);\n\tfor(int i=2; i <= sqrt; i++){\n\t\tint div = k/i;\n\t\tif(k%i != 0 | Harsh__005 | NORMAL | 2024-03-24T04:15:22.690019+00:00 | 2024-03-24T04:15:22.690046+00:00 | 348 | false | ## **CODE**\n```Java []\npublic int minOperations(int k) {\n\tint min = k-1, sqrt=(int)Math.sqrt(k);\n\tfor(int i=2; i <= sqrt; i++){\n\t\tint div = k/i;\n\t\tif(k%i != 0) div++;\n\n\t\tint curr = i-1 + div - 1;\n\t\tmin = Math.min(curr, min);\n\t}\n\treturn min;\n}\n``` | 2 | 0 | ['Java'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easiest 5 ways in C++ / Python3 / Java / C / Python / C# -- Beats 100% | easiest-5-ways-in-c-python3-java-c-pytho-15hm | Intuition\n\n\n\n\nC++ []\nclass Solution {\npublic:\n int minOperations(int k) {\n int res = INT_MAX;\n for (int i = 0; i <= k; i++)\n | Edwards310 | NORMAL | 2024-03-24T04:15:11.165770+00:00 | 2024-03-24T04:55:35.258134+00:00 | 64 | false | # Intuition\n\n\n![Screenshot 2024-03-24 094022... | 2 | 0 | ['C', 'Python', 'C++', 'Java', 'Python3', 'C#'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | C++ binary search | c-binary-search-by-wufengxuan1230-01j2 | \nclass Solution {\npublic:\n int minOperations(int k) {\n int l = 0, r = k;\n auto check = [&](int m) {\n for (int i = 0; i <= m; + | wufengxuan1230 | NORMAL | 2024-03-24T04:07:58.602309+00:00 | 2024-03-24T04:08:06.654961+00:00 | 79 | false | ```\nclass Solution {\npublic:\n int minOperations(int k) {\n int l = 0, r = k;\n auto check = [&](int m) {\n for (int i = 0; i <= m; ++i) {\n if ((1 + i) * (m - i + 1) >= k) {\n return true;\n }\n }\n return false;\n ... | 2 | 0 | [] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | 🔥O(1) SC || ✅Easy MAth⚡ || 🌟Greedy | o1-sc-easy-math-greedy-by-adish_21-i6me | \n\n# Complexity\n\n- Time complexity:\nO(k)\n\n- Space complexity:\nO(1)\n\n\n# Code\n## PLease Upvote if it helps\uD83E\uDD17\n\nclass Solution {\npublic:\n | aDish_21 | NORMAL | 2024-03-24T04:02:19.289536+00:00 | 2024-03-24T05:13:38.843523+00:00 | 497 | false | \n\n# Complexity\n```\n- Time complexity:\nO(k)\n\n- Space complexity:\nO(1)\n```\n\n# Code\n## PLease Upvote if it helps\uD83E\uDD17\n```\nclass Solution {\npublic:\n int minOperations(int k) {\n if(k == 1)\n return 0;\n int mini = INT_MAX;\n for(int i = 1 ; i < k ; i++){\n ... | 2 | 0 | ['Math', 'Greedy', 'C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | C++ 100% Faster | Basic Mathematics | Easy Step By Step Explanation | c-100-faster-basic-mathematics-easy-step-fg0r | Intuition\nThe problem asks for the minimum number of operations to make the sum of an array with an initial value of 1 greater than or equal to k. We can think | VYOM_GOYAL | NORMAL | 2024-03-24T04:01:47.020280+00:00 | 2024-03-24T04:01:47.020300+00:00 | 243 | false | # Intuition\nThe problem asks for the minimum number of operations to make the sum of an array with an initial value of 1 greater than or equal to k. We can think of building the sum by increasing the first element and duplicating it. Since increasing by 1 is a single operation, we want to minimize the number of duplic... | 2 | 0 | ['Math', 'C++'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | math ^^ | math-by-andrii_khlevniuk-gnok | I misread the description and mised the fact that "the final array should be greater than or equal to k" and assumed that "the final array should be equal to k. | andrii_khlevniuk | NORMAL | 2024-08-29T21:19:06.616532+00:00 | 2024-08-30T00:53:58.242936+00:00 | 3 | false | I misread the description and mised the fact that "the final array should be **greater** than or equal to k" and assumed that "the final array should be **equal** to k. But it turned out that the solutions of these two slightly different problems are the same!\n\n```\nint minOperations(int k) \n{\n\treturn ceil(2*sqrt(... | 1 | 0 | ['C', 'C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easy Solution | Beats 100 % | Explanation | easy-solution-beats-100-explanation-by-k-slct | Approach\n Describe your approach to solving the problem. \nGreedy\n# Complexity\n- Time complexity:O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space | kmuhammadjon | NORMAL | 2024-04-22T06:58:03.240773+00:00 | 2024-04-22T06:58:03.240799+00:00 | 28 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\nGreedy\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\n```\nfunc minOperations(k int) int {\n if k == 1{\n ... | 1 | 0 | ['Math', 'Greedy', 'Enumeration', 'Go'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easest Solution with Greedy Approach || Beats 100 % of users | easest-solution-with-greedy-approach-bea-zgtb | Approach\n Describe your approach to solving the problem. \nGreedy approach\n# Complexity\n- Time complexity:O(n)\n Add your time complexity here, e.g. O(n) \n\ | Saidakbar_Zokirovich | NORMAL | 2024-04-22T06:57:01.033711+00:00 | 2024-04-22T06:57:01.033737+00:00 | 30 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\nGreedy approach\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\n```\nfunc minOperations(k int) int {\n number... | 1 | 0 | ['Greedy', 'Go'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | The Shortest Possible Mathematical Approach | the-shortest-possible-mathematical-appro-67vg | Intuition\nMagic math formula according to hints\n\n# Code\n\nvar minOperations = (k, x = k ** 0.5 | 0) => Math.ceil(k / x) + x - 2;\n | charnavoki | NORMAL | 2024-03-31T14:56:44.876297+00:00 | 2024-03-31T14:56:44.876319+00:00 | 14 | false | # Intuition\nMagic math formula according to hints\n\n# Code\n```\nvar minOperations = (k, x = k ** 0.5 | 0) => Math.ceil(k / x) + x - 2;\n``` | 1 | 0 | ['JavaScript'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easy C++ Solution || (3 line)✅✅ | easy-c-solution-3-line-by-abhi242-2hpl | Code\n\nclass Solution {\npublic:\n int minOperations(int k) {\n int i=1;\n int ans=INT_MAX;\n while(i<=k){\n ans=min(ans,(in | Abhi242 | NORMAL | 2024-03-26T12:58:52.705572+00:00 | 2024-03-26T12:58:52.705596+00:00 | 34 | false | # Code\n```\nclass Solution {\npublic:\n int minOperations(int k) {\n int i=1;\n int ans=INT_MAX;\n while(i<=k){\n ans=min(ans,(int)(i+ceil(k*1.0/i)-2));\n i++;\n }\n return ans;\n }\n};\n``` | 1 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | C++ / Beats 100% | c-beats-100-by-ak200199-qvkl | 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 | AK200199 | NORMAL | 2024-03-25T18:24:07.960874+00:00 | 2024-03-25T18:24:07.960908+00:00 | 5 | 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 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easy to Understand , Simple Mathematics | easy-to-understand-simple-mathematics-by-epi0 | Intuition\nIn this problem, we aim to find the minimum number of operations required to form a sum just greater than or equal to k. We increment the value by 1 | polisettys3 | NORMAL | 2024-03-24T20:49:27.094929+00:00 | 2024-03-24T20:49:27.094958+00:00 | 2 | false | # Intuition\nIn this problem, we aim to find the minimum number of operations required to form a sum just greater than or equal to k. We increment the value by 1 and then make multiples of it, checking the sum at each step. By tracking the number of steps taken to reach k, we determine the minimum operations required.\... | 1 | 0 | ['Math', 'C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easy greedy approach in python3 | easy-greedy-approach-in-python3-by-alexx-eiyg | Intuition\ngreedy + math\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nFirstly create a variable named toReach.\nThis variable wi | alexx290713 | NORMAL | 2024-03-24T18:11:22.690308+00:00 | 2024-03-24T18:11:22.690353+00:00 | 109 | false | # Intuition\ngreedy + math\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nFirstly create a variable named toReach.\nThis variable will store the square root value of k and it will tell the number of time you have to add 1 to the array.\nThen reduce that value from k as you have reac... | 1 | 0 | ['Math', 'Greedy', 'Python3'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Beats 100% | Intuitive and Simple math is all you need | Mathematics way | beats-100-intuitive-and-simple-math-is-a-ahf2 | Best Solution\n\n Describe your first thoughts on how to solve this problem. \n\n# Intuition\nFor every increment in number of operations, we are trying to find | K-Shashank | NORMAL | 2024-03-24T18:10:27.224624+00:00 | 2024-03-24T18:10:27.224645+00:00 | 58 | false | # Best Solution\n\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Intuition\nFor every increment in number of operations, we are trying to find wh... | 1 | 0 | ['Python3'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easy to Understand || C++ | easy-to-understand-c-by-sumitsaurabh20-c9n2 | \n\n# Code\n\nclass Solution {\npublic:\n int minOperations(int k) {\n int ans=k;\n for(int i=0;i<=k;i++){\n int sum=1+i;\n | sumitsaurabh20 | NORMAL | 2024-03-24T14:22:49.347410+00:00 | 2024-03-24T14:22:49.347427+00:00 | 33 | false | \n\n# Code\n```\nclass Solution {\npublic:\n int minOperations(int k) {\n int ans=k;\n for(int i=0;i<=k;i++){\n int sum=1+i;\n int left=k-sum;\n int dup=ceil((double)left/sum);\n ans=min(ans,dup+i);\n }\n return ans;\n }\n};\n``` | 1 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Solved using Binary Search | solved-using-binary-search-by-krishna_13-tqwf | Intuition\nBinary Search on answers \n\n\n# Code\n\n//Bineary Search solution : with slight better time complexity\nclass Solution {\n public int minOperatio | krishna_1307 | NORMAL | 2024-03-24T10:53:00.471275+00:00 | 2024-03-24T10:53:00.471296+00:00 | 81 | false | # Intuition\nBinary Search on answers \n\n\n# Code\n```\n//Bineary Search solution : with slight better time complexity\nclass Solution {\n public int minOperations(int k) {\n if (k == 1)\n return 0;\n int low = 0, high = k;\n int ans = 0;\n while (low <= high) {\n i... | 1 | 0 | ['Binary Search', 'Java'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Kotlin O(1) math solution | kotlin-o1-math-solution-by-chayangkoon-ayz5 | \n\n# Complexity\n- Time complexity:\nO(1)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\n fun minOperations(k: Int): Int {\n if(k == 1) | chayangkoon | NORMAL | 2024-03-24T10:50:07.921841+00:00 | 2024-03-24T10:50:07.921867+00:00 | 7 | false | \n\n# Complexity\n- Time complexity:\nO(1)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\n fun minOperations(k: Int): Int {\n if(k == 1) return 0\n val... | 1 | 0 | ['Kotlin'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easy Math Solution || C++ || Beats 100% | easy-math-solution-c-beats-100-by-ryuzak-jsdc | Intuition\nThe general idea is to notice that the solution will always be off the format --> \n\n"add 1 to [1] n times" + "add n to [n] to (k/n) times"\n\nThere | Ryuzakiiii | NORMAL | 2024-03-24T09:58:11.816369+00:00 | 2024-03-24T09:58:11.816408+00:00 | 4 | false | # Intuition\nThe general idea is to notice that the solution will always be off the format --> \n\n`"add 1 to [1] n times" + "add n to [n] to (k/n) times"`\n\nTherefore, the number of operations required with this kind of format can be written as a function of f(n) as follows : \n`f(n) = (k/n) + n`\n\nTo find the minim... | 1 | 0 | ['Math', 'C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | beats 100% || Best Solution | beats-100-best-solution-by-procodingskil-6sbb | 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 | procodingskills | NORMAL | 2024-03-24T09:24:04.029524+00:00 | 2024-03-24T09:24:04.029554+00:00 | 90 | 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:\nO(k)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n int minOperations(int k) {\n int ans=INT_MA... | 1 | 0 | ['C++'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easy Implementation base problem Solved in O(1) time and space | easy-implementation-base-problem-solved-9h63s | Intuition\nFirst I start with maximum possible answer and after that I tried to minimze it using min function \n\n# Approach\n Simple Observation based check co | saurabh_shashank7654 | NORMAL | 2024-03-24T09:01:50.543668+00:00 | 2024-03-24T09:01:50.543687+00:00 | 59 | false | # Intuition\n**First I start with maximum possible answer and after that I tried to minimze it using min function** \n\n# Approach\n Simple Observation based check code I belive you all will get the logic eventually \n\n# Complexity\n- Time complexity:O(1)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Spa... | 1 | 0 | ['C++'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | ✅Binary Search on Answer beats 100% 🔥 | binary-search-on-answer-beats-100-by-rau-8wk5 | \n\n---\n initialy, N=1\n let, one is added \'x\' times \n => N=1+x\n then duplicated \'y\' times\n => N = (1+x) + (1+x) * y\n => N = (1+x)(y+ | raunak_1611 | NORMAL | 2024-03-24T08:52:44.172622+00:00 | 2024-03-26T15:27:58.451032+00:00 | 54 | false | \n\n---\n initialy, N=1\n let, one is added \'x\' times \n => N=1+x\n then duplicated \'y\' times\n => N = (1+x) + (1+x) * y\n => N = (1+x)(y+1)\n\n N >= k\n =... | 1 | 0 | ['Math', 'Binary Search', 'C++'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easy Java Solution || T.C = O(1) || Beats 100% | easy-java-solution-tc-o1-beats-100-by-ra-ciyx | 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-03-24T08:28:46.914633+00:00 | 2024-03-24T08:28:46.914653+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)$$ --... | 1 | 0 | ['Java'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Python 3 solution based on Inequality | python-3-solution-based-on-inequality-by-pwet | Intuition\n\nDenote we need to make the \'add\' operation \'a\' times, and \'duplicate\' operation for \'b\'. We want to calculate the minmiun result for \'a+b\ | dliu5812 | NORMAL | 2024-03-24T07:24:16.572295+00:00 | 2024-03-24T07:24:16.572318+00:00 | 86 | false | # Intuition\n\nDenote we need to make the \'add\' operation \'a\' times, and \'duplicate\' operation for \'b\'. We want to calculate the minmiun result for \'a+b\', which meets the requirement:\n\n(1+a) * (1+b) >= k\n\n# Approach\n\nFor (1+a) * (1+b) >= k, we modify it as:\n\n(a+b)* (a+b) / 4 + (a+b) >= ab + (a+b) >= k... | 1 | 0 | ['Python3'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | JAVA | BINARY SEARCH | OPTIMAL | java-binary-search-optimal-by-priyadarsh-w9fn | Intuition:\nI couldn\'t solve this in today\'s contest, though got the intuiton half way. I have to find the minimum operations which give me the maximum output | Priyadarshi_codes | NORMAL | 2024-03-24T07:19:40.831056+00:00 | 2024-03-24T07:24:45.981690+00:00 | 14 | false | **Intuition**:\nI couldn\'t solve this in today\'s contest, though got the intuiton half way. I have to find the minimum operations which give me the maximum output closest to k. I may add on 1. And if I keep adding 1 till k, I get the maximum number of operations that lead me to k. But I am asked to find the minimum. ... | 1 | 0 | ['Binary Tree', 'Java'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Python3 Solution | python3-solution-by-subhash_2004-word | 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 | subhash_2004 | NORMAL | 2024-03-24T06:57:33.205882+00:00 | 2024-03-24T06:57:33.205910+00:00 | 22 | 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'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | ✅ C++ Solution ✅||🔥Greedy🔥|| With Approach | c-solution-greedy-with-approach-by-anshu-b8we | APPROACH\n Describe your approach to solving the problem. \n\n1. Number of 1\'s required to reach 1 to n equals to n-1\n2. Number of duplicate\'s required of a | anshumaan1024 | NORMAL | 2024-03-24T06:50:07.198782+00:00 | 2024-03-24T06:59:33.352830+00:00 | 69 | false | # APPROACH\n<!-- Describe your approach to solving the problem. -->\n\n1. Number of ```1```\'s required to reach ```1``` to ```n``` equals to ```n-1```\n2. Number of duplicate\'s required of any given number ```n``` to make the sum of elements of the final array greater than or equal to ```k``` is equals to ```ceil(k... | 1 | 0 | ['Math', 'Greedy', 'C++', 'Java'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easy C++ || O(k) time O(1) space beats 100% || In depth intuition and approach explained | easy-c-ok-time-o1-space-beats-100-in-dep-ipel | Intuition\n Describe your first thoughts on how to solve this problem. \n\nStart by considering the minimum number of operations required to achieve the target | anubhavchawla02 | NORMAL | 2024-03-24T06:27:43.413007+00:00 | 2024-03-24T14:25:04.304167+00:00 | 28 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nStart by considering the minimum number of operations required to achieve the target sum. Initially, set the number of operations to 0 and increment it gradually. At each step, determine the maximum sum that can be achieved with the cur... | 1 | 0 | ['Math', 'C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | C++ || Intuition Explained || Easy to Understand | c-intuition-explained-easy-to-understand-jzmf | Intuition\n Describe your first thoughts on how to solve this problem. \n- just try to find the solution in the given range \n\n# Approach\n Describe your appro | Aditya_Sahu_99 | NORMAL | 2024-03-24T06:26:17.705337+00:00 | 2024-03-24T06:26:17.705388+00:00 | 30 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- just try to find the solution in the given range \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- iterate through all the possible ans from `i=1 to i<=k` and return the minimum possible ans\n\n# Complexity\n- T... | 1 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | O(1) and O(n) method | Math vs Brute Force | Beginner friendly | o1-and-on-method-math-vs-brute-force-beg-9afr | Intuition\nWe will add first then multiply\nm is number of time we need to add 1.\nn is number of time we need to multiply.\n\n=> We need to find (1 + m) * (n + | dangnp | NORMAL | 2024-03-24T05:46:23.113840+00:00 | 2024-03-28T18:30:33.368394+00:00 | 112 | false | # Intuition\nWe will add first then multiply\n`m` is number of time we need to add `1`.\n`n` is number of time we need to multiply.\n\n=> We need to find `(1 + m) * (n + 1) >= k` in such way `m + n` is smallest. \n\n# Brute Force method\nTime complexity: $$O(n)$$\n\nWe can do the following:\n- Increase `m` from `0` to... | 1 | 0 | ['Math', 'Python', 'C++', 'Java', 'Python3', 'JavaScript'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Using bfs | using-bfs-by-rohit_new_0402-oubc | Intuition\n Describe your first thoughts on how to solve this problem. \nif youre using normal bfs method then it would give wrong answer \nso first you need to | rohit_new_0402 | NORMAL | 2024-03-24T05:30:11.468458+00:00 | 2024-03-24T05:30:11.468476+00:00 | 21 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nif youre using normal bfs method then it would give wrong answer \nso first you need to increase the num as you want by 1 . But once you start taking dublicate then after that only one operation left for you that is to dublicate the numbe... | 1 | 0 | ['Breadth-First Search', 'C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Brute Force || easy to understand | brute-force-easy-to-understand-by-oyjf01-6lcb | Intuition\n Describe your first thoughts on how to solve this problem. \nStarting from 1, we use a for loop to calculate the number of operations required to re | oyjf012 | NORMAL | 2024-03-24T05:03:59.450486+00:00 | 2024-03-24T05:03:59.450515+00:00 | 32 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nStarting from 1, we use a for loop to calculate the number of operations required to reach k. Until we find the optimal solution, the number of operations should be decreasing with each iteration. If the number of operations starts increa... | 1 | 0 | ['Java'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | C++ solution.. beats 100% | c-solution-beats-100-by-us_2010_er-h8w1 | Intuition\nFirst of all reach the smallest number which when duplicated will result in sum greater than equal to k this takes (minimum number-1) operations,then | us_2010_er | NORMAL | 2024-03-24T04:42:50.380400+00:00 | 2024-03-24T05:36:25.478596+00:00 | 36 | false | # Intuition\nFirst of all reach the smallest number which when duplicated will result in sum greater than equal to k this takes (minimum number-1) operations,then duplicate the minimum number got.\n\n# Complexity\n- Time complexity:\nO(sqrt(k))\n\n- Space complexity:\n O(1)\n\n# Code\n```\nclass Solution {\npublic:\n ... | 1 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | 100 % efficient & 0 ms time | 100-efficient-0-ms-time-by-shivnath-9by5 | Intuition\n Describe your first thoughts on how to solve this problem. \nHere we have to find out minimum no of operation so minimum value can be 0 and maximum | shivnath | NORMAL | 2024-03-24T04:31:02.145980+00:00 | 2024-03-24T04:31:02.146001+00:00 | 188 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nHere we have to find out minimum no of operation so minimum value can be 0 and maximum value can be k-1 so it is the concept of binary search problem.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nHere minimum va... | 1 | 0 | ['Binary Search', 'C++'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | [Java] Binary search, for those can't think up Math solutions like me ^^ | java-binary-search-for-those-cant-think-w5g7i | \n\n# Code\n\nclass Solution {\n int minStep = Integer.MAX_VALUE;\n int originK = 0;\n public int minOperations(int k) {\n if(k == 1) return 0;\ | yugong | NORMAL | 2024-03-24T04:22:07.645904+00:00 | 2024-03-24T04:24:45.384917+00:00 | 38 | false | \n\n# Code\n```\nclass Solution {\n int minStep = Integer.MAX_VALUE;\n int originK = 0;\n public int minOperations(int k) {\n if(k == 1) return 0;\n // if(k == 2) return 1;\n originK = k;\n helper(k);\n return minStep;\n }\n \n public void helper(int k){\n if(... | 1 | 0 | ['Binary Search', 'Java'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Break into 2 parts at each step | break-into-2-parts-at-each-step-by-mukul-4p53 | Complexity\n- Time complexity:\nO(k)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n int minOperations(int k) {\n if(k==1) retur | MukulDev007 | NORMAL | 2024-03-24T04:17:14.858681+00:00 | 2024-03-24T04:17:14.858711+00:00 | 9 | false | # Complexity\n- Time complexity:\n$$O(k)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n int minOperations(int k) {\n if(k==1) return 0;\n \n int ans = INT_MAX;\n \n for(int i=1 ; 2*i <= k; i++){\n int l = ceil(k / (1.0 * i));\n ... | 1 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easy To Understand || O(1) complexity || Math | easy-to-understand-o1-complexity-math-by-fkwy | 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 | sprashant1029 | NORMAL | 2024-03-24T04:08:14.151809+00:00 | 2024-03-24T04:08:14.151827+00:00 | 118 | 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(1)\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... | 1 | 0 | ['C++', 'Java'] | 2 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easy Solution in O(n) T.C | easy-solution-in-on-tc-by-sdkv-d703 | \n# Complexity\n- Time complexity:\nO(1)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n int minOperations(int k) {\n int mini=I | sdkv | NORMAL | 2024-03-24T04:04:55.656750+00:00 | 2024-03-24T04:04:55.656799+00:00 | 2 | false | \n# Complexity\n- Time complexity:\nO(1)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n int minOperations(int k) {\n int mini=INT_MAX;\n int n=1,ans=1;\n int operation=0;\n \n while (1) {\n int temp=operation;\n temp+=k/n;\n ... | 1 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Binary Search | binary-search-by-aswinnath123-4rzs | Approach\nUse low=1 and high=k and use check to find if its feasible.\n\n# Complexity\n- Time complexity: O(k*log k)\n- Space complexity: O(1)\n\n# Code\n\nclas | ASWINNATH123 | NORMAL | 2024-03-24T04:03:33.671489+00:00 | 2024-03-24T04:11:53.972293+00:00 | 90 | false | # Approach\nUse low=1 and high=k and use check to find if its feasible.\n\n# Complexity\n- Time complexity: O(k*log k)\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution:\n def minOperations(self, k: int) -> int:\n if k==1:\n return 0\n low=1\n high=k\n def check(val):\n ... | 1 | 0 | ['Binary Search', 'Python3'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Clean Java Solution || Weekly Contest | clean-java-solution-weekly-contest-by-sh-0wsz | Code\n\nclass Solution {\n public int minOperations(int k) {\n int ans = Integer.MAX_VALUE;\n int sum =1, temp =1;\n int oper = 0;\n | Shree_Govind_Jee | NORMAL | 2024-03-24T04:01:38.436765+00:00 | 2024-03-24T04:01:38.436786+00:00 | 138 | false | # Code\n```\nclass Solution {\n public int minOperations(int k) {\n int ans = Integer.MAX_VALUE;\n int sum =1, temp =1;\n int oper = 0;\n while(true){\n int count = oper;\n count += k/temp;\n if(k%temp != 0){\n count += 1;\n }\n ... | 1 | 0 | ['Array', 'Math', 'Suffix Array', 'Java'] | 1 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Without using sqrt achieve sqrt(k) time complexity | without-using-sqrt-achieve-sqrtk-time-co-qafv | IntuitionWe start with val = 1 and increment it while doing so remains efficient. The key idea is to minimize the total number of operations by balancing betwee | amanabiy | NORMAL | 2025-03-16T22:55:04.151345+00:00 | 2025-03-16T22:55:29.980409+00:00 | 2 | false | ## Intuition
We start with `val = 1` and increment it while doing so remains efficient. The key idea is to minimize the total number of operations by balancing between increments and division-like reductions.
## Complexity
- **Time Complexity:** O(sqrt(k)) — The maximum value of `val` we consider is around sqrt... | 0 | 0 | ['Enumeration', 'Rust'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | O(NlogN) | Math solution | onlogn-math-solution-by-coldkaushal-bs54 | Intuitionif we start with [1] and construct array in every move
0th move -> [1]
1st move -> [[2], [1, 1]]
2nd move -> [[3], [2,2], [1,1,1]]
3rd move -> [[4], [3 | coldKaushal | NORMAL | 2025-03-11T14:11:35.409342+00:00 | 2025-03-11T14:11:35.409342+00:00 | 3 | false | # Intuition
if we start with [1] and construct array in every move
0th move -> [1]
1st move -> [[2], [1, 1]]
2nd move -> [[3], [2,2], [1,1,1]]
3rd move -> [[4], [3,3], [2,2,2], [1,1,1,1]]
...
from the previous we either increment the val by 1 or we can duplicate it. Notice in any array of size>1, increasing an element... | 0 | 0 | ['Python3'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Beats 100% of C++ Users || Solution using math|{\ | beats-100-of-c-users-solution-using-math-t1s2 | IntuitionWe are tasked with constructing an array starting from [1] where we can:Increase any element by 1.Duplicate any element and append it to the array.The | dk8818604 | NORMAL | 2025-02-19T19:29:51.747156+00:00 | 2025-02-19T19:29:51.747156+00:00 | 5 | false | # Intuition
We are tasked with constructing an array starting from [1] where we can:
Increase any element by 1.
Duplicate any element and append it to the array.
The goal is to reach a sum of elements that is at least k, using the minimum number of operations.
The main observation here is that creating larger eleme... | 0 | 0 | ['Math', 'Greedy', 'Enumeration', 'C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Looks it's a math question | looks-its-a-math-question-by-linda2024-w1xy | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | linda2024 | NORMAL | 2025-02-04T22:05:08.544944+00:00 | 2025-02-04T22:05:08.544944+00:00 | 4 | 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 | ['C#'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Optimization Problem | optimization-problem-by-vadibaum-6ea8 | IntuitionMin Movements(x, y) = x + y
Constrained ASum(x, y) = (x + 1, y + 1) = kApproachMin Movements(x, y) = x + y
Constrained ASum(x, y) = (x + 1, y + 1) = kS | vadibaum | NORMAL | 2025-01-21T08:14:46.921177+00:00 | 2025-01-21T08:14:46.921177+00:00 | 11 | false | # Intuition
Min Movements(x, y) = x + y
Constrained ASum(x, y) = (x + 1, y + 1) = k
# Approach
<!-- Describe your approach to solving the problem. -->
Min Movements(x, y) = x + y
Constrained ASum(x, y) = (x + 1, y + 1) = k
Solving a Lagrangian,
get an answer sqrt(k) - 1
We need to check whatever it works for 2 * ... | 0 | 0 | ['Python3'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | The 2000th LC medium solved WOAH !!! Time = O(K) Space = O(1) Explicit | the-2000th-lc-medium-solved-woah-time-ok-ah6h | Intuition and ApproachSee problem titleComplexityK = #-given
Time complexity:
O(K)
Space complexity:
O(1) ( Explicit and Implicit )
Code | 2018hsridhar | NORMAL | 2025-01-08T02:26:22.987279+00:00 | 2025-01-08T02:26:22.987279+00:00 | 7 | false | # Intuition and Approach
See problem title
# Complexity
K = #-given
- Time complexity:
$$O(K)$$
- Space complexity:
$$O(1)$$ ( Explicit and Implicit )
# Code
```python3 []
'''
URL := https://leetcode.com/problems/apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k/description/
3091. Apply Operations to... | 0 | 0 | ['Math', 'Greedy', 'Enumeration', 'Python3'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | c++ math | c-math-by-vineeshrao-7q6h | IntuitionApproachComplexity
Time complexity:O(sqrt(k))
Space complexity:O(1)
Code | Vin342786 | NORMAL | 2024-12-20T03:53:36.328704+00:00 | 2024-12-20T03:53:36.328704+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:O(sqrt(k))
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$... | 0 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | 2 lines of code with O(1) complexity | 2-lines-of-code-with-o1-complexity-by-ch-blgv | key idea: let initally arr is [0], and to get minimum operation there should be a time incrementation followed by b times duplication. So, the problem can be wr | chtome | NORMAL | 2024-12-13T02:30:43.190990+00:00 | 2024-12-13T02:30:43.191018+00:00 | 3 | false | key idea: let initally arr is [0], and to get minimum operation there should be `a` time incrementation followed by `b` times duplication. So, the problem can be written as find `min(a+b)` given that `ab >= k`. If we simply use `AM >= GM` inequality, we can see `a` and `b` should be similar value or somewhat same. \n ... | 0 | 0 | ['Python'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easy solution | easy-solution-by-_jyoti_geek-fbcn | Code\njava []\nclass Solution {\n public int[] dp;\n\n public int minOperations(int k) {\n dp = new int[k + 1];\n for (int i = 0; i < dp.len | _jyoti_geek | NORMAL | 2024-12-06T07:05:28.494956+00:00 | 2024-12-06T07:05:28.494996+00:00 | 2 | false | # Code\n```java []\nclass Solution {\n public int[] dp;\n\n public int minOperations(int k) {\n dp = new int[k + 1];\n for (int i = 0; i < dp.length; i++) {\n dp[i] = -1;\n }\n return helper(k, 1, 1);\n }\n\n public int helper(int k, int prev, int sum) {\n if (s... | 0 | 0 | ['Math', 'Dynamic Programming', 'Java'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Check 2 or less near sqrt of K | Unique approach | Beats 100% Space and Time 🔥 | check-2-or-less-near-sqrt-of-k-unique-ap-x1tc | 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 | sahilraut22 | NORMAL | 2024-11-10T19:47:49.000355+00:00 | 2024-11-10T19:50:46.466541+00:00 | 2 | 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 | ['Math', 'C', 'C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Simple Math | simple-math-by-premkumarchilumula-fed5 | Intuition \n Simple math !\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n- Basic Math\n\n# Complexity\n- Time complexity: O(n) | PremKumarChilumula | NORMAL | 2024-11-06T09:58:52.380487+00:00 | 2024-11-06T09:58:52.380523+00:00 | 3 | false | # Intuition \n Simple math !\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n- Basic Math\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\n... | 0 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | reducing number of searches, beats 70% on time, 53% on space | reducing-number-of-searches-beats-70-on-it3d7 | Intuition\nsince this is a greedy algorithm based solution, we need a heusteric function that can help us optimise the the minimum operations required.\nfor any | cim3ZADdET | NORMAL | 2024-09-19T07:25:48.100228+00:00 | 2024-09-19T07:25:48.100261+00:00 | 0 | false | # Intuition\nsince this is a greedy algorithm based solution, we need a heusteric function that can help us optimise the the minimum operations required.\nfor any k, there are assured to be some operations by which we can exceed k. the most intuitive is: increase till k/2, then duplicate.\n```java []\nint minOps = k;\n... | 0 | 0 | ['Java'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | solved | solved-by-diorsalimov2006-2odt | 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 | diorsalimov2006 | NORMAL | 2024-09-19T06:02:23.356896+00:00 | 2024-09-19T06:02:23.356932+00:00 | 0 | 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 | ['Python'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | 0 ms Beats 100.00% | 0-ms-beats-10000-by-pribyte1-ns6u | Shortest Solution\n# Code\njava []\nclass Solution {\n public int minOperations(int k) {\n int p = (int) Math.sqrt(k), q = (k+p-1)/p; \n return | pribyte1 | NORMAL | 2024-09-03T04:37:33.684700+00:00 | 2024-09-03T04:37:33.684726+00:00 | 2 | false | Shortest Solution\n# Code\n```java []\nclass Solution {\n public int minOperations(int k) {\n int p = (int) Math.sqrt(k), q = (k+p-1)/p; \n return p + q - 2;\n }\n}\n``` | 0 | 0 | ['Java'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | javascript solution | javascript-solution-by-suhail_lc-21fo | Intuition\n Describe your first thoughts on how to solve this problem. \nto make the efficient \nwe\'ve to increment the array value by 1 N nimes, the N can be | suhail_lc | NORMAL | 2024-08-25T11:30:03.164063+00:00 | 2024-08-25T11:30:03.164092+00:00 | 7 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nto make the efficient \nwe\'ve to increment the array value by 1 N nimes, the N can be evaluated by iterating upto sqrt of k\nnext,instead of pushing the array we can just increment our move by one and iterating variable by value\nthus de... | 0 | 0 | ['JavaScript'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Square root is optimal | square-root-is-optimal-by-pranavkapparad-9fsc | \n\n# Code\n\nclass Solution:\n def minOperations(self, k: int) -> int:\n x = int(floor(sqrt(k)))\n res = x-1\n \n res += (ceil(k | pranavkapparad30 | NORMAL | 2024-08-17T06:42:53.984495+00:00 | 2024-08-17T06:42:53.984536+00:00 | 6 | false | \n\n# Code\n```\nclass Solution:\n def minOperations(self, k: int) -> int:\n x = int(floor(sqrt(k)))\n res = x-1\n \n res += (ceil(k/x) - 1)\n\n return res\n``` | 0 | 0 | ['Python3'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | 3ms Beats 100% | 3ms-beats-100-by-chenchewei-pcch | 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 | chenchewei | NORMAL | 2024-08-12T13:07:15.667943+00:00 | 2024-08-12T13:07:15.667972+00:00 | 2 | 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 | ['Swift'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Logical | Simple | logical-simple-by-yatishgarg_2002-l09i | Intuition\nJust thought of it as ormal mathematics. lets suppose we have done x increse opertaions and then multiply the final vale y times we can get >= k.\n\n | yatishgarg_2002 | NORMAL | 2024-07-28T05:48:01.683574+00:00 | 2024-07-28T05:48:01.683593+00:00 | 3 | false | # Intuition\nJust thought of it as ormal mathematics. lets suppose we have done x increse opertaions and then multiply the final vale y times we can get >= k.\n\n# Approach\nso eqaution will look like.\n(x+1)*y >= k\n\nso x*y >= k-y;\n\nthis shows us that y can at max go till 0 to k.\n\nso the x >= (k-y)/y;\n\nso now i... | 0 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Straight Forward Java Solution with complete explanation. O(√ k) Solution. | straight-forward-java-solution-with-comp-hwvl | APPROACH\n To get the minum operation we must apply maximum increment first and then duplicate it.\n to achieve this we will increament num each time and devide | vishwajeet_rauniyar | NORMAL | 2024-07-22T09:26:45.558724+00:00 | 2024-07-22T09:27:47.329767+00:00 | 3 | false | **APPROACH**\n* To get the minum operation we must apply maximum increment first and then duplicate it.\n* to achieve this we will increament num each time and devide it by k to get the steps.\n* iterating each step we would find the minimum..\n \tfor Example:\n \t\tsuppose K = 100\n \t\twe have: num = 1\n \t\tfirst it... | 0 | 0 | ['Math', 'Java'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | C++ solution | c-solution-by-oleksam-wzc7 | \n// Please, upvote if you like it. Thanks :-)\n// Runtime: 0 ms, faster than 100.00% of C++ online submissions for Apply Operations to Make Sum of Array Greate | oleksam | NORMAL | 2024-07-18T19:22:42.082024+00:00 | 2024-07-18T19:22:42.082055+00:00 | 1 | false | ```\n// Please, upvote if you like it. Thanks :-)\n// Runtime: 0 ms, faster than 100.00% of C++ online submissions for Apply Operations to Make Sum of Array Greater Than or Equal to k.\n// Memory Usage: 8 MB, less than 5.03% of C++ online submissions for Apply Operations to Make Sum of Array Greater Than or Equal to k.... | 0 | 0 | ['Math', 'Greedy', 'C', 'C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Easy C++ Solution | O(1) Solution | Calculus | easy-c-solution-o1-solution-calculus-by-234of | Intuition\nIt can be observed that first adding up elements to a certain extent and then duplicating the largest number will make the least number of moves to i | Maniii97 | NORMAL | 2024-07-17T19:41:37.060964+00:00 | 2024-07-17T19:41:37.060991+00:00 | 5 | false | # Intuition\nIt can be observed that first adding up elements to a certain extent and then duplicating the largest number will make the least number of moves to increase the sum. Our target is to find the extent upto which we add.\n# Approach\nBy further observation you can see that the extent upto which we have to inc... | 0 | 0 | ['Math', 'Greedy', 'C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Simple and Easy JAVA Solution using DP | simple-and-easy-java-solution-using-dp-b-ssl0 | 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 | Triyaambak | NORMAL | 2024-07-17T12:48:49.245868+00:00 | 2024-07-17T12:48:49.245894+00:00 | 4 | 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 | ['Dynamic Programming', 'Java'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | c++ o(1). | c-o1-by-cajung-z1s4 | 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 | cajung | NORMAL | 2024-07-16T09:23:22.164926+00:00 | 2024-07-16T09:23:22.164959+00:00 | 1 | 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)$$ -->\no(1);\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)... | 0 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Simplest solution, O(1), Math logic | simplest-solution-o1-math-logic-by-archi-of27 | Intuition:\nThe optimal strategy is to find a balance between increasing a single element and duplicating it. We want to create x copies of a number close to k/ | archie9211 | NORMAL | 2024-07-15T19:33:16.535898+00:00 | 2024-07-15T19:33:16.535918+00:00 | 1 | false | # Intuition:\nThe optimal strategy is to find a balance between increasing a single element and duplicating it. We want to create x copies of a number close to k/x, minimizing the total operations.\n\n# Explanation:\n1. We use Math.sqrt(k) to find an optimal balance between the number of copies and the value of each co... | 0 | 0 | ['Java'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | VERY OPTIMAL SOLUTION BEAT 100% | very-optimal-solution-beat-100-by-aniket-x0ly | 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 | Aniket_Jaiswal-013 | NORMAL | 2024-07-11T15:40:33.899350+00:00 | 2024-07-11T15:40:33.899385+00:00 | 1 | 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 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | 4 lines of code c++ solution | 4-lines-of-code-c-solution-by-mahindra20-fms6 | Complexity\n- Time complexity: O(k)\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 | mahindra2005 | NORMAL | 2024-07-11T10:21:42.340491+00:00 | 2024-07-11T10:21:42.340521+00:00 | 1 | false | # Complexity\n- Time complexity: $$O(k)$$\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 int minOperations(int k) {\n int ans = 1e9;\n for(int i=1;i<=k;i++){\n ... | 0 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | I am a WIZARD | i-am-a-wizard-by-sulohesh-tb9x | Intuition\nEQUATIONS!!\nYou can have function like,\nn+1 = k (No addition, just duplication)\n2(n-1)+2 = k (1 addition, then duplication)\n3(n-2)+3 = k (..)\n\n | sulohesh | NORMAL | 2024-07-06T20:26:07.169497+00:00 | 2024-07-06T20:26:07.169547+00:00 | 1 | false | # Intuition\nEQUATIONS!!\nYou can have function like,\nn+1 = k (No addition, just duplication)\n2(n-1)+2 = k (1 addition, then duplication)\n3(n-2)+3 = k (..)\n\nGeneral form:- x(n-(x-1))+x>k => xn-x(x-2)=k\n\nn > (k+x(x-2))/x (Greater than,since sum is greater than or equal to k)\n\nHence the ceil, i.r..\nn = ceil((k+... | 0 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Simple solution in C++ (well commented, runs in 0ms) | simple-solution-in-c-well-commented-runs-j034 | Intuition\nFirst, we need to take into account that we\'re not necessarily looking for a number with the exact same value.\n\nAfter that, we can notice two thin | NunoLealF | NORMAL | 2024-07-04T10:59:02.414974+00:00 | 2024-07-04T10:59:02.415003+00:00 | 0 | false | # Intuition\nFirst, we need to take into account that we\'re not necessarily looking for a number with the exact same value.\n\nAfter that, we can notice two things:\n- First, it\'s generally always more efficient to *first* increment the initial number, and then multiply it\n- Second, the maximum number we can get fol... | 0 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Basic thought process and in O(sqrt(k)). | basic-thought-process-and-in-osqrtk-by-a-2d5w | # Intuition \n\n\n\n\n\n\n# Complexity\n- Time complexity: O(sqrt(k)).\n\n\n- Space complexity: O(1).\n\n\n# Code\n\nclass Solution {\npublic:\n int minOpe | abhicalyptic | NORMAL | 2024-06-28T11:53:27.618009+00:00 | 2024-06-28T11:53:27.618040+00:00 | 2 | 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\n# Complexity\n- Time complexity: O(sqrt(k)).\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1).\n<!-- Add your s... | 0 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | C++ easy approach, understandable | c-easy-approach-understandable-by-wourt-jprf | Intuition\n Describe your first thoughts on how to solve this problem. \nGreedy approach to find the highest value per operations\n# Approach\n Describe your ap | wourt | NORMAL | 2024-06-24T01:31:07.164032+00:00 | 2024-06-24T01:31:07.164062+00:00 | 5 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nGreedy approach to find the highest value per operations\n# Approach\n<!-- Describe your approach to solving the problem. -->\n we start from array n which is [1], which we declare x = value of array, and mul = size of array, and we ca... | 0 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | [C++] One-liner, Greedy | c-one-liner-greedy-by-amanmehara-ampe | Increase the only element by 1 until it is \geq \sqrt{k}.\n2. Duplicate the element until sum \geq k. \n\n# Complexity\n- Time complexity: O(\sqrt{k})\n- Space | amanmehara | NORMAL | 2024-06-11T05:10:06.407051+00:00 | 2024-06-11T05:15:42.529747+00:00 | 6 | false | 1. Increase the only element by 1 until it is $$\\geq \\sqrt{k}$$.\n2. Duplicate the element until $$sum \\geq k$$. \n\n# Complexity\n- Time complexity: $$O(\\sqrt{k})$$\n- Space complexity: $$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n int minOperations(int k) {\n return ceil(sqrt(k)) + ceil(static_ca... | 0 | 0 | ['Math', 'Greedy', 'C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | EASY BY PRINCE GANESHWALA | easy-by-prince-ganeshwala-by-princeganes-ey3a | 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 | PrinceGaneshwala | NORMAL | 2024-06-08T07:17:21.878996+00:00 | 2024-06-08T07:17:21.879027+00:00 | 0 | 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 | ['Java'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | O((logk )*(logk)) and O(1) solution using nested binary search; | ologk-logk-and-o1-solution-using-nested-a1p3p | Intuition\n Describe your first thoughts on how to solve this problem. \nwe just check from 1 to k if at any point using that ammount f operation it is possible | kishansinhpuvar89 | NORMAL | 2024-06-06T07:23:41.250603+00:00 | 2024-06-06T07:23:41.250628+00:00 | 0 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nwe just check from 1 to k if at any point using that ammount f operation it is possible to get sum>=k if yes the we store that point in as ans and move to left part for finding minimum possible else we move to right part .\n\n\n\n# Approa... | 0 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | 3091. Apply Operations to Make Sum of Array Greater Than or Equal to k in Java by Coding_Sanjay | 3091-apply-operations-to-make-sum-of-arr-lahr | \n\n# Code\n\nclass Solution {\n public int minOperations(int k) {\n \n if (k <= 1) return 0;\n \n int min = Integer.MAX_VALUE;\n | Sanjay_kumar14 | NORMAL | 2024-06-05T18:33:41.551430+00:00 | 2024-06-05T18:33:41.551457+00:00 | 0 | false | \n\n# Code\n```\nclass Solution {\n public int minOperations(int k) {\n \n if (k <= 1) return 0;\n \n int min = Integer.MAX_VALUE;\n \n for (int i=1; i<=k/2; i++) {\n for(int j=1; j<=k; j++) {\n if(i*j >= k && min > (i+j)-2) {\n m... | 0 | 0 | ['Java'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Fastest solution cpp | fastest-solution-cpp-by-bhanu_pratap5-tu7y | 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 | bhanu_pratap5 | NORMAL | 2024-06-01T16:42:10.899627+00:00 | 2024-06-01T16:42:10.899657+00:00 | 1 | 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 | ['Binary Search', 'C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | 100% beat simple solution Math | 100-beat-simple-solution-math-by-ashutos-8qrr | 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 | ashutoshup | NORMAL | 2024-05-28T02:50:42.184353+00:00 | 2024-05-28T02:50:42.184371+00:00 | 1 | 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 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | best c++ solution 100% beat | best-c-solution-100-beat-by-sada_nayak-7brl | 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 | sada_nayak | NORMAL | 2024-05-25T06:55:57.279627+00:00 | 2024-05-25T06:55:57.279658+00:00 | 2 | 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(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.... | 0 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | simple straight forward approach | simple-straight-forward-approach-by-gant-fww8 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nSure, here\'s a concise | GantlaRahul | NORMAL | 2024-05-21T17:28:10.177632+00:00 | 2024-05-21T17:28:10.177664+00:00 | 1 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nSure, here\'s a concise explanation of the code:\n\nThe Java method `minOperations` calculates the minimum number of operations needed to reach the value `k` starting ... | 0 | 0 | ['Java'] | 0 |
minimum-bit-flips-to-convert-number | Most easy || beats 100% || Best Solution || All languages | most-easy-beats-100-best-solution-all-la-84tu | \n\n# Intuition\nThe question asks how few bit flips are necessary to change one integer into another. It follows easily that the bits of the two numbers can be | raghavagarwal28 | NORMAL | 2024-09-10T12:00:07.317772+00:00 | 2024-09-11T13:08:33.818651+00:00 | 32,401 | false | \n\n# Intuition\nThe question asks how few bit flips are necessary to change one integer into another. It follows easily that the bits of the two numbers can be compared. The amount o... | 195 | 7 | ['Bit Manipulation', 'Python', 'C++', 'Java', 'Python3', 'JavaScript'] | 21 |
minimum-bit-flips-to-convert-number | [C++] 1 liner[xor,count set bits] | c-1-linerxorcount-set-bits-by-prilily-beng | To get minimum bit flips we find XOR of two number : which have set bits only at those places where A differs from B. \nSo, after getting the xor ( a ^ b ) , we | prilily | NORMAL | 2022-04-02T16:02:10.759478+00:00 | 2022-04-02T16:02:10.759508+00:00 | 11,454 | false | To get minimum bit flips we find XOR of two number : which have set bits only at those places where A differs from B. \nSo, after getting the **xor** `( a ^ b )` , we need to count the number of set bits.\nWe can do that using **__builtin_popcount(i)**: This function is used to count the number of set bits in an intege... | 73 | 1 | ['C'] | 13 |
minimum-bit-flips-to-convert-number | One liners | Have a look | one-liners-have-a-look-by-surajthapliyal-9b0o | Number of different bits is the required bits to flip, to make start and goal same.\nWe can efficiently calculate them using xor operation : \n\nJava one liner | surajthapliyal | NORMAL | 2022-04-03T16:38:31.243448+00:00 | 2022-04-03T16:41:56.165298+00:00 | 6,391 | false | Number of different bits is the required bits to flip, to make start and goal same.\nWe can efficiently calculate them using xor operation : \n\n**Java one liner :** \n```\npublic int minBitFlips(int start, int goal) {\n return Integer.bitCount(start^goal);\n}\n```\n\n\n**CPP one liner :**\n```\nint minBitFlips(... | 40 | 0 | ['Python', 'C++', 'Java', 'JavaScript'] | 7 |
minimum-bit-flips-to-convert-number | [Python/Java/C++] Solution without XOR | pythonjavac-solution-without-xor-by-keio-pzuv | Divmod Remainder Approach:\n#### Time Complexity: O(log(min(s,g))) --> O(log(n)) \n#### Space Complexity: O(1)\n\nWe divide s and q by 2 until either s or g equ | keioon | NORMAL | 2022-11-03T21:03:41.671314+00:00 | 2023-03-14T19:28:56.710857+00:00 | 2,935 | false | # Divmod Remainder Approach:\n#### Time Complexity: O(log(min(s,g))) --> O(log(n)) \n#### Space Complexity: O(1)\n\nWe divide s and q by 2 until either s or g equals zero.\nDuring this process, if the remainder of either of them **do not** equal eachother, we increment the counter.\n\n***This process is similar to conv... | 35 | 0 | ['Python', 'Python3'] | 5 |
minimum-bit-flips-to-convert-number | C++ || 2 methods || 1-Line Solution | c-2-methods-1-line-solution-by-raghav_ma-bre0 | Method-1\n\nWe find last bit of both start and goal by two and check if the bit is same or not. Then divide the numbers by 2.\n\n\nclass Solution {\npublic:\n | raghav_maskara | NORMAL | 2022-04-02T17:06:03.318755+00:00 | 2022-04-02T17:06:03.318798+00:00 | 4,081 | false | ## Method-1\n\nWe find last bit of both start and goal by two and check if the bit is same or not. Then divide the numbers by 2.\n\n```\nclass Solution {\npublic:\n int minBitFlips(int start, int goal) {\n int ans=0;\n while(start>0 or goal>0){\n int temp1=start%2;\n int temp2=goa... | 28 | 1 | ['C'] | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.