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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
maximum-xor-after-operations | ✅ One Line Solution | one-line-solution-by-mikposp-wpwr | Time complexity: O(n). Space complexity: O(1). | MikPosp | NORMAL | 2024-11-20T13:56:15.393868+00:00 | 2025-04-06T09:27:38.968992+00:00 | 40 | false | Time complexity: $$O(n)$$. Space complexity: $$O(1)$$.
```python3
class Solution:
def maximumXOR(self, a: List[int]) -> int:
return reduce(or_,a)
``` | 2 | 0 | ['Array', 'Bit Manipulation', 'Python', 'Python3'] | 0 |
maximum-xor-after-operations | Simple bit manipulation solution with explanation | simple-bit-manipulation-solution-with-ex-nn7n | Intuition\n Describe your first thoughts on how to solve this problem. \n- You may see that AND operator will always reduce number of bits. Therefore nums[i] AN | trieutrng | NORMAL | 2024-10-09T07:44:05.472732+00:00 | 2024-10-09T07:52:31.552949+00:00 | 59 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- You may see that AND operator will always reduce number of bits. Therefore nums[i] AND (nums[i] XOR x) will be used to turn off bits\n- When we XOR all numbers of an array $$[a1, a2, a3, ...]$$, all the bits whose occurences is even num... | 2 | 0 | ['Math', 'Bit Manipulation', 'Python3'] | 0 |
maximum-xor-after-operations | [Python] OR all elements | python-or-all-elements-by-pbelskiy-4n7k | python\n"""\nFirst of all it\'s easy taks, if we look create table of binary \nrepresentation of nums, it will be clear that anser is OR sum.\n\nFor example [1, | pbelskiy | NORMAL | 2023-09-25T15:49:43.143417+00:00 | 2023-09-25T15:49:43.143465+00:00 | 143 | false | ```python\n"""\nFirst of all it\'s easy taks, if we look create table of binary \nrepresentation of nums, it will be clear that anser is OR sum.\n\nFor example [1,2,3,9,2]\n\n1 - 0001\n2 - 0010\n3 - 0011\n9 - 1001\n2 - 0010\n\nUsing `nums[i] AND (nums[i] XOR x)` we actually can zero any i th bit.\n\nSo it\'s clear that... | 2 | 0 | ['Python'] | 0 |
maximum-xor-after-operations | Maximum XOR After Operations Solution in C++ | maximum-xor-after-operations-solution-in-ech8 | 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 | The_Kunal_Singh | NORMAL | 2023-04-22T06:46:32.575709+00:00 | 2023-04-27T16:28:27.695775+00:00 | 336 | 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(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$... | 2 | 0 | ['C++'] | 0 |
maximum-xor-after-operations | Python One Line (Detailed Explanation) | python-one-line-detailed-explanation-by-4e5rl | Intuition\n Describe your first thoughts on how to solve this problem. \nThis problem relies on a few key observations made in sequence, which lend themselves t | likey_00 | NORMAL | 2023-03-25T04:17:50.509652+00:00 | 2023-03-25T04:17:50.509700+00:00 | 418 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThis problem relies on a few key observations made in sequence, which lend themselves to a very elegant solution.\n\nObservation 1: Since x is arbitrary, we can make (nums[i] XOR x) anything we like. For a given target number T = (nums[i]... | 2 | 0 | ['Python3'] | 0 |
maximum-xor-after-operations | [Java] %100 O(n) | java-100-on-by-zeldox-letz | \n# Approach\n Describe your approach to solving the problem. \nXOR means check all the bits and make or operations so if we apply this for all the array member | zeldox | NORMAL | 2023-01-10T10:58:52.284427+00:00 | 2023-01-10T10:58:52.284470+00:00 | 1,206 | false | \n# Approach\n<!-- Describe your approach to solving the problem. -->\nXOR means check all the bits and make or operations so if we apply this for all the array member we can reach the maximum value\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$ \n- Space complexity:\... | 2 | 0 | ['Java'] | 0 |
maximum-xor-after-operations | Bitmanipulation | bitmanipulation-by-mani_himanshu-2k5d | Intuition\n Describe your first thoughts on how to solve this problem. \n Bit Manipulation.\n Here we have A & (A ^ B), now if A = 9 (ie 1 0 0 1), now A & | Mani_Himanshu | NORMAL | 2022-12-31T17:13:36.822891+00:00 | 2022-12-31T17:14:46.515454+00:00 | 477 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n Bit Manipulation.\n Here we have A & (A ^ B), now if A = 9 (ie 1 0 0 1), now A & (A ^ B) can not be more than 9, because we are anding A ^ B with A, so here we know that iff the bit is 1 it can be 0, but we can not make 0 to 1.\n ... | 2 | 0 | ['Java'] | 1 |
maximum-xor-after-operations | C++ || Well-commented || Brute force approach || Bitmasks || Clean solution | c-well-commented-brute-force-approach-bi-6jsc | \n/* Intution -> \n If we write the binary representation of the nums, we can observe that \n if we manage to find atleast one setbit at that position ac | jainshreyansh163 | NORMAL | 2022-10-31T11:33:48.600355+00:00 | 2022-10-31T11:33:48.600398+00:00 | 68 | false | ```\n/* Intution -> \n If we write the binary representation of the nums, we can observe that \n if we manage to find atleast one setbit at that position across nums, \n\tthen we can simply take its contribution bcoz on changing a number \n\tby the given AND operation, we won\'t end up with a setbit.\n\t( 0&0=1 ... | 2 | 0 | ['C', 'Bitmask'] | 0 |
maximum-xor-after-operations | ✅Two Approaches || Easy, Short & Best Code in C++✅✅ | two-approaches-easy-short-best-code-in-c-tpuo | Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(1)\n\n# Code\nPlease Upvote if u liked my Solution\uD83D\uDE42\n\n1st Approach:-\n\nclass Solution | aDish_21 | NORMAL | 2022-10-22T09:46:53.427755+00:00 | 2022-10-22T09:57:39.072858+00:00 | 588 | false | # Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(1)\n\n# Code\n**Please Upvote if u liked my Solution**\uD83D\uDE42\n\n***1st Approach:-***\n```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int xoR=0;\n for(auto it:nums)\n xoR |= it;\n return xoR;\n... | 2 | 0 | ['Array', 'Math', 'Bit Manipulation', 'C++'] | 1 |
maximum-xor-after-operations | 70% BEATS || EASY || SIMPLE || C++ || TIME O(1) || SPACE O(1) | 70-beats-easy-simple-c-time-o1-space-o1-xscl9 | \nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n vector<int> v(32,0);\n int j = 0;\n for(auto &i: nums){\n | abhay_12345 | NORMAL | 2022-09-08T07:50:20.988564+00:00 | 2022-09-08T07:50:20.988611+00:00 | 339 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n vector<int> v(32,0);\n int j = 0;\n for(auto &i: nums){\n j = 0;\n while(i){\n v[j] += i&1;\n i = i >> 1;\n j++;\n }\n }\n int ans = ... | 2 | 0 | ['Bit Manipulation', 'C', 'C++'] | 0 |
maximum-xor-after-operations | 2 Solutions | OR and Bit Shifting | Python | 2-solutions-or-and-bit-shifting-python-b-ho2l | Intuition\nWe have to use AND (&) after some XOR (^) operation.\n\nApplying & will not be able to toggle bits set to 0 into 1.\n\nApplying XOR ^ we are able to | nadaralp | NORMAL | 2022-06-26T16:08:45.455334+00:00 | 2022-06-26T16:08:45.455383+00:00 | 126 | false | # Intuition\nWe have to use AND (&) after some XOR (^) operation.\n\nApplying `&` will not be able to toggle bits set to 0 into 1.\n\nApplying XOR `^` we are able to flip the bits.\n\nThe idea is to flip all the bits we can to 1, by doing this we will be able to maximize the result. \n\nFor example if we are able to f... | 2 | 0 | ['Python'] | 0 |
maximum-xor-after-operations | C++ O(32*n) code with Detailed Explanation | c-o32n-code-with-detailed-explanation-by-bwi4 | Observe that a&(a^x) = (a&a)^(a&x) = a^(a&x)\nObserve that (a&x) will be set only on those bits which is already 1.\nie. if a has a binary representation of \n\ | akshatanand186 | NORMAL | 2022-06-26T09:43:17.998179+00:00 | 2022-06-26T09:43:17.998207+00:00 | 48 | false | Observe that **a&(a^x) = (a&a)^(a&x) = a^(a&x)**\nObserve that **(a&x)** will be set only on those bits which is already 1.\nie. if a has a binary representation of \n\na = 100011\nthen a&x can be 100001, 100010, 100011, 000011, 000010, 000001, 000000.\n\nNow the XOR of this A&X will make those bits off which is presen... | 2 | 0 | [] | 0 |
maximum-xor-after-operations | Java || simple || explanation O(31 * N) | java-simple-explanation-o31-n-by-lagahua-tbty | if we consider ith bit of numbers then we can notice that \n if the number of set bits are odd then XOR of that position will be 1.\n if the number of set bits | lagaHuaHuBro | NORMAL | 2022-06-25T19:06:15.899306+00:00 | 2022-06-25T19:10:24.713707+00:00 | 36 | false | if we consider ```ith``` bit of numbers then we can notice that \n* if the number of set bits are odd then ```XOR``` of that position will be ```1```.\n* if the number of set bits are even then ```XOR``` of that position will be ```0```.\n\nwe know that taking ```and``` of a number with any other number can never incre... | 2 | 0 | [] | 0 |
maximum-xor-after-operations | C++ || Clean and concise solution || O(n) time O(1) space | c-clean-and-concise-solution-on-time-o1-38zzv | \nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n long long k=0;\n int ans=0;\n for(int i=0;i<32;i++)\n {\n | ashay028 | NORMAL | 2022-06-25T17:12:48.222166+00:00 | 2022-06-25T17:13:24.114835+00:00 | 78 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n long long k=0;\n int ans=0;\n for(int i=0;i<32;i++)\n {\n k= (1<<i);\n for(auto &it : nums)\n {\n if(it&k)\n {\n ans+=(1<<i);\n ... | 2 | 0 | [] | 0 |
maximum-xor-after-operations | Python | O(n) Explanation for people struggling with Bitwise. | python-on-explanation-for-people-struggl-yiwf | Things to notice\n\nAND Operator\n\nBasically i AND j is used to find the bits set in both i and j.\nFor example.\n\nBitwise AND of 1001010, 1001100 is\n1001010 | surajajaydwivedi | NORMAL | 2022-06-25T17:12:46.331031+00:00 | 2022-06-25T18:03:14.773340+00:00 | 78 | false | **Things to notice**\n\n**AND Operator**\n\nBasically *i AND j* is used to find the bits set in both *i* and *j*.\nFor example.\n\nBitwise AND of 1001010, 1001100 is\n1001010\n1001100\n*=*\n1001000\n\nSo we can realise that \n* no new bit can be set by the AND operator.\n* AND of any number with 0 is 0.\n* To unset ith... | 2 | 0 | ['Python'] | 0 |
maximum-xor-after-operations | javascript greedy two solutions OR of All 86ms + check ith bit 204ms | javascript-greedy-two-solutions-or-of-al-fn38 | key point: make each i\'th bit only has one 1\'s\n\nconst maximumXOR = (a) => {\n let res = 0;\n for (const x of a) res |= x;\n return res;\n};\n\nSolu | henrychen222 | NORMAL | 2022-06-25T16:14:24.659132+00:00 | 2022-06-25T17:52:57.428065+00:00 | 106 | false | key point: make each i\'th bit only has one 1\'s\n```\nconst maximumXOR = (a) => {\n let res = 0;\n for (const x of a) res |= x;\n return res;\n};\n```\nSolution 2: check each bit if it has one, has, add the mask value to res\n204ms\n```\nconst bit = 27; // cover 10 ^ 8\nconst checkIthBit = (x, i) => x & (1 <<... | 2 | 0 | ['Bit Manipulation', 'JavaScript'] | 0 |
maximum-xor-after-operations | C++ | Bit manipulation | c-bit-manipulation-by-amirkpatna-c20w | \nclass Solution {\npublic:\n int maximumXOR(vector<int>& v) {\n vector<bool> cnt(31);\n for(int x:v){\n int i=0;\n for(i | amirkpatna | NORMAL | 2022-06-25T16:01:52.103149+00:00 | 2022-06-25T16:08:03.665994+00:00 | 220 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& v) {\n vector<bool> cnt(31);\n for(int x:v){\n int i=0;\n for(int i=0;x;i++){\n if(x&1)cnt[i]=true;\n x>>=1;\n }\n }\n int ans=0;\n for(int i=0;i<31;i++){\n ... | 2 | 0 | ['C++'] | 0 |
maximum-xor-after-operations | ✔ Python3 Solution | O(n) | python3-solution-on-by-satyam2001-n3zs | Time : O(n)\nSpace : O(1)\n\n\nclass Solution:\n def maximumXOR(self, nums: List[int]) -> int:\n res = 0\n for i in nums:\n res |= i | satyam2001 | NORMAL | 2022-06-25T16:01:50.925032+00:00 | 2022-06-25T16:01:50.925078+00:00 | 221 | false | ```Time``` : ```O(n)```\n```Space``` : ```O(1)```\n\n```\nclass Solution:\n def maximumXOR(self, nums: List[int]) -> int:\n res = 0\n for i in nums:\n res |= i\n return res\n``` | 2 | 0 | ['Python'] | 1 |
maximum-xor-after-operations | O(1) Solution with simple approach | C++ | explained | o1-solution-with-simple-approach-c-expla-psqm | We can make change 1 to 0 but can\'t change 0 to 1 in num[i]\n 2. ( n&(n^x) ) => ith bit of n is 0 zero then it will be zero always ans & operation is fina | aynburnt | NORMAL | 2022-06-25T16:00:52.989366+00:00 | 2022-06-25T16:04:14.249934+00:00 | 183 | false | 1. We can make change 1 to 0 but can\'t change 0 to 1 in num[i]\n 2. ( n&(n^x) ) => ith bit of n is 0 zero then it will be zero always ans & operation is final operation\n=> **so count for every bit if at least 1 set bit is there then take it into answer;**\n```\nint maximumXOR(vector<int>& nums) {\n int an... | 2 | 0 | ['C++'] | 0 |
maximum-xor-after-operations | C++ | Easy Solution | 12 Lines of Code | c-easy-solution-12-lines-of-code-by-char-txry | \nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int x_or = 0;\n for(int i=31;i>=0;i--)\n {\n for(auto x:n | charitramehlawat | NORMAL | 2022-06-25T16:00:43.764004+00:00 | 2022-06-25T16:06:24.967557+00:00 | 195 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int x_or = 0;\n for(int i=31;i>=0;i--)\n {\n for(auto x:nums)\n {\n if(((x>>i)&1)==1)// If 1 bit is present then all the other ith bits can be disabled using the above given operation and ... | 2 | 0 | ['C', 'C++'] | 0 |
maximum-xor-after-operations | AAAAAAAAAAAAAAAAAAAAAAAAAAAAA | aaaaaaaaaaaaaaaaaaaaaaaaaaaaa-by-danisde-n54w | Code | DanisDeveloper | NORMAL | 2025-03-14T22:35:09.643822+00:00 | 2025-03-14T22:35:09.643822+00:00 | 11 | false |
# Code
```kotlin []
class Solution {
fun maximumXOR(nums: IntArray): Int {
var result = 0
for(i in nums.indices){
result = result or nums[i]
}
return result
}
}
``` | 1 | 0 | ['Kotlin'] | 0 |
maximum-xor-after-operations | Bitwise OR | Beats 100%, 0ms, C# | bitwise-or-beats-100-0ms-c-by-bkga9sasfa-jscz | ApproachThe operation described in the task lets us delete any set bits in any number. Therefore the maximum XOR, after applying operations, contains a 1 at all | bKGa9sAsfA | NORMAL | 2025-03-06T09:39:47.902483+00:00 | 2025-03-06T09:39:47.902483+00:00 | 13 | false | # Approach
The operation described in the task lets us delete any set bits in any number. Therefore the maximum XOR, after applying operations, contains a 1 at all positions where there exists a number in nums with a 1 at that position. This can be expressed using the bitwise OR.
# Complexity
- Time complexity: $$O(n)... | 1 | 0 | ['C#'] | 0 |
maximum-xor-after-operations | 0ms C bit teaser | c-bit-teaser-by-michelusa-r7r2 | Just step back and think we are looking for a maximum from a list of number based on some operation.
The maximum number would be to have as many bits set at one | michelusa | NORMAL | 2025-01-13T13:42:09.777852+00:00 | 2025-01-13T13:42:30.818446+00:00 | 32 | false | Just step back and think we are looking for a maximum from a list of number based on some operation.
The maximum number would be to have as many bits set at one as possible.
That would happen if no bits are eliminated due to XOR, meaning all 1 bits from each number in the array can contributed.
So we OR all numbers an... | 1 | 0 | ['C++'] | 0 |
maximum-xor-after-operations | Degrees 2 in the range 0..26 | degrees-2-in-the-range-026-by-sav2001196-2ud4 | Approach\nSo, the premise of the decision:\n1) Any number cannot become greater when the AND operation is performed on it with any other number. \n2) From any n | sav20011962 | NORMAL | 2024-10-09T09:17:11.367205+00:00 | 2024-10-10T05:41:06.631282+00:00 | 14 | false | # Approach\nSo, the premise of the decision:\n1) Any number cannot become greater when the AND operation is performed on it with any other number. \n2) From any number in the array by performing (nums[i] AND (nums[i] XOR x))we can get all numbers from 0 to nums[i].\nThus, the original problem is transformed into the pr... | 1 | 0 | ['Kotlin'] | 0 |
maximum-xor-after-operations | Python easy solution || Beats 100% 🔥⚡ | python-easy-solution-beats-100-by-asrith-wr7z | Intuition : Bit manipulation\n Describe your first thoughts on how to solve this problem. \n\n# Approach : using OR\n Describe your approach to solving the prob | asritha_chilamakuri | NORMAL | 2024-07-02T10:52:37.824543+00:00 | 2024-07-02T10:52:37.824572+00:00 | 93 | false | # Intuition : Bit manipulation\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach : using OR\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your... | 1 | 0 | ['Python'] | 0 |
maximum-xor-after-operations | BEATS 100% || SIMPLEST AND EASYEST || BITWISE | beats-100-simplest-and-easyest-bitwise-b-h3g9 | 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 | varma7 | NORMAL | 2023-12-04T16:30:52.699408+00:00 | 2023-12-04T16:30:52.699441+00:00 | 165 | 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- O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n- O(n)\n<!-- Add your space complexity here, ... | 1 | 0 | ['Java'] | 1 |
maximum-xor-after-operations | Beats 100%🔥|| 3 Lines🔥|| easy JAVA Solution✅ | beats-100-3-lines-easy-java-solution-by-geei1 | how can we get the maximum number simply by setting every possible bit to 1 and how can we do it simple by using OR.\n# Code\n\nclass Solution {\n public int | priyanshu1078 | NORMAL | 2023-12-01T10:12:13.872305+00:00 | 2023-12-01T10:12:13.872321+00:00 | 10 | false | how can we get the maximum number simply by setting every possible bit to 1 and how can we do it simple by using OR.\n# Code\n```\nclass Solution {\n public int maximumXOR(int[] nums) {\n int ans=0;\n for(int i:nums) ans|=i;\n return ans;\n }\n}\n``` | 1 | 0 | ['Java'] | 0 |
maximum-xor-after-operations | Java O(N) solution | java-on-solution-by-shree_govind_jee-65jz | 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 | Shree_Govind_Jee | NORMAL | 2023-11-23T04:55:46.871446+00:00 | 2023-11-23T04:55:46.871470+00:00 | 27 | false | # Complexity\n- Time complexity:$$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int maximumXOR(int[] nums) {\n int res = 0;\n for(int num:nums){\n ... | 1 | 0 | ['Array', 'Math', 'Bit Manipulation', 'Java'] | 1 |
maximum-xor-after-operations | Copied solution but tried to explain in a better way | copied-solution-but-tried-to-explain-in-kb9dq | Intuition\nWhat does a&(a^b) do?\nIt says that whatever bit of a is different from that of b, keep it. Turn all other bits to 0.\n\nThose different bits will an | AT_01 | NORMAL | 2023-08-05T07:14:45.826108+00:00 | 2023-08-05T07:14:45.826134+00:00 | 9 | false | # Intuition\nWhat does a&(a^b) do?\nIt says that whatever bit of a is different from that of b, keep it. Turn all other bits to 0.\n\nThose different bits will anyway produce 1 when XORed. \n\nThe bits that were same as that of b are now 0. These bits were either 0 or 1 in b. If they were 1, they are now 0, and will pr... | 1 | 0 | ['C++'] | 0 |
maximum-xor-after-operations | Easy Solution C++| 3 lines | easy-solution-c-3-lines-by-bajpayiananya-spxm | 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 | bajpayiananya | NORMAL | 2023-06-26T07:50:28.958895+00:00 | 2023-06-26T07:50:28.958923+00:00 | 213 | 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 |
maximum-xor-after-operations | since we can't make one by ourselves, doing OR between them will give the answer | since-we-cant-make-one-by-ourselves-doin-lzx7 | \nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int res = 0;\n for(auto i : nums)\n res|=i;\n return res; | mr_stark | NORMAL | 2023-03-28T13:06:27.492678+00:00 | 2023-03-28T13:06:27.492712+00:00 | 493 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int res = 0;\n for(auto i : nums)\n res|=i;\n return res;\n }\n};\n``` | 1 | 1 | ['C'] | 0 |
maximum-xor-after-operations | C++ Simple Implementation using (BITWISE OR) | c-simple-implementation-using-bitwise-or-bfsb | \n\n# Code\n\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int ans=0;\n for(auto x:nums){\n ans= ans | x;\n | ayushnautiyal1110 | NORMAL | 2023-03-27T10:56:31.604651+00:00 | 2023-03-27T10:56:31.604694+00:00 | 372 | false | \n\n# Code\n```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int ans=0;\n for(auto x:nums){\n ans= ans | x;\n }\n return ans;\n }\n};\n``` | 1 | 0 | ['Bit Manipulation', 'C++'] | 0 |
maximum-xor-after-operations | C++ || Explained || O(N) || 3 lines code || Bit manipulation | c-explained-on-3-lines-code-bit-manipula-ahbs | Algorithm\n\n\n- Here we need to find the maximum xor of an array and we can replace a number a by a & ( a ^ x) where x is a non negative number \n- What does | siddhantk1103 | NORMAL | 2022-09-15T12:40:36.298800+00:00 | 2022-09-15T12:40:36.298839+00:00 | 247 | false | __Algorithm__\n\n\n- Here we need to find the maximum xor of an array and we can replace a number a by a & ( a ^ x) where x is a non negative number \n- What does a & ( a ^ x) mean ? Suppose you have 2 numbers in array 1 and 3\n``` \n 1 -> 0 0 0 1\n\t\t\t\t\t\t 3 -> 0 0 1 ... | 1 | 0 | ['Bit Manipulation', 'C', 'C++'] | 0 |
maximum-xor-after-operations | Python3 very easy | python3-very-easy-by-excellentprogrammer-wvnr | \nclass Solution:\n def maximumXOR(self, nums: List[int]) -> int:\n s=[nums[0]]\n for i in range(len(nums)):\n s.append(s[-1]|nums[i | ExcellentProgrammer | NORMAL | 2022-08-31T10:19:38.503417+00:00 | 2022-08-31T10:19:38.503455+00:00 | 83 | false | ```\nclass Solution:\n def maximumXOR(self, nums: List[int]) -> int:\n s=[nums[0]]\n for i in range(len(nums)):\n s.append(s[-1]|nums[i])\n return max(s)\n``` | 1 | 0 | [] | 0 |
maximum-xor-after-operations | Python one liner with explanation | python-one-liner-with-explanation-by-nik-adxd | The operation\nnums[i] = nums[i] & (nums[i] ^ x)\neffectively turns off any bit 1 in nums[i].\nIt cannot turn on 1, so we can only remove any 1 bits that are al | nikamir | NORMAL | 2022-08-27T23:59:13.099121+00:00 | 2022-08-27T23:59:13.099166+00:00 | 58 | false | The operation\nnums[i] = nums[i] & (nums[i] ^ x)\neffectively turns off any bit 1 in nums[i].\nIt cannot turn on 1, so we can only remove any 1 bits that are already in the array.\nThis way we can always create a combination of odd 1 in any position as long as there is 1 at that position at any number.\nThus, just bund... | 1 | 0 | [] | 0 |
maximum-xor-after-operations | C++ Code || Bit Manipulation | c-code-bit-manipulation-by-girdhar-rxwg | \nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) \n {\n \n int ans = 0;\n \n for(auto it: nums)\n {\ | Girdhar__ | NORMAL | 2022-07-30T16:33:42.888150+00:00 | 2022-07-30T16:38:53.291787+00:00 | 130 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) \n {\n \n int ans = 0;\n \n for(auto it: nums)\n {\n ans = ans | it; \n }\n\n return ans;\n \n }\n};\n``` | 1 | 0 | ['Bit Manipulation', 'C', 'C++'] | 0 |
maximum-xor-after-operations | bitwise or ^^ | bitwise-or-by-andrii_khlevniuk-irx0 | \nint maximumXOR(vector<int>& n)\n{\n\treturn accumulate(begin(n), end(n), 0, bit_or{});\n}\n | andrii_khlevniuk | NORMAL | 2022-07-12T11:40:04.640161+00:00 | 2022-07-12T15:37:26.366024+00:00 | 136 | false | ```\nint maximumXOR(vector<int>& n)\n{\n\treturn accumulate(begin(n), end(n), 0, bit_or{});\n}\n``` | 1 | 0 | ['C', 'C++'] | 0 |
maximum-xor-after-operations | java Easy Explanation | java-easy-explanation-by-shiavm-singh-k2gd | num[i] = nums[i]&(nums[i]^x)\nnums[i] = nums[i]&nums[i]^(nums[i] & x )\nnums[i] = nums[i]^(nums[i]&x)\n\nHere nums[i]&x = only common bit between x and nums[i] | shiavm-singh | NORMAL | 2022-07-11T12:43:41.588621+00:00 | 2022-07-11T12:43:41.588672+00:00 | 92 | false | num[i] = nums[i]&(nums[i]^x)\nnums[i] = nums[i]&nums[i]^(nums[i] & x )\nnums[i] = nums[i]^(nums[i]&x)\n\nHere nums[i]&x = only common bit between x and nums[i] will be there other will be gone.\nFor example => 1001&(0101) = 0001\n\n* We conclude that any set bit can be can 0, using this operation\n* We will calculate b... | 1 | 0 | [] | 0 |
maximum-xor-after-operations | Java O(n) easy, simple, and straight forward solution | java-on-easy-simple-and-straight-forward-nq5y | \nclass Solution {\n public int maximumXOR(int[] nums) {\n int max = 0;\n for(int num: nums)\n max = max | num;\n return max; | foolish-engineer | NORMAL | 2022-06-28T14:22:26.094191+00:00 | 2022-06-28T14:22:26.094226+00:00 | 51 | false | ```\nclass Solution {\n public int maximumXOR(int[] nums) {\n int max = 0;\n for(int num: nums)\n max = max | num;\n return max;\n }\n}\n``` | 1 | 0 | [] | 1 |
maximum-xor-after-operations | 🔥 C++ Detailed Explanation | Easy Approach | c-detailed-explanation-easy-approach-by-ayha0 | \uD83D\uDCCDKindly Upvote, It is FREE from your side\n\n\uD83D\uDD25Approach:-\n Whenever we are doing nums[i] = nums[i] & (nums[i] ^ x). Please note that the A | AlphaDecodeX | NORMAL | 2022-06-28T06:48:39.444072+00:00 | 2022-06-28T06:48:39.444116+00:00 | 86 | false | \uD83D\uDCCD**Kindly Upvote, It is FREE from your side**\n\n\uD83D\uDD25Approach:-\n* Whenever we are doing nums[i] = nums[i] & (nums[i] ^ x). Please note that the And operation will produce the result 0 if any bit of the number is zero.\n* It can produce 1/0 depending on the result of nums[i]^x. Because XOR operator c... | 1 | 0 | ['Bit Manipulation', 'C', 'C++'] | 0 |
maximum-xor-after-operations | Didn't expect it as medium. 2 liner solution in C++ | didnt-expect-it-as-medium-2-liner-soluti-b5jb | \nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums){\n int xorr = 0;\n for(auto it : nums) xorr |= it;\n return xorr;\n }\n} | NextThread | NORMAL | 2022-06-27T15:15:13.871126+00:00 | 2022-06-27T15:15:13.871173+00:00 | 19 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums){\n int xorr = 0;\n for(auto it : nums) xorr |= it;\n return xorr;\n }\n};\n``` | 1 | 0 | ['C'] | 0 |
maximum-xor-after-operations | C++ | Easy Simple Approach | Beginners Friendly | c-easy-simple-approach-beginners-friendl-o00d | \nint maximumXOR(vector<int>& nums) {\n int ans=0;\n for(int i=0;i<nums.size();i++)\n ans=ans|nums[i];\n return ans;\n }\n | aaquilnasim | NORMAL | 2022-06-26T14:36:25.965093+00:00 | 2022-06-26T14:36:25.965135+00:00 | 91 | false | ```\nint maximumXOR(vector<int>& nums) {\n int ans=0;\n for(int i=0;i<nums.size();i++)\n ans=ans|nums[i];\n return ans;\n }\n``` | 1 | 0 | ['Bit Manipulation', 'C', 'C++'] | 0 |
maximum-xor-after-operations | I can't believe it work !! | i-cant-believe-it-work-by-zhuangzhutao-y0my | My idea \n\nI thought it would take little bit extra time to solve the third problem of the weekly contest.\n\nBut I was wrong.\n\nI missed the opportunity of p | zhuangzhutao | NORMAL | 2022-06-26T12:15:18.163887+00:00 | 2022-06-26T12:15:18.163915+00:00 | 29 | false | ## My idea \n\nI thought it would take little bit extra time to solve the third problem of the weekly contest.\n\nBut I was wrong.\n\nI missed the opportunity of passing another problem in the contest yesterday during contest.\n\nI read the problem more carefully today.\n\nThe problem states that the operation is numbe... | 1 | 0 | [] | 1 |
maximum-xor-after-operations | Go | Golang | Explanation | O(n) | go-golang-explanation-on-by-camusabsurdo-pff5 | ```\nfunc maximumXOR(nums []int) (ans int) { \n /\n So suppose after doing xor [3,2,4,6] we\'re getting 3\n\n 3 => 0 0 1 1\n 2 => 0 | camusabsurdo | NORMAL | 2022-06-26T09:20:07.360839+00:00 | 2022-06-26T09:20:07.360882+00:00 | 31 | false | ```\nfunc maximumXOR(nums []int) (ans int) { \n /*\n So suppose after doing xor [3,2,4,6] we\'re getting 3\n\n 3 => 0 0 1 1\n 2 => 0 0 1 0\n 4 => 0 1 0 0\n 6 => 0 1 1 0\n xor => 0 0 1 1\n \n The xor result can be maximised if either 4 became 0... | 1 | 0 | ['Go'] | 0 |
maximum-xor-after-operations | Maximum XOR After Operations | maximum-xor-after-operations-by-babu45-51le | \nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n vector<bool>v(32,0);\n for(int i=0;i<nums.size();i++){\n for(int | babu45 | NORMAL | 2022-06-26T05:16:21.687618+00:00 | 2022-06-26T05:16:21.687664+00:00 | 26 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n vector<bool>v(32,0);\n for(int i=0;i<nums.size();i++){\n for(int j=0;j<32;j++)\n if(nums[i]&(1<<j))v[j]=1;\n }\n int ans=0;\n for(int i=0;i<32;i++)\n if(v[i])ans+=pow(2,i);\n... | 1 | 0 | ['Bit Manipulation'] | 0 |
maximum-xor-after-operations | Trie C++ Solution | trie-c-solution-by-rohit_271-cvbh | ```\nclass Solution {\npublic:\n class Node{\n public:\n int x;\n Node left,right;\n Node(){\n left=NULL;\n | rohit_271 | NORMAL | 2022-06-25T20:36:03.950306+00:00 | 2022-06-25T20:36:03.950332+00:00 | 66 | false | ```\nclass Solution {\npublic:\n class Node{\n public:\n int x;\n Node* left,*right;\n Node(){\n left=NULL;\n right=NULL;\n }\n Node(int y){\n x=y;\n left=NULL;\n right=NULL;\n }\n };\n class Trie{\n ... | 1 | 0 | ['Trie'] | 0 |
maximum-xor-after-operations | 2 approaches - Python Easy Understanding | 2-approaches-python-easy-understanding-b-fqsf | \tclass Solution(object):\n\t\tdef maximumXOR(self, nums):\n\t\t\t#approach1\n\t# lis=[0 for _ in range(32)]\n\t# for i in range(32):\n\t# | prateekgoel7248 | NORMAL | 2022-06-25T19:31:59.345540+00:00 | 2022-06-25T19:31:59.345572+00:00 | 73 | false | \tclass Solution(object):\n\t\tdef maximumXOR(self, nums):\n\t\t\t#approach1\n\t# lis=[0 for _ in range(32)]\n\t# for i in range(32):\n\t# for j in nums:\n\t# if 1<<i & j:\n\t# lis[i]=1\n\t# break\n\t# s=0\n\t# val=1\n\n... | 1 | 0 | ['Python', 'C++', 'Python3'] | 2 |
maximum-xor-after-operations | Python solution O(n) time O(1) space | python-solution-on-time-o1-space-by-robe-skb9 | If you haven\'t tried \nhttps://leetcode.com/problems/single-number/ [easy]\nyet that is a good warm up problem to this one. My description uses similar reasoni | roberluc | NORMAL | 2022-06-25T18:41:15.836959+00:00 | 2022-06-25T18:42:17.652355+00:00 | 119 | false | If you haven\'t tried \nhttps://leetcode.com/problems/single-number/ [easy]\nyet that is a good warm up problem to this one. My description uses similar reasoning. \n\nIn particular checkout the solution # 6: Sum of Set Bits \n\nTo arrive at the solution observe two things:\n\n(1) nums[0] XOR nums[1] XOR ... XOR nums[n... | 1 | 0 | ['Bit Manipulation', 'Python3'] | 0 |
maximum-xor-after-operations | C++ || Easy O(n) || OR | c-easy-on-or-by-hrishilamdade-llnp | \nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int res=0;\n for(auto i:nums){\n res|=i;\n }\n ret | hrishilamdade | NORMAL | 2022-06-25T18:39:12.540904+00:00 | 2022-06-25T18:39:12.540946+00:00 | 58 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int res=0;\n for(auto i:nums){\n res|=i;\n }\n return res;\n }\n};\n``` | 1 | 0 | ['Bit Manipulation', 'C', 'C++'] | 0 |
maximum-xor-after-operations | Video Explanation (With Intuition) | video-explanation-with-intuition-by-codi-5mrx | https://www.youtube.com/watch?v=q9HXx63DZCU | codingmohan | NORMAL | 2022-06-25T18:27:45.076850+00:00 | 2022-06-25T18:27:45.076896+00:00 | 22 | false | https://www.youtube.com/watch?v=q9HXx63DZCU | 1 | 0 | [] | 0 |
maximum-xor-after-operations | C++ || Easy to understand || Beats 100% | c-easy-to-understand-beats-100-by-akshar-8h15 | \nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int ans=0; \n for(int & a: nums) ans|=a;\n return ans;\n }\n};\n/**\ | aksharma071 | NORMAL | 2022-06-25T17:47:40.356604+00:00 | 2022-06-25T17:47:40.356642+00:00 | 19 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int ans=0; \n for(int & a: nums) ans|=a;\n return ans;\n }\n};\n/**\nif(find helpful) {\ndo upvote(); // thanks:)\n}\n*/\n``` | 1 | 1 | ['Bit Manipulation', 'C'] | 0 |
maximum-xor-after-operations | JS | Reduce | 1-liner | js-reduce-1-liner-by-escaroda-34wy | \n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar maximumXOR = function(nums) {\n return nums.reduce((acc, cur) => acc |= cur, 0);\n};\n | escaroda | NORMAL | 2022-06-25T17:24:51.544024+00:00 | 2022-06-25T17:24:51.544112+00:00 | 131 | false | ```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar maximumXOR = function(nums) {\n return nums.reduce((acc, cur) => acc |= cur, 0);\n};\n``` | 1 | 0 | ['JavaScript'] | 0 |
maximum-xor-after-operations | C++ || Simple Code || OR operation | c-simple-code-or-operation-by-theblackho-6lad | ```\nclass Solution {\npublic:\n int maximumXOR(vector& a)\n {\n int n=a.size();\n \n if(n==1) return a[0];\n \n int an | theblackhoop | NORMAL | 2022-06-25T17:14:10.216544+00:00 | 2022-06-25T17:14:10.216574+00:00 | 14 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& a)\n {\n int n=a.size();\n \n if(n==1) return a[0];\n \n int ans=a[0];\n for(int i=1;i<n;i++)\n {\n ans=ans|a[i];\n }\n return ans;\n }\n};\n | 1 | 0 | [] | 0 |
maximum-xor-after-operations | Simple explanation: take OR of all elements | simple-explanation-take-or-of-all-elemen-cdpw | Explanation \nWe can unset or set any bit in A[i] by doing A[i]^x. As we can take same or reverse of that bit in x to unset or set the bit.\nBut in every operat | theesoteric | NORMAL | 2022-06-25T16:49:34.964017+00:00 | 2022-06-25T16:50:54.055390+00:00 | 89 | false | Explanation \nWe can unset or set any bit in A[i] by doing A[i]^x. As we can take same or reverse of that bit in x to unset or set the bit.\nBut in every operation, we also have to do AND with A[i] so we can\'t set any new bit in the result of one operation.\nBut still we can unset any bit in any A[i] with one operatio... | 1 | 0 | ['JavaScript'] | 0 |
maximum-xor-after-operations | Very simple understandable solution with explanations | very-simple-understandable-solution-with-v4wh | \nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int maxi = nums[0];\n int n = nums.size();\n for(int i=1;i<n;i++){\n | yogesh358 | NORMAL | 2022-06-25T16:19:32.193672+00:00 | 2022-06-25T16:19:32.193715+00:00 | 45 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int maxi = nums[0];\n int n = nums.size();\n for(int i=1;i<n;i++){\n maxi=maxi | nums[i];\n }\n return maxi;\n \n }\n};\n``` | 1 | 1 | ['C', 'Python', 'Java'] | 0 |
maximum-xor-after-operations | C++ simple solution | c-simple-solution-by-rupesh_dharme-79r8 | \nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int orr = 0;\n for (auto num : nums) orr |= num;\n return orr;\n | rupesh_dharme | NORMAL | 2022-06-25T16:11:38.711452+00:00 | 2022-06-25T16:11:38.711491+00:00 | 28 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int orr = 0;\n for (auto num : nums) orr |= num;\n return orr;\n }\n};\n``` | 1 | 0 | [] | 0 |
maximum-xor-after-operations | Intuition Explained in Detail | Observation | intuition-explained-in-detail-observatio-n0w1 | \nThe answer is simply bitwise OR of whole array.\n\nBut how do we observe this ?\n\nAs we can replace nums[i] with nums[i] & (nums[i] ^ x)\nThere are only 4 po | bitmasker | NORMAL | 2022-06-25T16:09:31.150384+00:00 | 2022-06-25T16:22:07.195319+00:00 | 90 | false | <br/>\nThe answer is simply bitwise OR of whole array.\n\n**But how do we observe this ?**\n\nAs we can replace nums[i] with nums[i] & (nums[i] ^ x)\nThere are only 4 possible combinations of 0s and 1s, so let\'s see what happens in all cases if we subtitute nums[i] with the above formula\n\n<pre>\nnums[i] ... | 1 | 0 | ['Bit Manipulation', 'C'] | 0 |
maximum-xor-after-operations | 6105. Maximum XOR After Operations | Bitwise OR | 6105-maximum-xor-after-operations-bitwis-6hfm | \nclass Solution {\n public int maximumXOR(int[] nums) {\n int[] bits=new int[32];//usigned int\n for(int x:nums){\n for(int i=0;i<3 | Ayushman_18 | NORMAL | 2022-06-25T16:09:16.604428+00:00 | 2022-06-25T16:09:25.988650+00:00 | 18 | false | ```\nclass Solution {\n public int maximumXOR(int[] nums) {\n int[] bits=new int[32];//usigned int\n for(int x:nums){\n for(int i=0;i<32;i++){//count 1 at each bit positon!\n if((1&(x>>i))==1)\n bits[i]=1;\n }\n }\n long ans=0L;\n ... | 1 | 0 | ['Array', 'Bit Manipulation'] | 0 |
maximum-xor-after-operations | 3 line code || c++ | 3-line-code-c-by-jainss-355d | \nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int num=0;\n for(auto it:nums)\n num |=it;\n return num;\ | jainss | NORMAL | 2022-06-25T16:07:15.543286+00:00 | 2022-06-25T16:07:15.543361+00:00 | 27 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int num=0;\n for(auto it:nums)\n num |=it;\n return num;\n }\n};\n``` | 1 | 0 | ['Bit Manipulation'] | 0 |
maximum-xor-after-operations | Python | One Line Solution | O(n) | With Explanation | python-one-line-solution-on-with-explana-mxsx | If we try the "nums[i] AND (nums[i] XOR x)" operation, we get to know that this operation can be used to unset bits of a number. If we want the max XOR, then we | arjuhooda | NORMAL | 2022-06-25T16:06:59.802397+00:00 | 2022-06-25T16:06:59.802479+00:00 | 119 | false | If we try the "nums[i] AND (nums[i] XOR x)" operation, we get to know that this operation can be used to unset bits of a number. If we want the max XOR, then we want 1 at each possible place (if there is atleast one set bit at this place in any number). This definition seems familiar.\nYess !! This is nothing but OR op... | 1 | 0 | ['Bit Manipulation', 'Python', 'Python3'] | 0 |
maximum-xor-after-operations | Very Easy to Understand Code [counting bits] | very-easy-to-understand-code-counting-bi-zc53 | ```\nclass Solution {\npublic:\n int maximumXOR(vector& nums) {\n vectorfreq(31,0);\n for(auto x: nums)\n {\n for(int i=0;i<3 | mahakrawat | NORMAL | 2022-06-25T16:03:35.403173+00:00 | 2022-06-25T16:05:19.859362+00:00 | 36 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n vector<int>freq(31,0);\n for(auto x: nums)\n {\n for(int i=0;i<31;i++)\n {\n freq[i]+=(x&(1<<i))?1:0;\n }\n }\n int ans=0;\n for(int i=0;i<31;i++)\n ... | 1 | 0 | ['C'] | 0 |
maximum-xor-after-operations | Simple O(n) TC and O(1) SC solution | simple-on-tc-and-o1-sc-solution-by-parth-jfzu | For any bit that is on in any number that bit will be also on in the answer. So simply find all the possible on bits\n\nclass Solution {\npublic:\n int binar | parth511 | NORMAL | 2022-06-25T16:03:10.619946+00:00 | 2022-06-25T16:03:10.619990+00:00 | 24 | false | For any bit that is on in any number that bit will be also on in the answer. So simply find all the possible on bits\n```\nclass Solution {\npublic:\n int binaryToDecimal(string n){\n string num = n;\n int dec_value = 0, base = 1, len = num.length();\n for (int i = len - 1; i >= 0; i--) {\n ... | 1 | 0 | ['Math', 'C', 'Iterator'] | 0 |
maximum-xor-after-operations | Simple OR | simple-or-by-cdev-eujq | \n public int MaximumXOR(int[] nums) \n {\n int result = 0;\n foreach (var num in nums)\n result |= num;\n return result;\ | CDev | NORMAL | 2022-06-25T16:02:16.836895+00:00 | 2022-06-25T16:14:41.914653+00:00 | 110 | false | ```\n public int MaximumXOR(int[] nums) \n {\n int result = 0;\n foreach (var num in nums)\n result |= num;\n return result;\n }\n``` | 1 | 0 | [] | 0 |
maximum-xor-after-operations | Easy C++ Solution | O(N) | With Explaination | easy-c-solution-on-with-explaination-by-4ujk9 | OBSERVATION : The main observaton is that we can not set any bit of any element in nums. We can only set off.\nSo the optimal way will be to keep a bit on in ex | Roar47 | NORMAL | 2022-06-25T16:01:12.740511+00:00 | 2022-06-25T16:01:12.740540+00:00 | 51 | false | **OBSERVATION** : The main observaton is that we can not set any bit of any element in nums. We can only set off.\nSo the optimal way will be to keep a bit on in exactly one element of nums. So that when we take XOR of all elements it will be on in the final answer.\nHere is the implementation.\n```\nclass Solution {\n... | 1 | 0 | ['Bit Manipulation', 'C'] | 0 |
maximum-xor-after-operations | leetcode just made you a fool !! | leetcode-just-made-you-a-fool-by-binaykr-hx6i | \nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int mask = 0;\n for(int i=0; i<nums.size(); i++)\n {\n ma | binayKr | NORMAL | 2022-06-25T16:00:58.908909+00:00 | 2022-06-25T16:00:58.908955+00:00 | 82 | false | ```\nclass Solution {\npublic:\n int maximumXOR(vector<int>& nums) {\n int mask = 0;\n for(int i=0; i<nums.size(); i++)\n {\n mask|=nums[i];\n }\n return mask;\n }\n};\n``` | 1 | 1 | [] | 0 |
maximum-xor-after-operations | O(n*32), just check if can we find a number with ith bit set. | on32-just-check-if-can-we-find-a-number-du1tv | Explaination - \nlets say\nxor = n1 ^ n2 ^ .........nN\nwhen this xor can be maximum -> when it has all the bits set.\n\nto have ith bit set in final xor ->\nwe | prabhjyot28 | NORMAL | 2022-06-25T16:00:50.276377+00:00 | 2022-06-25T16:00:50.276410+00:00 | 115 | false | Explaination - \nlets say\nxor = n1 ^ n2 ^ .........nN\nwhen this xor can be maximum -> when it has all the bits set.\n\nto have ith bit set in final xor ->\nwe need to have atleast two numbers from our number set that has opposite ith bit.\n\nnow consider operations, what does it means?\nnums[i] AND (nums[i] XOR x) ->... | 1 | 0 | [] | 0 |
maximum-xor-after-operations | Just 4 lines CPP | just-4-lines-cpp-by-about_anuj-0tc8 | \n int maximumXOR(vector<int>& nums) {\n int temp = 0;\n for(auto e: nums) temp |= e;\n return temp;\n }\n | about_anuj | NORMAL | 2022-06-25T16:00:37.497060+00:00 | 2022-06-25T16:00:37.497091+00:00 | 204 | false | ```\n int maximumXOR(vector<int>& nums) {\n int temp = 0;\n for(auto e: nums) temp |= e;\n return temp;\n }\n``` | 1 | 0 | [] | 0 |
maximum-xor-after-operations | Easy to understand java solution | easy-to-understand-java-solution-by-priy-gnd2 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | priyanshuyadav21 | NORMAL | 2025-04-03T17:20:00.114898+00:00 | 2025-04-03T17:20:00.114898+00:00 | 1 | 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-xor-after-operations | Best Approach Or-ing the array to get Maximum XOR JAVA Bit Manipulation | best-approach-or-ing-the-array-to-get-ma-9m7f | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Viraljain_123 | NORMAL | 2025-04-03T11:51:53.571755+00:00 | 2025-04-03T11:51:53.571755+00:00 | 2 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. --> The | (bitwise OR) operation ensures we keep all 1s from any number.
# Approach
<!-- Describe your approach to solving the problem. --> The best approach is simply OR-ing all numbers together to get the highest possible XOR.
# Complexity
... | 0 | 0 | ['Java'] | 0 |
maximum-xor-after-operations | OR of all elements | O(n) | 2ms | beating 73.53% | or-of-all-elements-on-2ms-beating-7353-b-cdnn | IntuitionOR of all elementsApproachReduce with OR.Complexity
Time complexity:
O(n)
Space complexity:
O(1)
Code | lilongxue | NORMAL | 2025-03-30T16:30:53.864954+00:00 | 2025-03-30T16:30:53.864954+00:00 | 1 | false | # Intuition
OR of all elements
# Approach
Reduce with OR.
# Complexity
- Time complexity:
O(n)
- Space complexity:
O(1)
# Code
```javascript []
/**
* @param {number[]} nums
* @return {number}
*/
var maximumXOR = function(nums) {
return nums.reduce((acc, cur) => acc | cur)
};
``` | 0 | 0 | ['JavaScript'] | 0 |
maximum-xor-after-operations | OPTIMISED C++ SOL | optimised-c-sol-by-himanshu240504-00wj | IntuitionApproachComplexity
Time complexity:
O(32*N)
Space complexity:
O(1)
Code | himanshu240504 | NORMAL | 2025-03-12T19:38:21.726249+00:00 | 2025-03-12T19:38:21.726249+00:00 | 1 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
O(32*N)
- Space complexity:
O(1)
# Code
```cpp []
class Solution {
public:
int maximumXOR(vector<int>& nums) {
vector<int>bits(... | 0 | 0 | ['C++'] | 0 |
maximum-xor-after-operations | [C] arrOr | Time: O(n), Space: O(1) | c-arror-time-on-space-o1-by-zhang_jiabo-i30d | null | zhang_jiabo | NORMAL | 2025-02-04T14:31:05.487441+00:00 | 2025-02-04T14:31:05.487441+00:00 | 3 | false | ```C []
int arrOr(const int * const nums, const int numsLen){
int result = 0;
for (int i = 0; i < numsLen; i += 1){
result |= nums[i];
}
return result;
}
int maximumXOR(const int * const nums, const int numsLen){
return arrOr(nums, numsLen);
}
``` | 0 | 0 | ['C'] | 0 |
minimum-time-to-make-array-sum-at-most-x | [Java/C++/Python] DP Solution, O(n^2) | javacpython-dp-solution-on2-by-lee215-02vp | Intuition\nThe sa = sum(A), sb = sum(B).\nIf we do nothing,\nwe will have sb * i + sa in total at i seconds.\n\nAt the t seconds,\nwe will select t elements.\nT | lee215 | NORMAL | 2023-08-05T16:27:26.041471+00:00 | 2023-08-13T14:59:26.699940+00:00 | 4,280 | false | # **Intuition**\nThe `sa = sum(A)`, `sb = sum(B)`.\nIf we do nothing,\nwe will have `sb * i + sa` in total at `i` seconds.\n\nAt the `t` seconds,\nwe will select `t` elements.\nTake a look at these selected elements,\n`A[i]` will be removed,\nand the sum for these elements is `b1 * (t - 1) + b2 * (t - 2) .... + bt * 0`... | 45 | 0 | ['C', 'Python', 'Java'] | 16 |
minimum-time-to-make-array-sum-at-most-x | Simple DP in C++, java & Python | simple-dp-in-c-java-python-by-cpcs-iwzx | Intuition\n\nSome conclusions:\n1. Each number will be cleared to 0 at most once. Since if we clear a number twice, we can skip the first time setting to make e | cpcs | NORMAL | 2023-08-05T16:49:30.135555+00:00 | 2023-08-05T16:58:01.472491+00:00 | 3,067 | false | # Intuition\n\nSome conclusions:\n1. Each number will be cleared to 0 at most once. Since if we clear a number twice, we can skip the first time setting to make everything earlier.\n2. The numbers with larger increasing rates (nums2[.]) should be cleared to 0 later than the numbers with smaller rates.\n\nSo if the numb... | 19 | 0 | ['Python', 'C++', 'Java', 'Python3'] | 6 |
minimum-time-to-make-array-sum-at-most-x | Video Explanation ("All" the proofs - Exchange Arguments) | video-explanation-all-the-proofs-exchang-f1xy | Explanation \n\nClick here for the video link\n\n# Code\n\n#define pii pair<int, int>\n#define F first\n#define S second\n\nint dp[1001][1001];\n\nclass Solutio | codingmohan | NORMAL | 2023-08-06T18:29:24.082636+00:00 | 2023-08-06T18:29:24.082654+00:00 | 491 | false | # Explanation \n\n[Click here for the video link](https://youtu.be/7KaJamPY7yA)\n\n# Code\n```\n#define pii pair<int, int>\n#define F first\n#define S second\n\nint dp[1001][1001];\n\nclass Solution {\n \n vector<int> n1, n2;\n \n int MaxSum(int row, int last_ind) {\n if (row == 0 || last_ind < 0) re... | 14 | 0 | ['C++'] | 0 |
minimum-time-to-make-array-sum-at-most-x | C++ solution with explainations | c-solution-with-explainations-by-trantai-amxc | Intuition\nSome key observations: \n\nKey 1: The number of operations required should be no more than the length of the array. \n\nKey 2: There exist an optimiz | trantai | NORMAL | 2023-08-05T16:28:51.417090+00:00 | 2023-08-05T16:30:07.285013+00:00 | 1,104 | false | # Intuition\nSome key observations: \n\n**Key 1**: The number of operations required **should be no more than the length of the array**. \n\n**Key 2**: There exist an optimize way that **apply the operation to each indexes in the array atmost 1 time**. \n\n**Key 3**: Let\'s say for t operations, we are choosing to appl... | 14 | 0 | ['C++'] | 2 |
minimum-time-to-make-array-sum-at-most-x | Python solution | python-solution-by-leetcode_dafu-spe4 | observations: \n1. we will use at most n deletions\n2. each col will be deleted at most once. \n3. if one combination of deletions can make the sum less than x, | leetcode_dafu | NORMAL | 2023-08-05T16:08:16.218137+00:00 | 2023-08-05T19:11:30.323543+00:00 | 768 | false | observations: \n1. we will use at most n deletions\n2. each col will be deleted at most once. \n3. if one combination of deletions can make the sum less than x, then we can adjust the order of the deletions, so that those with larger nums2 are deleted later, which will create smaller total sum. \n\nSo, we sort nums2 f... | 14 | 0 | [] | 1 |
minimum-time-to-make-array-sum-at-most-x | 🚀 Java O(n^2) DP with 💡 explanation and comments | java-on2-dp-with-explanation-and-comment-ihn5 | Intuition\nWe are going to use dynamic programming to build up an answer. We sort our pairs by nums2 values ascending, because zeroing out a nums1 value which h | mattihito | NORMAL | 2023-08-05T20:06:55.686977+00:00 | 2023-08-05T20:06:55.686998+00:00 | 276 | false | # Intuition\nWe are going to use dynamic programming to build up an answer. We sort our pairs by nums2 values ascending, because zeroing out a nums1 value which has a large nums2 value is best later (the earlier you do it, the more times you add nums2 value, and you don\'t want to do it twice, else why bother the first... | 11 | 0 | ['Array', 'Dynamic Programming', 'Java'] | 0 |
minimum-time-to-make-array-sum-at-most-x | Optimized DP | optimized-dp-by-votrubac-vt10 | It was hard for me to see that this is a DP solution. \n\nI was not sure if previous computations can be reused. \n\nTurned out they can, but only if we process | votrubac | NORMAL | 2023-08-05T23:30:34.263449+00:00 | 2023-08-05T23:46:21.180067+00:00 | 1,020 | false | It was hard for me to see that this is a DP solution. \n\nI was not sure if previous computations can be reused. \n\nTurned out they can, but only if we process elements in the order of `n2`, increasing.\n\n**C++**\nBecause we only look one step back, we can optimize the memory to `dp[1001]`.\n\n```cpp\nint minimumTime... | 8 | 0 | ['C'] | 1 |
minimum-time-to-make-array-sum-at-most-x | N^2logN solution, DP + Binary search + Maths | n2logn-solution-dp-binary-search-maths-b-i6r5 | Intuition\nYou can see that after a certain day you can get the solution, which gives the intuition of binary search\n\n# Approach\nWe use binary search to get | yashsinghania | NORMAL | 2023-08-05T18:44:46.384520+00:00 | 2023-08-05T18:44:46.384547+00:00 | 672 | false | # Intuition\nYou can see that after a certain day you can get the solution, which gives the intuition of binary search\n\n# Approach\nWe use binary search to get the answer, the check funtion is a DP function. \n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complex... | 6 | 0 | ['C++'] | 7 |
minimum-time-to-make-array-sum-at-most-x | [C++] Intuitive explaination - math and sorting (not DP) | c-intuitive-explaination-math-and-sortin-oyqf | Intuition\nFirst we can see that selecting an index for the operation more than once is not helpful. If we choose index i for step S_k, then the value at that i | awesson | NORMAL | 2023-08-05T17:18:10.721917+00:00 | 2023-08-06T00:20:08.776858+00:00 | 465 | false | # Intuition\nFirst we can see that selecting an index for the operation more than once is not helpful. If we choose index $$i$$ for step $$S_k$$, then the value at that index for the sum at that step will be 0, regardless of whether we chose it at some earlier step. For this reason, we also know that it wont make sense... | 6 | 0 | ['Math', 'Sorting', 'C++'] | 2 |
minimum-time-to-make-array-sum-at-most-x | (Memoization + Sorting ) Simple Algorithm 🔥🔥 | memoization-sorting-simple-algorithm-by-ic1pu | Code\n\nclass Solution {\nprivate:\n int n;\n long long sum1, sum2;\n vector<pair<int, int>> arr;\n\n // finds max sum which can be made in t time w | kingsman007 | NORMAL | 2023-09-08T05:50:27.008349+00:00 | 2023-09-08T05:50:27.008371+00:00 | 314 | false | # Code\n```\nclass Solution {\nprivate:\n int n;\n long long sum1, sum2;\n vector<pair<int, int>> arr;\n\n // finds max sum which can be made in t time with i as last index taken\n // using simple knapsack dp - take, not take\n\n long long dp[1001][1001];\n\n long long f(vector<int>& nums1 ,int t ,... | 4 | 0 | ['Array', 'Dynamic Programming', 'Memoization', 'Sorting', 'C++'] | 0 |
minimum-time-to-make-array-sum-at-most-x | Python solution (DP tab, explained) | python-solution-dp-tab-explained-by-olzh-eq4m | Approach\n Describe your approach to solving the problem. \nLet\'s consider the following example:\n- nums1 = [100, 5, 1, 1]\n- nums2 = [2, 1, 3, 5]\n\nSome obs | olzh06 | NORMAL | 2023-08-13T17:13:19.095657+00:00 | 2023-08-14T06:51:01.592684+00:00 | 203 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\nLet\'s consider the following example:\n- `nums1 = [100, 5, 1, 1]`\n- `nums2 = [2, 1, 3, 5]`\n\nSome observations:\n1. At time `0` the result is `sum(nums1)` regardless of what the `nums2` elements are. If `sum(nums1) <= x`, the problem condition is s... | 4 | 0 | ['Python3'] | 1 |
minimum-time-to-make-array-sum-at-most-x | C++ DP solution with explanation (~15lines) | c-dp-solution-with-explanation-15lines-b-5rei | Intuition\nAt time $t$, the sum of nums1 without any operations is $sum(nums1)+tsum(nums2)$ which is only dependent on $t$. So the problem turns to maximizing t | TonyCao7 | NORMAL | 2023-08-11T10:43:03.129007+00:00 | 2023-08-11T10:43:03.129037+00:00 | 85 | false | # Intuition\nAt time $t$, the sum of nums1 without any operations is $sum(nums1)+t*sum(nums2)$ which is only dependent on $t$. So the problem turns to maximizing the sum of elements we cleared with $t$ operations.\n## Intuition 1\n**Answer should be no larger than $n$.**\nIf the answer is larger than $n$, there must be... | 4 | 0 | ['C++'] | 0 |
minimum-time-to-make-array-sum-at-most-x | 💯✅ JAVA 8 STREAMS || EXPLAINED || 8 LINES || Intuition || Approach 🆙🆙⬆️⬆️ | java-8-streams-explained-8-lines-intuiti-jr38 | \n# Intuition: \n\nFor each task in nums1 and nums2, we can clear it at most once. If we clear a task twice, we are just wasting time by setting it to zero agai | ManojKumarPatnaik | NORMAL | 2023-08-05T16:42:04.628086+00:00 | 2023-08-05T17:26:44.719114+00:00 | 472 | false | \n# Intuition: \n\nFor each task in nums1 and nums2, we can clear it at most once. If we clear a task twice, we are just wasting time by setting it to zero again. Therefore, we should choose which tasks to clear carefully.\n\nTasks in the nums2 list with larger duration per operation should be cleared later than tasks ... | 4 | 1 | ['Dynamic Programming', 'Data Stream', 'Python', 'C++', 'Java', 'Python3'] | 2 |
minimum-time-to-make-array-sum-at-most-x | 💥💥 Beats 100% on runtime and memory [EXPLAINED] | beats-100-on-runtime-and-memory-explaine-w7gx | IntuitionFigure out how to spend time in a way that minimizes a result, considering both time and starting values, while trying to find an optimal selection of | r9n | NORMAL | 2025-01-07T05:03:39.841116+00:00 | 2025-01-07T05:03:39.841116+00:00 | 18 | false | # Intuition
Figure out how to spend time in a way that minimizes a result, considering both time and starting values, while trying to find an optimal selection of elements from two lists. I realized that sorting the pairs and using recursion with memoization would help efficiently explore the possible options without r... | 3 | 0 | ['Array', 'Math', 'Binary Search', 'Dynamic Programming', 'Recursion', 'Memoization', 'Sorting', 'Data Stream', 'Rust'] | 0 |
minimum-time-to-make-array-sum-at-most-x | Recursive Solution O(n^2) beats nobody | recursive-solution-on2-beats-nobody-by-s-6eaa | This isn\'t an optimal solution (in particular it isn\'t space-optimal) but I think it will be helpful.\n\n# Intuition\nWe have n counters; counter i has an ini | space_dancer | NORMAL | 2023-08-17T02:52:17.895235+00:00 | 2023-08-17T02:52:17.895256+00:00 | 194 | false | This isn\'t an optimal solution (in particular it isn\'t space-optimal) but I think it will be helpful.\n\n# Intuition\nWe have `n` counters; counter `i` has an initial value `nums1[i]` and increases at a rate of `nums2[i]`.\n\nNote first that it is suboptimal to reset a counter (to zero) more than once, since then the... | 2 | 0 | ['Python3'] | 1 |
minimum-time-to-make-array-sum-at-most-x | Detailed and well explained C++ Solution ✔️✔️✔️ | detailed-and-well-explained-c-solution-b-qx46 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n1. Create a 2D vector v of size n by 2, where v[i][0] stores the value of | __AKASH_SINGH___ | NORMAL | 2023-08-05T19:47:10.000461+00:00 | 2023-08-05T19:47:10.000481+00:00 | 244 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. Create a 2D vector v of size n by 2, where v[i][0] stores the value of nums2[i] and v[i][1] stores the value of nums1[i].\n\n2. Sort the 2D vector v based on the values in nums2 in non-decreasing order. Sorting helps in s... | 2 | 0 | ['C++'] | 0 |
minimum-time-to-make-array-sum-at-most-x | [C++] simple dp | c-simple-dp-by-cuny-66brother-2k0k | \nusing ll = long long;\n\nconst int N = 1010, INF = 1e9;\nll dp[N][N];\n\nvoid init(int n) {\n for(int i = 0; i <= n; i++) {\n for(int j = 0; j <= n; | CUNY-66brother | NORMAL | 2023-10-10T15:48:33.679438+00:00 | 2023-10-10T15:48:33.679466+00:00 | 10 | false | ```\nusing ll = long long;\n\nconst int N = 1010, INF = 1e9;\nll dp[N][N];\n\nvoid init(int n) {\n for(int i = 0; i <= n; i++) {\n for(int j = 0; j <= n; j++) {\n dp[i][j] = -INF;\n }\n }\n}\n\nclass Solution {\npublic:\n int minimumTime(vector<int>& a, vector<int>& b, int x) {\n ... | 1 | 0 | [] | 0 |
minimum-time-to-make-array-sum-at-most-x | Taking same number a second time is same as taking it only one time | taking-same-number-a-second-time-is-same-r3zx | Intuition\nKey Observations:\n1. If you take nums[i] both at time 2 and at time 5, the result is same as taking nums[i] only at time 5. And taking only at time | yuanzhi247012 | NORMAL | 2023-08-15T06:41:53.759324+00:00 | 2023-08-18T07:02:01.519038+00:00 | 253 | false | # Intuition\nKey Observations:\n1. If you take nums[i] both at time 2 and at time 5, the result is same as taking nums[i] **only** at time 5. And taking **only** at time 5 is better because you save one extra round. \nBecause of this, it make no sense to take any index a second time. Each index can only be taken once. ... | 1 | 0 | ['Python3'] | 0 |
minimum-time-to-make-array-sum-at-most-x | Straightforward cpp solution :) | straightforward-cpp-solution-by-sanyam46-jjsa | 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 | sanyam46 | NORMAL | 2023-08-09T13:51:38.641376+00:00 | 2023-08-09T13:51:38.641419+00:00 | 134 | 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 |
minimum-time-to-make-array-sum-at-most-x | Vanilla dynamic programming to understand the logic | vanilla-dynamic-programming-to-understan-aica | This post is inspired by https://leetcode.com/problems/minimum-time-to-make-array-sum-at-most-x/solutions/3868304/simple-dp-in-c-java-python/ !\n# Intuition\n D | superPandaPlus | NORMAL | 2023-08-06T20:59:41.511018+00:00 | 2023-08-06T21:01:35.406371+00:00 | 252 | false | This post is inspired by https://leetcode.com/problems/minimum-time-to-make-array-sum-at-most-x/solutions/3868304/simple-dp-in-c-java-python/ !\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIt is important to realize that the problem can be translated as: given j steps, and i rows (... | 1 | 0 | ['Java'] | 0 |
minimum-time-to-make-array-sum-at-most-x | Intuition, approaching, proof and code | intuition-approaching-proof-and-code-by-gidjg | Intuition\n\nEDITED: fix some error, add the proof of max_possible_ops.\nEDITED 2: fix error in proof of max_possible_ops\n\n## Notations\n\nLet $A$ be the orig | 6cdh | NORMAL | 2023-08-06T10:57:47.622724+00:00 | 2023-08-08T01:18:18.596658+00:00 | 288 | false | # Intuition\n\nEDITED: fix some error, add the proof of `max_possible_ops`.\nEDITED 2: fix error in proof of `max_possible_ops`\n\n## Notations\n\nLet $A$ be the original `nums1`, $B$ be the original `nums2`.\nSo $A_i$ is `nums1[i]`.\nLet the length of `nums1` be $n$.\n\n## Limit\n\nAfter $n$ seconds, a intuition is th... | 1 | 0 | ['Racket'] | 1 |
minimum-time-to-make-array-sum-at-most-x | Actually Helpful Explanation with Proof and Not Just Code translated in English | actually-helpful-explanation-with-proof-cd1f6 | We will find a value MaxRemove[i], this tells us the maximum sum of values we can remove if we can find the answer in i seconds/moves.\n\nIf we can find this Ma | non_deterministic | NORMAL | 2023-08-05T17:09:57.400468+00:00 | 2023-08-05T17:09:57.400491+00:00 | 261 | false | We will find a value MaxRemove[i], this tells us the maximum sum of values we can remove if we can find the answer in i seconds/moves.\n\nIf we can find this MaxRemove[i] for i = 0 to N, then we can just check at every position if the total would be less than X, then we are done.\n\nLet\'s try to find this now.\n\n- Th... | 1 | 0 | ['C'] | 3 |
minimum-time-to-make-array-sum-at-most-x | [C++] beats 100%, Space complexity: O(N), with explaination | c-beats-100-space-complexity-on-with-exp-mv9s | Intuition\n Describe your first thoughts on how to solve this problem. \n\nTo minimize, we have to find out the minimum num to reset to 0.\n\n# Approach\n Descr | ryankert | NORMAL | 2023-08-05T16:40:07.099894+00:00 | 2023-08-05T16:48:36.552174+00:00 | 164 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nTo minimize, we have to find out the minimum num to reset to 0.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFirst, we sort `v` (contains `nums2`, `nums1`).\n\nSecond, we use dynamic programming to calcualte t... | 1 | 1 | ['C++'] | 0 |
minimum-time-to-make-array-sum-at-most-x | python n2 dynamic programming | python-n2-dynamic-programming-by-hongyil-ntnv | 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 | hongyili | NORMAL | 2023-08-05T16:27:42.745213+00:00 | 2023-08-05T16:27:42.745236+00:00 | 95 | 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)$$ -->\nn^2\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$... | 1 | 0 | ['Dynamic Programming', 'Python3'] | 0 |
minimum-time-to-make-array-sum-at-most-x | Explained DP 33ms | explained-dp-33ms-by-ivangnilomedov-uud2 | IntuitionThe key observation is that when zeroing multiple positions, we want to zero positions with higher growth rates (nums2[i]) later, since they contribute | ivangnilomedov | NORMAL | 2025-01-18T12:43:49.461107+00:00 | 2025-01-18T12:43:49.461107+00:00 | 6 | false | # Intuition
The key observation is that when zeroing multiple positions, we want to zero positions with higher growth rates (nums2[i]) later, since they contribute more to the total sum over time. This leads to a dynamic programming solution where we consider positions in order of their growth rates.
# Approach
The so... | 0 | 0 | ['C++'] | 0 |
minimum-time-to-make-array-sum-at-most-x | DP + Greedy | Intuitive | dp-greedy-intuitive-by-anonymous_k-jurw | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | anonymous_k | NORMAL | 2024-12-24T16:26:04.186360+00:00 | 2024-12-24T16:26:04.186360+00:00 | 12 | 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 |
minimum-time-to-make-array-sum-at-most-x | Top Down DP || Memoization || Accepted Solution || O(n^2) O(n^2) | top-down-dp-memoization-accepted-solutio-ifg5 | Approach\n Describe your approach to solving the problem. \nI don\'t really like bottom up DP, so I always try me best to come up with top down approach. It is | sulerhy | NORMAL | 2024-09-22T16:47:22.231426+00:00 | 2024-09-22T16:48:56.681241+00:00 | 25 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\nI don\'t really like bottom up DP, so I always try me best to come up with top down approach. It is more natural and easy to explain in the interview. \nYou can also explain the optimal bottom up solution as the follow up later.\nHere is the tip why m... | 0 | 0 | ['Dynamic Programming', 'Memoization', 'Sorting', 'Python3'] | 0 |
minimum-time-to-make-array-sum-at-most-x | Commented | Intuitive | commented-intuitive-by-anonymous_k-e6x3 | 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 | anonymous_k | NORMAL | 2024-09-21T06:54:22.463702+00:00 | 2024-09-21T06:54:22.463742+00:00 | 6 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Python3'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.