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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
mini-parser | Java - Recursive Solution with FULL explanation | java-recursive-solution-with-full-explan-5ava | Since the question mentions nested structure, use of recursion is necessary.\n\nAlso, it\'s mentioned that the element is either an integer or list of NestedInt | parin2 | NORMAL | 2020-05-04T09:08:18.564645+00:00 | 2020-05-04T09:08:18.564696+00:00 | 175 | false | Since the question mentions *nested* structure, use of recursion is necessary.\n\nAlso, it\'s mentioned that the element is *either an integer or list of NestedIntegers*. So, **the base-case will be, the string which does not start with \'[\'.** - which means, the nested integer contains only one integer.\n\nNow we hav... | 1 | 0 | [] | 0 |
mini-parser | Python Iterative | python-iterative-by-majgawali-82rs | \nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n \n if (len(s) == 0):\n return NestedInteger()\n elif (s | majgawali | NORMAL | 2020-04-18T05:59:00.577478+00:00 | 2020-04-18T05:59:00.577508+00:00 | 222 | false | ```\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n \n if (len(s) == 0):\n return NestedInteger()\n elif (s[0] != \'[\'):\n return NestedInteger(int(s))\n \n number=\'\'\n stack = [NestedInteger()]\n \n for char in s:\... | 1 | 0 | [] | 0 |
mini-parser | Java solution uses recursive | java-solution-uses-recursive-by-akiramon-e3ha | case 1: s = "123" -> 123\ncase 2: [] -> return new NestedInteger()\ncase 3: [123, 456, 789, [1, 2, 3], [4, 5, 6]]\n\n\nclass Solution {\n public NestedIntege | akiramonster | NORMAL | 2020-04-06T22:19:51.542216+00:00 | 2020-04-06T22:19:51.542256+00:00 | 99 | false | case 1: s = "123" -> 123\ncase 2: [] -> return new NestedInteger()\ncase 3: [123, 456, 789, [1, 2, 3], [4, 5, 6]]\n\n```\nclass Solution {\n public NestedInteger deserialize(String s) {\n NestedInteger res = new NestedInteger();\n if (s == null || s.length() == 0) return res;\n if (s.charAt(0) !... | 1 | 0 | [] | 0 |
mini-parser | Java 29.27% time 30% space, Iterative w/ stack | java-2927-time-30-space-iterative-w-stac-cd0q | ````\nclass Solution {\n public NestedInteger deserialize(String s) {\n if(!s.startsWith("["))return new NestedInteger(Integer.valueOf(s));\n S | robsalcedo | NORMAL | 2020-03-13T05:13:21.823507+00:00 | 2020-03-13T05:13:21.823543+00:00 | 232 | false | ````\nclass Solution {\n public NestedInteger deserialize(String s) {\n if(!s.startsWith("["))return new NestedInteger(Integer.valueOf(s));\n Stack<NestedInteger> st=new Stack<NestedInteger>();\n NestedInteger res = new NestedInteger();\n st.push(res);\n int start=1;\n for(i... | 1 | 0 | ['Iterator', 'Java'] | 0 |
mini-parser | Swift Solution using Stack | swift-solution-using-stack-by-alptekin35-dgef | \nclass Solution {\n func deserialize(_ s: String) -> NestedInteger {\n var stack:[NestedInteger] = []\n var current:NestedInteger = NestedInte | alptekin35 | NORMAL | 2020-01-16T23:01:35.585622+00:00 | 2020-01-16T23:01:35.585673+00:00 | 121 | false | ```\nclass Solution {\n func deserialize(_ s: String) -> NestedInteger {\n var stack:[NestedInteger] = []\n var current:NestedInteger = NestedInteger()\n let head = current\n var currentItem = ""\n var negative = false\n for item in s{\n if item == "["{\n ... | 1 | 0 | ['Stack', 'Swift'] | 0 |
mini-parser | python solution to parse the input string into a native nested list in python | python-solution-to-parse-the-input-strin-5cis | Not sure why we need a NestedInteger type in python since python could already represent such values. The parse step and creation of NestedInteger could be com | e2718281828 | NORMAL | 2020-01-03T04:47:13.210562+00:00 | 2020-01-03T04:47:13.210611+00:00 | 249 | false | Not sure why we need a NestedInteger type in python since python could already represent such values. The parse step and creation of NestedInteger could be combined into one step.\n\n```\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n if s[0].isdigit():\n return NestedInteger(... | 1 | 0 | [] | 0 |
mini-parser | Java Straightforward stack solution | java-straightforward-stack-solution-by-p-txer | \nclass Solution {\n public NestedInteger deserialize(String s) {\n Deque<NestedInteger> stack = new ArrayDeque<>();\n int i = 0;\n whil | pandalv9999 | NORMAL | 2019-12-13T19:15:06.622729+00:00 | 2019-12-13T19:15:06.622763+00:00 | 231 | false | ```\nclass Solution {\n public NestedInteger deserialize(String s) {\n Deque<NestedInteger> stack = new ArrayDeque<>();\n int i = 0;\n while (i < s.length()) {\n if (s.charAt(i) == \'[\') {\n stack.push(new NestedInteger());\n i++;\n } else if ... | 1 | 0 | [] | 0 |
mini-parser | recursive solution written in c++ | recursive-solution-written-in-c-by-apeir-0t5b | this problem is very similiar to pasring a boolean expression, so we can use the same method. use a cnt to count the number of parenthesis, and to check whether | apeironc | NORMAL | 2019-10-12T20:11:53.296692+00:00 | 2019-10-12T20:13:17.423661+00:00 | 198 | false | this problem is very similiar to [pasring a boolean expression](https://leetcode.com/problems/parsing-a-boolean-expression/discuss/325228/C%2B%2B-Polish-Notation), so we can use the same method. use a cnt to count the number of parenthesis, and to check whether a coma could split a NestedInteger object\n```\nclass Solu... | 1 | 0 | [] | 0 |
mini-parser | simple Java recursive solution | simple-java-recursive-solution-by-sjwang-dtkh | \nclass Solution {\n int i = 0;\n public NestedInteger deserialize(String s) {\n return dfs(s).getList().get(0);\n }\n \n public NestedInt | sjwang0719 | NORMAL | 2019-09-14T17:45:10.371975+00:00 | 2019-09-14T17:45:10.372028+00:00 | 161 | false | ```\nclass Solution {\n int i = 0;\n public NestedInteger deserialize(String s) {\n return dfs(s).getList().get(0);\n }\n \n public NestedInteger dfs(String s) {\n NestedInteger res = new NestedInteger(); \n while (i < s.length()) {\n char c = s.charAt(i);\n ... | 1 | 0 | [] | 0 |
mini-parser | Simple Java solution for slow learners like myself with comments (4ms) | simple-java-solution-for-slow-learners-l-rpwo | \nclass Solution {\n public NestedInteger deserialize(String s) {\n if (s == null || "".equals(s)) \n\t\t\treturn null;\n if (!isEnclosed(s)) \ | dumbleeter | NORMAL | 2019-07-22T04:00:21.618656+00:00 | 2019-10-23T05:08:59.832418+00:00 | 289 | false | ```\nclass Solution {\n public NestedInteger deserialize(String s) {\n if (s == null || "".equals(s)) \n\t\t\treturn null;\n if (!isEnclosed(s)) \n\t\t\treturn new NestedInteger(Integer.parseInt(s)); //if not enclosed its number so simply parse out result\n\n NestedInteger root = new NestedInteg... | 1 | 0 | [] | 1 |
mini-parser | recursive Python solution | recursive-python-solution-by-merciless-4gdm | ```\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n if not s:\n return NestedInteger()\n if s[0] != "[":\n | merciless | NORMAL | 2019-05-14T01:08:59.794543+00:00 | 2019-05-14T01:13:04.016790+00:00 | 244 | false | ```\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n if not s:\n return NestedInteger()\n if s[0] != "[":\n return int(s)\n s,temp,memo,i = s[1:-1], NestedInteger(),"1234567890-",0\n while i < len(s):\n if s[i] in memo:\n ... | 1 | 0 | [] | 0 |
mini-parser | Simple & Fast Python | simple-fast-python-by-autodino-cvb4 | ```\nclass Solution(object):\n def deserialize(self, s):\n """\n :type s: str\n :rtype: NestedInteger\n """\n \n if | autodino | NORMAL | 2018-05-20T15:31:18.795720+00:00 | 2018-05-20T15:31:18.795720+00:00 | 205 | false | ```\nclass Solution(object):\n def deserialize(self, s):\n """\n :type s: str\n :rtype: NestedInteger\n """\n \n if s[0]!=\'[\': return NestedInteger(int(s))\n \n stack=[NestedInteger()]\n num=\'\'\n for i in s:\n if i==\'[\': \n ... | 1 | 0 | [] | 0 |
mini-parser | Very short and simple Python solution | very-short-and-simple-python-solution-by-sxzs | \nreturn eval(s)\n | bobzhu | NORMAL | 2018-01-20T05:32:43.812000+00:00 | 2018-01-20T05:32:43.812000+00:00 | 167 | false | ```\nreturn eval(s)\n``` | 1 | 0 | [] | 0 |
mini-parser | easy to understand use stack java solution | easy-to-understand-use-stack-java-soluti-a5g7 | ```\npublic NestedInteger deserialize(String s) {\n NestedInteger res = new NestedInteger();\n Stack stack = new Stack();\n for (int i = 0; | willcomeback | NORMAL | 2016-08-15T01:35:42.872000+00:00 | 2016-08-15T01:35:42.872000+00:00 | 363 | false | ```\npublic NestedInteger deserialize(String s) {\n NestedInteger res = new NestedInteger();\n Stack<NestedInteger> stack = new Stack<NestedInteger>();\n for (int i = 0; i < s.length(); i++) {\n char c = s.charAt(i);\n if (c == '[') {\n stack.push(new NestedInte... | 1 | 0 | [] | 0 |
mini-parser | Java 10 ms, while loop + recursion (one scan) | java-10-ms-while-loop-recursion-one-scan-7i7g | I found that most of the recursion solutions have to scan through the string s more than once since they find a ',' as a breaking point at each layer in order t | yubad2000 | NORMAL | 2016-08-14T19:15:29.566000+00:00 | 2016-08-14T19:15:29.566000+00:00 | 845 | false | I found that most of the recursion solutions have to scan through the string s more than once since they find a ',' as a breaking point at each layer in order to return a NestedInteger between two ',' or between ',' and ']'. \nMy solution also uses recursion. However, it not only return a NestedInteger but also an inde... | 1 | 0 | [] | 1 |
mini-parser | Python 14-liner iterative solution | python-14-liner-iterative-solution-by-cl-4n1h | \ndef deserialize(self, s):\n stk, num = [NestedInteger()], ''\n for ch in s+' ':\n if ch == '[':\n tmp = NestedInteger()\n s | cloudycandy | NORMAL | 2016-08-17T14:07:41.607000+00:00 | 2016-08-17T14:07:41.607000+00:00 | 262 | false | ```\ndef deserialize(self, s):\n stk, num = [NestedInteger()], ''\n for ch in s+' ':\n if ch == '[':\n tmp = NestedInteger()\n stk[-1].add(tmp)\n stk.append(tmp)\n elif ch in '-01234556789':\n num += ch\n elif num:\n stk[-1].add(NestedInt... | 1 | 0 | [] | 0 |
mini-parser | A very clear and detailed explained iterative solution | a-very-clear-and-detailed-explained-iter-8msh | Iterate through the whole string. Keep a stack to track the NestedInteger objects.\nThe top of the stack is always the current NestedInteger we are working on.\ | ccpromise | NORMAL | 2016-08-23T04:19:27.334000+00:00 | 2016-08-23T04:19:27.334000+00:00 | 309 | false | Iterate through the whole string. Keep a stack to track the NestedInteger objects.\nThe top of the stack is always the current NestedInteger we are working on.\n'[': push a new object into stack\n']': if there are more that one object in the stack, it means the top NestedInteger is an element of the last but one Nested... | 1 | 0 | [] | 0 |
mini-parser | my clean solution using one stack | my-clean-solution-using-one-stack-by-hwy-9t4u | \npublic NestedInteger deserialize(String s) {\n if (s == null) {\n return null;\n }\n if (s.charAt(0) != '[') {\n return new NestedInteg | hwy_2015 | NORMAL | 2016-08-24T05:21:38.794000+00:00 | 2016-08-24T05:21:38.794000+00:00 | 225 | false | ```\npublic NestedInteger deserialize(String s) {\n if (s == null) {\n return null;\n }\n if (s.charAt(0) != '[') {\n return new NestedInteger(Integer.valueOf(s));\n }\n NestedInteger nestedInteger = null;\n Stack<NestedInteger> stack = new Stack<NestedInteger>();\n \n for (Str... | 1 | 0 | [] | 0 |
mini-parser | C++ code with 36ms | c-code-with-36ms-by-sanxi-980g | class Solution{\n stack<NestedInteger*> Stack;\n public:\n NestedInteger<string s>{\n NestedInteger *cur;\n | sanxi | NORMAL | 2016-09-06T12:41:22.517000+00:00 | 2016-09-06T12:41:22.517000+00:00 | 394 | false | class Solution{\n stack<NestedInteger*> Stack;\n public:\n NestedInteger<string s>{\n NestedInteger *cur;\n for(int i=0;i<s.size();i++){\n if(s[i]==',')continue;\n cur=new NestedInteger();\n if(s[i]==... | 1 | 0 | [] | 0 |
mini-parser | Simple Java Iterative Solution | simple-java-iterative-solution-by-hotpro-rtoq | I like this simple version.\n\n\npublic class Solution {\n\n public NestedInteger deserialize(String s) {\n if (s.charAt(0) != '[') {\n ret | hotpro | NORMAL | 2016-09-28T06:40:59.305000+00:00 | 2016-09-28T06:40:59.305000+00:00 | 310 | false | I like this simple version.\n\n```\npublic class Solution {\n\n public NestedInteger deserialize(String s) {\n if (s.charAt(0) != '[') {\n return new NestedInteger(Integer.parseInt(s));\n }\n Deque<NestedInteger> stack = new LinkedList<>();\n for (int i = 0; i < s.length(); i++... | 1 | 0 | [] | 0 |
mini-parser | Simple and short Java solution | simple-and-short-java-solution-by-ivtosk-s6k1 | \n public NestedInteger deserialize(String s) {\n Stack<NestedInteger> stack = new Stack<>();\n for (int i = 0, num = 0, sign = 1; i < s.length | ivtoskov | NORMAL | 2016-11-02T10:30:37.992000+00:00 | 2016-11-02T10:30:37.992000+00:00 | 281 | false | ```\n public NestedInteger deserialize(String s) {\n Stack<NestedInteger> stack = new Stack<>();\n for (int i = 0, num = 0, sign = 1; i < s.length(); ++i) {\n char c = s.charAt(i);\n if (Character.isDigit(c)) {\n num = num * 10 + c - '0';\n if (i + 1 ... | 1 | 0 | [] | 0 |
mini-parser | Concise Java Solution | concise-java-solution-by-yavinci-o5hf | The following pattern is very generic for similar questions:\n\n public NestedInteger deserialize(String s) {\n if (s.charAt(0) != '[') {\n | yavinci | NORMAL | 2016-11-09T03:29:33.915000+00:00 | 2016-11-09T03:29:33.915000+00:00 | 391 | false | The following pattern is very generic for similar questions:\n\n public NestedInteger deserialize(String s) {\n if (s.charAt(0) != '[') {\n return new NestedInteger(Integer.valueOf(s));\n }\n\n Deque<NestedInteger> stack = new ArrayDeque<>();\n NestedInteger curr = new NestedIn... | 1 | 0 | [] | 0 |
mini-parser | Java 15ms recursive solution beats 88% , short and clean | java-15ms-recursive-solution-beats-88-sh-e7fp | \npublic NestedInteger deserialize(String s) {\n if (s.charAt(0) != '[') return new NestedInteger(Integer.valueOf(s));\n\tNestedInteger res = new NestedI | shawnloatrchen | NORMAL | 2017-01-05T00:53:58.504000+00:00 | 2017-01-05T00:53:58.504000+00:00 | 152 | false | ```\npublic NestedInteger deserialize(String s) {\n if (s.charAt(0) != '[') return new NestedInteger(Integer.valueOf(s));\n\tNestedInteger res = new NestedInteger();\n\tif (s.length() == 2) return res;\n\tint start = 1, end = 1, brackets= 0;\n\tfor (;end < s.length()-1; end++) {\n\t\tchar cur = s.charAt(end);\n\... | 1 | 0 | [] | 0 |
mini-parser | Java iterative accepted solution using stack | java-iterative-accepted-solution-using-s-d1of | \npublic class Solution {\n public NestedInteger deserialize(String s) {\n NestedInteger ret = new NestedInteger();\n if(s == null || s.isEmpty | gtdoof | NORMAL | 2017-02-02T04:03:26.660000+00:00 | 2017-02-02T04:03:26.660000+00:00 | 521 | false | ```\npublic class Solution {\n public NestedInteger deserialize(String s) {\n NestedInteger ret = new NestedInteger();\n if(s == null || s.isEmpty()) {\n return new NestedInteger();\n }\n \n Stack<NestedInteger> stack = new Stack<>();\n stack.push(ret);\n i... | 1 | 0 | ['Stack', 'Iterator', 'Java'] | 0 |
maximum-total-damage-with-spell-casting | ✅Beats 100% -Explained with [ Video ] -C++/Java/Python/JS -Dynamic Programming -Interview Solution | beats-100-explained-with-video-cjavapyth-di6s | \n\n\n\n# YouTube Video Explanation:\n\n **If you want a video for this question please write in the comments** \n\nhttps://youtu.be/btt34fYah6s\n\n\n\uD83D\uDD | lancertech6 | NORMAL | 2024-06-16T05:42:16.161957+00:00 | 2024-06-16T07:41:43.289137+00:00 | 8,232 | false | \n\n\n\n# YouTube Video Explanation:\n\n<!-- **If you want a video for this question please write in the comments** -->\n\nhttps://youtu.be/btt34fYah6s\n\n\n**\uD83D\uDD25 Please like... | 108 | 2 | ['Array', 'Dynamic Programming', 'Python', 'C++', 'Java', 'JavaScript'] | 9 |
maximum-total-damage-with-spell-casting | Catch-Up DP | catch-up-dp-by-votrubac-x2qo | dp[i + 1] represents the best result if i-th spell was casted. \n\nWe sort the array first, so we can easily track all smaller powers we can use when casing i-t | votrubac | NORMAL | 2024-06-16T04:00:52.556056+00:00 | 2024-06-16T18:41:30.838850+00:00 | 4,814 | false | `dp[i + 1]` represents the best result if `i`-th spell was casted. \n\nWe sort the array first, so we can easily track all smaller powers we can use when casing `i`-th spell.\n\nBefore computing `dp[i + 1]`, we "catch up" to include best results for all `power[j]` such as `power[j] + 2 < power[i]`.\n\nWe track the bes... | 53 | 0 | ['C'] | 9 |
maximum-total-damage-with-spell-casting | 🔥DP || ⚡Memoization || ✅Clean & Easy to understand💯 | dp-memoization-clean-easy-to-understand-xs34p | Complexity\n- Time complexity: O(nlogn)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n | Sachin___Sen | NORMAL | 2024-06-16T04:07:46.991264+00:00 | 2024-06-16T04:07:46.991289+00:00 | 5,410 | false | # Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n#define ll long long \nprivate:\n ll getMaxDamage(vector<ll>& dp, map<int, int>& frequencyMap, vector<... | 39 | 0 | ['Hash Table', 'Dynamic Programming', 'Memoization', 'C++'] | 6 |
maximum-total-damage-with-spell-casting | [EASIEST] Delete and Earn + Explanation (DP) | easiest-delete-and-earn-explanation-dp-b-i204 | Approach\nThis problem is the same as 740. Delete and Earn, except there\'s one more previous entry that must be skipped\n\nThe logic is basically this: if we t | AlecLC | NORMAL | 2024-06-16T04:08:45.606904+00:00 | 2024-06-17T22:31:50.331880+00:00 | 1,882 | false | # Approach\nThis problem is the same as <b><span style="color:orange">740. Delete and Earn</span></b>, except there\'s one more previous entry that must be skipped\n\nThe logic is basically this: if we take a spell, then we can\'t take any previous spell within 2 of this spell. `dp[i]` is the max strength using only sp... | 19 | 0 | ['Dynamic Programming', 'Python3'] | 3 |
maximum-total-damage-with-spell-casting | 6 Approaches | 6-approaches-by-jay_1410-0lsn | 1. TopDown DP\nC++ []\nclass Solution {\npublic:\n vector<long long> DP;\n long long TopDown(int i , int N , vector<array<long long , 2>> &P){\n if | Jay_1410 | NORMAL | 2024-06-16T19:57:14.826689+00:00 | 2024-10-15T10:30:11.528378+00:00 | 1,028 | false | # 1. TopDown DP\n```C++ []\nclass Solution {\npublic:\n vector<long long> DP;\n long long TopDown(int i , int N , vector<array<long long , 2>> &P){\n if(i == N) return 0;\n if(DP[i] != -1) return DP[i];\n long long c1 = TopDown(i + 1 , N , P);\n long long c2 = P[i][1];\n for(int... | 13 | 0 | ['Hash Table', 'Binary Search', 'Dynamic Programming', 'Sorting', 'Python', 'C++', 'Java', 'Python3'] | 1 |
maximum-total-damage-with-spell-casting | [Dynamic Programming + Tutorial] Maximum Total Damage With Spell Casting | dynamic-programming-tutorial-maximum-tot-n5mo | Topic : Dynamic Programming\nDynamic Programming is a method used in mathematics and computer science to solve complex problems by breaking them down into simp | never_get_piped | NORMAL | 2024-06-16T04:04:55.591885+00:00 | 2024-06-21T04:50:28.749069+00:00 | 1,909 | false | **Topic** : Dynamic Programming\nDynamic Programming is a method used in mathematics and computer science to solve complex problems by breaking them down into simpler **subproblems**. By solving each subproblem only once and storing the results, it avoids redundant computations, leading to more efficient solutions for... | 12 | 1 | ['C', 'PHP', 'Python', 'Java', 'Go', 'JavaScript'] | 2 |
maximum-total-damage-with-spell-casting | ⚡Using DP || 🔥Memoization || ✅Clean Code | using-dp-memoization-clean-code-by-adish-0fn7 | \n# Complexity\n\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(n)\n\n\n## Connect with me on LinkedIn : https://www.linkedin.com/in/aditya-jhunjhunwal | aDish_21 | NORMAL | 2024-06-16T04:04:33.467357+00:00 | 2024-06-16T12:05:47.904770+00:00 | 2,363 | false | \n# Complexity\n```\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(n)\n```\n\n## Connect with me on LinkedIn : https://www.linkedin.com/in/aditya-jhunjhunwala-51b586195/\n\n# Code\n## Please Upvote if it helps\uD83E\uDD17\n```\nclass Solution {\npublic:\n unordered_map<int, int> mp;\n vector<long long> d... | 10 | 0 | ['Dynamic Programming', 'Memoization', 'C++'] | 4 |
maximum-total-damage-with-spell-casting | C++||Tabulation||memoization||Dp+Binary Search | ctabulationmemoizationdpbinary-search-by-n0hl | 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 | baibhavkr143 | NORMAL | 2024-06-16T04:02:29.198590+00:00 | 2024-06-16T04:15:22.206010+00:00 | 2,490 | 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)$$ --... | 10 | 1 | ['C++'] | 4 |
maximum-total-damage-with-spell-casting | Dynamic Programming solution || [Sort + Optimized O(n) DP] || Python, C++ | dynamic-programming-solution-sort-optimi-8c5g | Intuition\nIt\'s a straightforward Dynamic Programming problem, with 2 main points to note:\n1. DP based on the power level: \nGives the intuition that the orde | ayradnuos | NORMAL | 2024-06-16T04:47:01.072305+00:00 | 2024-06-16T06:47:05.476828+00:00 | 671 | false | # Intuition\nIt\'s a straightforward Dynamic Programming problem, with 2 main points to note:\n1. DP based on the power level: \nGives the intuition that the order of power needs to be maintained and hence, a good starting point would be to sort the powers.\n2. Multiple spells with the same power level:\nThe definition... | 8 | 0 | ['Dynamic Programming', 'Sorting', 'C++', 'Python3'] | 3 |
maximum-total-damage-with-spell-casting | Dynamic Programming Approach || Sorting || Beats 100% in Space and Time || Easy Explaination || C++ | dynamic-programming-approach-sorting-bea-mp8e | \n\n# Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem requires finding the maximum total damage that can be achieved by eit | CS_2201640100272 | NORMAL | 2024-06-16T16:37:51.781004+00:00 | 2024-06-22T05:19:07.463406+00:00 | 350 | false | \n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem requires finding the maximum total damage that can be achieved by either casting or n... | 6 | 0 | ['Dynamic Programming', 'Greedy', 'Sorting', 'C++'] | 2 |
maximum-total-damage-with-spell-casting | Sorting+Recursive DP->iteration||148ms Beats 100% | sortingrecursive-dp-iteration148ms-beats-fsy4 | Intuition\n Describe your first thoughts on how to solve this problem. \nUse recursion+ memo to solve. 1d recursive DP\nUse take or not take argument.\n\n2nd C+ | anwendeng | NORMAL | 2024-06-16T07:18:20.420321+00:00 | 2024-06-16T13:01:42.560641+00:00 | 921 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUse recursion+ memo to solve. 1d recursive DP\nUse take or not take argument.\n\n2nd C++ is a conversion of recursive DP to an iterative DP.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. sort the `power`\n2. Bu... | 6 | 0 | ['Dynamic Programming', 'Sorting', 'C++'] | 1 |
maximum-total-damage-with-spell-casting | DP & Sorting | Either take every occurrence of a num or none | dp-sorting-either-take-every-occurrence-i8o4x | \nclass Solution {\n private Long[] memo = null;\n \n private long dfs(int i, int[] A) {\n int n = A.length;\n if(i >= n) return 0;\n | ved72 | NORMAL | 2024-06-16T08:31:38.381625+00:00 | 2024-06-16T08:32:21.221181+00:00 | 496 | false | ```\nclass Solution {\n private Long[] memo = null;\n \n private long dfs(int i, int[] A) {\n int n = A.length;\n if(i >= n) return 0;\n \n if(memo[i] != null) return memo[i];\n \n long take = 0, skip = 0;\n \n //we will either take every occurrence of a ... | 5 | 0 | ['Dynamic Programming', 'Recursion', 'Memoization', 'Sorting', 'Java'] | 1 |
maximum-total-damage-with-spell-casting | MEMO 📝 + TABULATION 📊 + SPACE OPTIMIZATION 🚀 + C++ 🖥️ 100% | memo-tabulation-space-optimization-c-100-tfed | Problem Explanation\nYou are given an array power, where each element represents the damage of a spell. The goal is to determine the maximum possible total dama | LaxmanSinghBisht | NORMAL | 2024-06-16T04:14:34.709753+00:00 | 2024-06-16T06:14:43.781555+00:00 | 650 | false | ### Problem Explanation\nYou are given an array `power`, where each element represents the damage of a spell. The goal is to determine the maximum possible total damage a magician can achieve under certain constraints:\n- If a spell with damage `power[i]` is cast, spells with damages `power[i] - 2`, `power[i] - 1`, `po... | 5 | 0 | ['C++'] | 3 |
maximum-total-damage-with-spell-casting | DP+Sorting+Map | dpsortingmap-by-ayushnemmaniwar12-d21z | Code\n\nclass Solution {\npublic:\n long long maximumTotalDamage(vector<int>& v) {\n map<long long,long long>m;\n for(auto i:v)\n m[ | ayushnemmaniwar12 | NORMAL | 2024-06-16T04:06:52.955790+00:00 | 2024-06-16T04:06:52.955817+00:00 | 1,284 | false | # Code\n```\nclass Solution {\npublic:\n long long maximumTotalDamage(vector<int>& v) {\n map<long long,long long>m;\n for(auto i:v)\n m[i]++;\n vector<pair<int,long long>>temp;\n for(auto i:m) {\n long long k=i.first*i.second;\n temp.push_back({i.first,k}... | 5 | 0 | ['Dynamic Programming', 'Ordered Map', 'C++'] | 2 |
maximum-total-damage-with-spell-casting | House robber | house-robber-by-dekail-a6dp | Intuition\nSimilar to LC 198 LC 740\n\n\n# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(n)\n\n# Code\n\nclass Solution:\n def maximumTo | dekail | NORMAL | 2024-06-16T04:01:20.827398+00:00 | 2024-06-16T05:08:52.801824+00:00 | 578 | false | # Intuition\nSimilar to [LC 198](https://leetcode.com/problems/house-robber/) [LC 740](https://leetcode.com/problems/delete-and-earn/description/)\n\n\n# Complexity\n- Time complexity:\n$$O(nlogn)$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```\nclass Solution:\n def maximumTotalDamage(self, power: List[int]) -> i... | 5 | 0 | ['Python3'] | 2 |
maximum-total-damage-with-spell-casting | Simple DFS solution | simple-dfs-solution-by-0x4c0de-h4j1 | Intuition\n Describe your first thoughts on how to solve this problem. \nWe have two choices with each distinct power.\n\n### Approach\n Describe your approach | 0x4c0de | NORMAL | 2024-06-16T04:00:42.226593+00:00 | 2024-06-16T04:24:16.257707+00:00 | 875 | false | ### Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe have two choices with each **distinct** power.\n\n### Approach\n<!-- Describe your approach to solving the problem. -->\nUse map to count the power, and DFS with cache to search the best result.\n\n`TreeMap` can sort the power and it... | 5 | 0 | ['Depth-First Search', 'Java'] | 2 |
maximum-total-damage-with-spell-casting | simple recursion +memoization | simple-recursion-memoization-by-demon_co-3bez | First of all sort the power array bcz it doesn\'t matter how we use powers while following the given rule ,\nthe effect of sorting will be if we have selected t | demon_code | NORMAL | 2024-06-26T11:39:09.621278+00:00 | 2024-06-26T11:39:09.621312+00:00 | 59 | false | First of all sort the power array bcz it doesn\'t matter how we use powers while following the given rule ,\nthe effect of sorting will be if we have selected the current element then we can skip next elements which are in +1 and +2 range and call the function after skipping. and we don\'t have to worry about smaller e... | 4 | 0 | ['Recursion', 'Memoization', 'C'] | 0 |
maximum-total-damage-with-spell-casting | 🔥DP || ⚡Memoization || ✅Clean & Easy to understand || Beginner Friendly Solution💯 || | dp-memoization-clean-easy-to-understand-2ynw0 | Intuition\n Describe your first thoughts on how to solve this problem. \nThe key is to decide whether to include or exclude a spell with a particular damage and | virender_kumar | NORMAL | 2024-06-16T06:24:41.506148+00:00 | 2024-06-16T06:24:41.506194+00:00 | 248 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe key is to decide whether to include or exclude a spell with a particular damage and then use that decision to maximize the total damage. Its a simple pick or not pick problem in dynamic programming.\n\n# Approach\n<!-- Describe your a... | 4 | 0 | ['Dynamic Programming', 'Memoization', 'C++'] | 2 |
maximum-total-damage-with-spell-casting | ✅✅ Faster than 100% Solution | Memoization 🤩🤩😱😱 | faster-than-100-solution-memoization-by-gj9so | Intuition\n Describe your first thoughts on how to solve this problem. \nTo maximize the total damage by selecting elements from the array p, ensuring that sele | Rishu_Raj5938 | NORMAL | 2024-06-16T05:44:53.845458+00:00 | 2024-06-17T07:18:29.010209+00:00 | 244 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTo maximize the total damage by selecting elements from the array p, ensuring that selecting one element restricts selecting nearby values (e.g., values differing by 1 or 2).\n\n# Approach\n<!-- Describe your approach to solving the probl... | 4 | 0 | ['C++'] | 1 |
maximum-total-damage-with-spell-casting | Simple 13-line DP + Sorting, explained O(n log n) | simple-13-line-dp-sorting-explained-on-l-39q2 | It is obvious that if we take a spell, we should take all of the spells with the same value, as doing so doesn\'t impose any more restrictions. Then, the next l | t747 | NORMAL | 2024-06-16T04:00:28.967322+00:00 | 2024-06-16T04:00:28.967354+00:00 | 915 | false | It is obvious that if we take a spell, we should take all of the spells with the same value, as doing so doesn\'t impose any more restrictions. Then, the next lowest spell that we can consider taking is a spell with at least 3 more damage. So create two arrays, a sum array, and a next index array, to efficiently skip a... | 4 | 0 | [] | 1 |
maximum-total-damage-with-spell-casting | Memoization Very simple approach | memoization-very-simple-approach-by-kain-mojw | Intuition\n1. Sorting and Frequency Counting:\n\n- First, we sort the array of spell damage values in increasing order. This helps us ensure that when traversin | KaintCode | NORMAL | 2024-06-16T04:55:55.683828+00:00 | 2024-06-16T05:17:54.221865+00:00 | 342 | false | # Intuition\n1. Sorting and Frequency Counting:\n\n- First, we sort the array of spell damage values in increasing order. This helps us ensure that when traversing the array, we move from lower damage values to higher ones.\n- Then, we count the frequency of each unique spell damage value and store it in a map for easy... | 3 | 0 | ['Dynamic Programming', 'Memoization', 'Sorting', 'Ordered Set', 'C++'] | 0 |
maximum-total-damage-with-spell-casting | [Python] DP Knapsack (Simple, full explanations!) | python-dp-knapsack-simple-full-explanati-vonf | Approach\nWe first put all values of power into a frequency array, so that we can compute the total damage we deal by only using this specific power in O(1) tim | zzzqwq | NORMAL | 2024-06-16T04:36:42.272913+00:00 | 2024-06-16T04:36:42.272930+00:00 | 222 | false | # Approach\nWe first put all values of `power` into a frequency array, so that we can compute the total damage we deal by only using this specific power in $$O(1)$$ time by using $$freq[n]*n$$ (n is any number here). \n\nThen we realize that this problem is very similar to the 0/1 knapsack problem, where we can only ad... | 3 | 0 | ['Dynamic Programming', 'Python3'] | 0 |
maximum-total-damage-with-spell-casting | Dynamic Programming - Easy Solution Detailed Explanation | dynamic-programming-easy-solution-detail-9gyp | Intuition\n\nThe goal is to maximize the total damage by selecting powers in a way that no two selected powers differ by 2 or less. This problem can be solved u | chirag45610 | NORMAL | 2024-06-16T04:01:33.488058+00:00 | 2024-06-16T04:01:33.488094+00:00 | 345 | false | ### Intuition\n\nThe goal is to maximize the total damage by selecting powers in a way that no two selected powers differ by 2 or less. This problem can be solved using dynamic programming by leveraging the sorted unique values of power and computing the maximum damage incrementally.\n\n### Approach\n\n1. **Handle Edge... | 3 | 0 | ['C++'] | 0 |
maximum-total-damage-with-spell-casting | Beats 77% Solution Binary Search + Dp | beats-77-solution-binary-search-dp-by-sh-il8y | Code | shlok1913 | NORMAL | 2025-01-31T17:08:49.183700+00:00 | 2025-01-31T17:08:49.183700+00:00 | 65 | false |
# Code
```cpp []
class Solution {
public:
vector<long long>dp;
long long solve(int i , vector<int>&p) {
if (i >= p.size()) return 0;
if (dp[i] != -1) return dp[i];
int j = lower_bound(p.begin() , p.end() , p[i]+3) - p.begin();
int k = lower_bound(p.begin() , p.end() , p[i]+1) - p.begin();
long long... | 2 | 0 | ['Binary Search', 'Dynamic Programming', 'Sorting', 'C++'] | 0 |
maximum-total-damage-with-spell-casting | recursion with dp | recursion-with-dp-by-happygarg-oom8 | Intuition\n Describe your first thoughts on how to solve this problem. \ndid a problem number 740 on leetcode.\n\n# Approach\n Describe your approach to solving | happygarg | NORMAL | 2024-11-25T17:10:00.399252+00:00 | 2024-11-25T17:10:00.399296+00:00 | 24 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\ndid a problem number 740 on leetcode.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nsimply find all the unique numbers and store their frquency.\nthen sort the array of unique numbers and now it is very clear tha... | 2 | 0 | ['C++'] | 0 |
maximum-total-damage-with-spell-casting | dp | dp-by-anil-budamakuntla-pkvo | 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 | ANIL-BUDAMAKUNTLA | NORMAL | 2024-06-21T01:14:58.803095+00:00 | 2024-06-21T01:14:58.803112+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:o(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:o(n)\n<!-- Add your space complexity here, e.g. $$O... | 2 | 0 | ['Dynamic Programming', 'C++'] | 2 |
maximum-total-damage-with-spell-casting | Beats 100% || DP(Tabulation)+Binary Search || Clean Code | beats-100-dptabulationbinary-search-clea-3rvc | Intuition\nUse dynamic programming to keep track of the maximum damage at each step while considering the constraint that an element can only be added if its va | praneki_ | NORMAL | 2024-06-17T07:40:03.688895+00:00 | 2024-06-17T07:40:03.688925+00:00 | 64 | false | # Intuition\nUse dynamic programming to keep track of the maximum damage at each step while considering the constraint that an element can only be added if its value is at least 2 greater than some previously considered element.\n\nIn order to find which elements can contribute to the current element\'s damage without ... | 2 | 0 | ['Binary Search', 'Dynamic Programming', 'C++'] | 0 |
maximum-total-damage-with-spell-casting | 🔥Beats 100% || Intution || Memoization -> Tabulation -> Space Opti || CPP || JAVA || PYTHON || TS | beats-100-intution-memoization-tabulatio-hd6k | Intuition\n Describe your first thoughts on how to solve this problem. \nThis problem is similar to the "House Robber" problem with additional constraints on wh | IchigoGoes | NORMAL | 2024-06-16T14:23:06.079676+00:00 | 2024-06-17T18:14:23.894967+00:00 | 285 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThis problem is similar to the "House Robber" problem with additional constraints on which spells can be cast. If we cast a spell with damage power[i], we can\'t cast spells with adjacent damages in the range of power[i] - 2 to power[i] +... | 2 | 0 | ['Hash Table', 'Dynamic Programming', 'Recursion', 'Memoization', 'Sorting', 'Python', 'C++', 'Java', 'TypeScript'] | 0 |
maximum-total-damage-with-spell-casting | Easy 1D DP [Python, Cpp] Beats 100% | easy-1d-dp-python-cpp-beats-100-by-coder-syuw | \n\n\n\n\n# Intution\nIf we take power[i] we can not take power[i]-2, power[i]-1, power[i]+1, power[i]+2 but we can take all occurences of power[i]\n\nFurthermo | CoderIsCodin | NORMAL | 2024-06-16T10:31:41.639558+00:00 | 2024-09-10T05:16:44.759046+00:00 | 716 | false | \n\n\n\n\n# Intution\nIf we take power[i] we can not take power[i]-2, power[i]-1, power[i]+1,... | 2 | 0 | ['Dynamic Programming', 'Memoization', 'Python', 'C++', 'Python3'] | 1 |
maximum-total-damage-with-spell-casting | Video Explanation (Optimising solution step by step) O(N*2^N) --> O(N*N* --> O(N*logN) --> O(N) | video-explanation-optimising-solution-st-d8l5 | Explanation\n\nClick here for the video\n\n# Code\n\ntypedef long long int ll;\n\nll dp[100001];\nint nxt[100001];\nint same[100001];\n\nclass Solution {\n \ | codingmohan | NORMAL | 2024-06-16T07:52:26.188348+00:00 | 2024-06-16T07:52:26.188371+00:00 | 105 | false | # Explanation\n\n[Click here for the video](https://youtu.be/o_HVLJSeOEY)\n\n# Code\n```\ntypedef long long int ll;\n\nll dp[100001];\nint nxt[100001];\nint same[100001];\n\nclass Solution {\n \n int n;\n vector<ll> arr;\n \n ll MaxDamage (int i) {\n if (i == n) return 0;\n \n ll &an... | 2 | 0 | ['C++'] | 1 |
maximum-total-damage-with-spell-casting | Binary Search + Dynamic Programming (1D-DP) : 100%BEATS (TIME COMPLEXITY & SPACE COMPLEXITY) | binary-search-dynamic-programming-1d-dp-8lkg1 | Intuition\nWe can select Spell by Power[i]+1,Power[i]-1 ,Power[i]+2,Power[i]-2.\ntherfore Sort the power array and after we only select Power[i]+1 and Power[i]+ | user6155rw | NORMAL | 2024-06-16T06:38:24.513520+00:00 | 2024-06-16T06:38:24.513553+00:00 | 46 | false | # Intuition\nWe can select Spell by Power[i]+1,Power[i]-1 ,Power[i]+2,Power[i]-2.\ntherfore Sort the power array and after we only select Power[i]+1 and Power[i]+2 as we move forward .\n \nuse of upper_bound :\nPower Array have multiple same element then binary search through upper bound and next element is different f... | 2 | 0 | ['Binary Search', 'Dynamic Programming', 'C++'] | 0 |
maximum-total-damage-with-spell-casting | 🔥🔥🔥Beats 100% 💯 || JAVA || DP || Memoization || ✅Simple || ✅Clean || ✅Easy to Understand 💯💯💯 | beats-100-java-dp-memoization-simple-cle-u3ta | \n\n\nHere is the Clean, Easy and Fastest Solution for the problem with InDepth Explanation.\nTime Complexity: O(nlogn)\nSpace Complexity: O(n)\n\nIntuition\nTh | anmolmidha | NORMAL | 2024-06-16T06:08:17.044287+00:00 | 2024-06-16T11:03:56.938220+00:00 | 644 | false | \n\n\nHere is the **Clean**, **Easy** and **Fastest** Solution for the problem with **InDepth Explanation**.\nTime Complexity: O(nlogn)\nSpace Complexity: O(n)\n\n**Intuition**\nThe problem requires us to find ... | 2 | 0 | ['Dynamic Programming', 'Tree', 'Java'] | 1 |
maximum-total-damage-with-spell-casting | 🔥 🔥 🔥 Simple Approch | Dp | simple-approch-dp-by-vivek_kumr-o8os | Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem seems to be about calculating the maximum total damage possible using a set | Vivek_kumr | NORMAL | 2024-06-16T04:56:06.016811+00:00 | 2024-06-16T04:56:06.016829+00:00 | 611 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem seems to be about calculating the maximum total damage possible using a set of powers, where each power has a frequency of occurrence. The challenge involves selecting powers such that no two selected powers are within 2 units... | 2 | 0 | ['C++'] | 0 |
maximum-total-damage-with-spell-casting | DP beats % | dp-beats-by-mohityadavtx-lbor | Approach\nDP\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n Add your space complexity here, e.g. O(n) \n\n# Code\n\nclass Solution {\n | mohityadavtx | NORMAL | 2024-06-16T04:27:43.637055+00:00 | 2024-06-16T04:27:43.637078+00:00 | 51 | false | # Approach\nDP\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public long maximumTotalDamage(int[] power) {\n \n Arrays.sort(power);\n int n = power.length;\n long dp... | 2 | 0 | ['Java'] | 1 |
maximum-total-damage-with-spell-casting | Python Memoization and Bottom-up DP nlogn | python-memoization-and-bottom-up-dp-nlog-n2vf | \n# Memo\n\nclass Solution:\n def maximumTotalDamage_memo(self, power: List[int]) -> int:\n @cache\n def memo(i):\n if i >= n:\n | xleafy | NORMAL | 2024-06-16T04:23:58.723641+00:00 | 2024-06-16T05:11:49.584942+00:00 | 262 | false | \n# Memo\n```\nclass Solution:\n def maximumTotalDamage_memo(self, power: List[int]) -> int:\n @cache\n def memo(i):\n if i >= n:\n return 0\n \n cur = counter[avail[i]] * avail[i]\n res = max(cur, memo(i+1))\n\n if i+3 < n and avail... | 2 | 0 | ['Dynamic Programming', 'Memoization', 'Python3'] | 0 |
maximum-total-damage-with-spell-casting | Both Top-Down and Bottom-Up | both-top-down-and-bottom-up-by-mikposp-pb7n | Code #1 - Top-Down\nTime complexity: O(nlog(n)). Space complexity: O(n).\n\nclass Solution:\n def maximumTotalDamage(self, a: List[int]) -> int:\n c = | MikPosp | NORMAL | 2024-06-16T04:12:57.498481+00:00 | 2024-06-20T22:30:43.262825+00:00 | 255 | false | # Code #1 - Top-Down\nTime complexity: $$O(n*log(n))$$. Space complexity: $$O(n)$$.\n```\nclass Solution:\n def maximumTotalDamage(self, a: List[int]) -> int:\n c = sorted(Counter(a).items())\n \n @cache\n def calc(i):\n res1 = i+1 < len(c) and calc(i+1)\n res2 = c[i... | 2 | 0 | ['Dynamic Programming', 'Recursion', 'Memoization', 'Sorting', 'Python', 'Python3'] | 0 |
maximum-total-damage-with-spell-casting | exactly similar code to delete and earn | exactly-similar-code-to-delete-and-earn-3d8cn | IntuitionIn delete and earn problem we have to skip only i-1 and i+1 elements(Moreover we just need to skip i+1 element because sorting will help us in getting | ram_bhakt123 | NORMAL | 2025-02-19T07:47:18.661800+00:00 | 2025-02-19T07:57:12.598289+00:00 | 32 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
In delete and earn problem we have to skip only i-1 and i+1 elements(Moreover we just need to skip i+1 element because sorting will help us in getting rid of i-1 element). And in this problem we have to skip i-1, i-2, i+1, i+2 elements(agai... | 1 | 0 | ['Hash Table', 'Binary Search', 'Dynamic Programming', 'Sorting', 'C++'] | 0 |
maximum-total-damage-with-spell-casting | Easy Iterative Dp | easy-iterative-dp-by-kvivekcodes-duwj | 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 | kvivekcodes | NORMAL | 2024-07-05T10:00:30.654066+00:00 | 2024-07-05T10:00:30.654099+00:00 | 8 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['C++'] | 0 |
maximum-total-damage-with-spell-casting | Python 3 DP+Binary Search solution | python-3-dpbinary-search-solution-by-sai-ne2o | 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 | saisanjith15 | NORMAL | 2024-06-20T17:41:50.740176+00:00 | 2024-06-20T17:41:50.740237+00:00 | 15 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.... | 1 | 0 | ['Hash Table', 'Binary Search', 'Dynamic Programming', 'Sorting', 'Python3'] | 0 |
maximum-total-damage-with-spell-casting | Recursion + memoization DP(Pick and Non Pick concept) with TC : O(n) , SC : O(n) | recursion-memoization-dppick-and-non-pic-si54 | \nclass Solution {\npublic:\n \n long long helper(vector<pair<long long,long long>> &count,vector<long long> &dp,int idx,long long prev){\n if(idx> | adithya_u_bhat | NORMAL | 2024-06-20T11:25:29.235561+00:00 | 2024-06-20T11:28:32.035115+00:00 | 95 | false | ```\nclass Solution {\npublic:\n \n long long helper(vector<pair<long long,long long>> &count,vector<long long> &dp,int idx,long long prev){\n if(idx>=count.size()){\n return 0;\n }\n if(dp[idx]!=-1){\n return dp[idx];\n }\n long long nonPick = helper(count... | 1 | 0 | [] | 0 |
maximum-total-damage-with-spell-casting | 🔥Simple and efficient approach using DP | simple-and-efficient-approach-using-dp-b-4snq | 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 | Sparsh_7637 | NORMAL | 2024-06-19T08:56:53.461242+00:00 | 2024-06-19T08:56:53.461310+00:00 | 62 | 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\n- Space complexity:\n$$O(n)$$ \n\n# Code\n```\nclass Solution {\npublic:\n long long func(vector<long long>& dp, ve... | 1 | 0 | ['C++'] | 0 |
maximum-total-damage-with-spell-casting | DP || Memoization || Previous Element Trick || 2D DP || o(n) | dp-memoization-previous-element-trick-2d-k34p | Intuition\nTake and not take elements. DP based on previous element.\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nCreating a new | KVNS07 | NORMAL | 2024-06-17T20:27:50.485553+00:00 | 2024-06-17T20:27:50.485587+00:00 | 38 | false | # Intuition\nTake and not take elements. DP based on previous element.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nCreating a new unique element array a.\nCreating frequency array b of the elements.\n\nInstead of using index and previous element for memoization.\nTaking 2d DP wit... | 1 | 0 | ['Dynamic Programming', 'C++'] | 1 |
maximum-total-damage-with-spell-casting | Beats 100% in Space/ Memory, Knapsack - like, C++ | beats-100-in-space-memory-knapsack-like-dj0a1 | Intuition\n Describe your first thoughts on how to solve this problem. I\'ve seen a similar problem before on LeetCode.\n# Approach\n1. Sort the array, so that | anchalbajpai | NORMAL | 2024-06-17T11:17:08.532997+00:00 | 2024-06-17T11:20:01.516317+00:00 | 216 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->I\'ve seen a similar problem before on LeetCode.\n# Approach\n1. Sort the array, so that you don\'t have to care about the `power[i]-2` and `power[i]-1` thing.\n\n2. Follow the basic include/exclude approach as in case of bounded knapsack.\... | 1 | 0 | ['Dynamic Programming', 'Recursion', 'C++'] | 1 |
maximum-total-damage-with-spell-casting | No Binary Search (Upper Bound, LowerBound) | Map | Maximum Total Damage With Spell | Easy C++ | no-binary-search-upper-bound-lowerbound-0tp08 | \n# Complexity\n- Time complexity:O(nlogn) : O(n)\ dp + nlogn \ Array \ creation \n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(n)\n Add y | JeetuGupta | NORMAL | 2024-06-17T06:39:01.651088+00:00 | 2024-06-17T06:39:01.651123+00:00 | 31 | false | \n# Complexity\n- Time complexity:$$O(nlogn) : O(n)\\ dp + nlogn \\ Array \\ creation$$ \n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n long long helper(vector<pair<int, int>> &n... | 1 | 0 | ['C++'] | 0 |
maximum-total-damage-with-spell-casting | Tabulataion || C++ | tabulataion-c-by-bhanunegi420-9exl | Intuition\nWe\'ll make a dp array that will store the previous answers of wether taking the element or not. If taken we will take the max element that we can ta | bhanunegi420 | NORMAL | 2024-06-17T02:37:17.271253+00:00 | 2024-06-17T02:37:17.271272+00:00 | 5 | false | # Intuition\nWe\'ll make a dp array that will store the previous answers of wether taking the element or not. If taken we will take the max element that we can take in the array. Sort the array and take the frequency map of the array in order to reduce operations and if we take that element we will take all its occuran... | 1 | 0 | ['Dynamic Programming', 'Greedy', 'C++'] | 0 |
maximum-total-damage-with-spell-casting | O(N) Solution(java) | using dynamic programming | on-solutionjava-using-dynamic-programmin-55lb | Intuition\n Describe your first thoughts on how to solve this problem. \nSimilar to house robber with slight modification\n\n# Approach\ncalculate freqency\nget | rishipebbeti | NORMAL | 2024-06-16T18:06:07.159414+00:00 | 2024-06-16T18:06:07.159443+00:00 | 58 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSimilar to house robber with slight modification\n\n# Approach\ncalculate freqency\nget unique powers\nsort unique powers\ndo dp similar to house robber problem, ignore values bw pow[i-2] and pow[i]\n<!-- Describe your approach to solving... | 1 | 0 | ['Java'] | 0 |
maximum-total-damage-with-spell-casting | EASY DP | easy-dp-by-tin_le-6xd7 | 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 | tin_le | NORMAL | 2024-06-16T16:35:06.156318+00:00 | 2024-06-16T16:36:49.836929+00:00 | 76 | 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-total-damage-with-spell-casting | [CPP] Beats 100% || Detailed Intuition Given in Comments || HashMap || DP | cpp-beats-100-detailed-intuition-given-i-p97s | Intuition & Approach\nDescribe in the Code Comments step by step.\n\n# Complexity\n- Time complexity: O(N LogN) Because of sorting and in the for loop, the coll | Phoenix754 | NORMAL | 2024-06-16T11:19:30.637500+00:00 | 2024-06-16T11:19:30.637521+00:00 | 81 | false | # Intuition & Approach\nDescribe in the Code Comments step by step.\n\n# Complexity\n- **Time complexity**: $$O(N LogN)$$ Because of sorting and in the for loop, the colliding spells are atmost 2 if present. As we are taking unique values so the colliding spells occurs only once in the array. So the for loop is taking ... | 1 | 0 | ['Hash Table', 'Dynamic Programming', 'Sorting', 'C++'] | 0 |
maximum-total-damage-with-spell-casting | Java DP+Map -> From Recursion to Optimised | java-dpmap-from-recursion-to-optimised-b-ah0m | Intuition\nPick and Not pick pattern is used after sorting the given array. A simple condition is added to check if the next incoming element is greater than th | shapunk | NORMAL | 2024-06-16T08:01:14.470174+00:00 | 2024-06-16T08:02:14.125500+00:00 | 101 | false | # Intuition\nPick and Not pick pattern is used after sorting the given array. A simple condition is added to check if the next incoming element is greater than the (given element + 2);\n# Approach\n1. Sort the array\n2. Then in the recursive call, use pick and not pick pattern.\n3. When picking add all the duplicates a... | 1 | 0 | ['Hash Table', 'Dynamic Programming', 'Ordered Map', 'Sorting', 'Java'] | 2 |
maximum-total-damage-with-spell-casting | Don't know how to optimize ? | 100% beats | java | dont-know-how-to-optimize-100-beats-java-9ux2 | \nSort the array to find A[i]+1 A[i]-1 A[i]+2 A[i]-2 easily\n\n### Approach 1 \nnaive DP would be to keep dp[i][j] that stores maximum damage for subarray i..j | Nagaraj_Poojari | NORMAL | 2024-06-16T07:41:37.096177+00:00 | 2024-06-16T07:41:37.096226+00:00 | 131 | false | \nSort the array to find `A[i]+1` `A[i]-1` `A[i]+2` `A[i]-2` easily\n\n### Approach 1 \nnaive DP would be to keep `dp[i][j]` that stores maximum damage for subarray `i..j`.\nThen for every `mid` call for subproblems on left and right side.\nex : \nA=[1,1,1,<ins> 2,2,4,5,5,5 </ins> ,8,9,10]\n```\nlets mid = 5 ,// A[m... | 1 | 0 | ['Hash Table', 'Dynamic Programming', 'Sorting', 'Heap (Priority Queue)', 'Java'] | 0 |
maximum-total-damage-with-spell-casting | DP || Memoization || ✅Clean & Easy to understand💯 | dp-memoization-clean-easy-to-understand-282t8 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n1-Storing the frequency of elements in a map to process the condition for | DivyenduVimal | NORMAL | 2024-06-16T06:52:06.028498+00:00 | 2024-06-16T06:52:06.028528+00:00 | 165 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1-Storing the frequency of elements in a map to process the condition for equal elements.\n2-Storing thee unique values int the vector v and the applying pick and not pick and then taking maximum among them.\n\n# Complexity\... | 1 | 0 | ['Hash Table', 'Dynamic Programming', 'Memoization', 'C++'] | 0 |
maximum-total-damage-with-spell-casting | Using PICK/NOT_PICK concept, just variation of house robber I | using-picknot_pick-concept-just-variatio-ojwb | Intuition\n1. This is a good dp question of pick/not pick pattern(somewhat similar to house robber I).\n2. As we can take duplicate elements as per their freque | Hardy1 | NORMAL | 2024-06-16T06:46:01.823979+00:00 | 2024-06-16T06:46:01.824005+00:00 | 31 | false | # Intuition\n1. This is a good dp question of pick/not pick pattern(somewhat similar to house robber I).\n2. As we can take duplicate elements as per their frequency, so we can maintain a map which sorts the values of power and stores each value\'s frequency.\n# Approach\n1. Maintain a map not unordered map because we... | 1 | 0 | ['Dynamic Programming', 'Ordered Map', 'C++'] | 0 |
maximum-total-damage-with-spell-casting | Easy Solution ||Beats 100% with C++|| 489ms || Hashing || Memoization || 1D DP || Optimized Solution | easy-solution-beats-100-with-c-489ms-has-0krv | Intuition\nThe code implements an algorithm to find the maximum total damage that can be dealt in a scenario where you have an array of power levels (represente | j_aryannn | NORMAL | 2024-06-16T06:24:24.579372+00:00 | 2024-06-16T06:24:24.579399+00:00 | 36 | false | # Intuition\nThe code implements an algorithm to find the maximum total damage that can be dealt in a scenario where you have an array of power levels (represented as integers) and can choose to attack enemies with these powers.\nWe can choose element by either picking it or not picking thus it requires recursion.\n<!-... | 1 | 0 | ['Hash Table', 'Recursion', 'Memoization', 'C++'] | 0 |
maximum-total-damage-with-spell-casting | Simple DP with Set and List Manipulation | simple-dp-with-set-and-list-manipulation-2n35 | Intuition\nThe intuition behind the solution is that we use all duplicates of a spell if the spell is used. Hence, we can use sets to remove duplicates. This si | rigvedmanoj | NORMAL | 2024-06-16T05:22:47.147905+00:00 | 2024-06-16T05:22:47.147935+00:00 | 30 | false | # Intuition\nThe intuition behind the solution is that we use all duplicates of a spell if the spell is used. Hence, we can use sets to remove duplicates. This simplifies the problem immensely because once duplicates are removed and the list is sorted, Only the next 3 numbers need to be checked to find a spell that is ... | 1 | 0 | ['Python3'] | 0 |
maximum-total-damage-with-spell-casting | Priority Queue Unique Solution | Easy to understand | No dynamic programming | priority-queue-unique-solution-easy-to-u-9zcm | Intuition\n Describe your first thoughts on how to solve this problem. \nFor each unique number traverse in ascending order and check what last element for that | atharva1codes | NORMAL | 2024-06-16T05:15:11.831404+00:00 | 2024-06-16T05:15:11.831427+00:00 | 185 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFor each unique number traverse in ascending order and check what last element for that sequence of maximum sum can be picked and follows the constraint of last picked + 1 and last picked + 2.\n\n# Approach\n<!-- Describe your approach to... | 1 | 0 | ['Heap (Priority Queue)', 'C++'] | 1 |
maximum-total-damage-with-spell-casting | C++ easy approach using DP | c-easy-approach-using-dp-by-cookie_33-raie | 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 | cookie_33 | NORMAL | 2024-06-16T05:14:45.657720+00:00 | 2024-06-16T05:14:45.657737+00:00 | 140 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N*LogN)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e... | 1 | 0 | ['Dynamic Programming', 'Greedy', 'C++'] | 0 |
maximum-total-damage-with-spell-casting | 🔥🔥✅ CPP || Dp Tabulation|| binary search | cpp-dp-tabulation-binary-search-by-omraj-mm4w | \n# Code\n\nclass Solution {\npublic:\n long long maximumTotalDamage(vector<int>& power) {\n unordered_map<int,long long>mp;\n for(auto it: | omrajhalwa | NORMAL | 2024-06-16T05:05:35.188183+00:00 | 2024-06-16T05:05:35.188202+00:00 | 28 | false | \n# Code\n```\nclass Solution {\npublic:\n long long maximumTotalDamage(vector<int>& power) {\n unordered_map<int,long long>mp;\n for(auto it:power) mp[it]++;\n vector<int>nums;\n for(auto it:mp){\n nums.push_back(it.first);\n }\n sort(nums.begin(),nums.end())... | 1 | 0 | ['Binary Search', 'Dynamic Programming', 'C++'] | 0 |
maximum-total-damage-with-spell-casting | Binary Search + Dynamic Programming O(NlogN) | binary-search-dynamic-programming-onlogn-ygxd | Intuition\n Describe your first thoughts on how to solve this problem. \nBinary Search\nUse maximum array to save the maximum possible total damage until index | Coco_007 | NORMAL | 2024-06-16T04:52:22.095389+00:00 | 2024-06-16T04:52:22.095407+00:00 | 432 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nBinary Search\nUse maximum array to save the maximum possible total damage until index i. \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... | 1 | 0 | ['Binary Search', 'Dynamic Programming', 'Python3'] | 0 |
maximum-total-damage-with-spell-casting | Easy LIS Approach Dp [cpp] | easy-lis-approach-dp-cpp-by-anish_das001-ht8w | 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 | Anish_das001 | NORMAL | 2024-06-16T04:51:14.002125+00:00 | 2024-06-16T04:51:14.002148+00:00 | 43 | 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-total-damage-with-spell-casting | Maximum Total Damage Calculation Using Non-Consecutive Powers | maximum-total-damage-calculation-using-n-xgy6 | Maximum Total Damage Calculation Using Non-Consecutive Powers\n\n## Intuition\nThe problem involves calculating the maximum total damage that can be achieved by | Cregan_wolf | NORMAL | 2024-06-16T04:49:39.091590+00:00 | 2024-06-16T04:49:39.091607+00:00 | 16 | false | # Maximum Total Damage Calculation Using Non-Consecutive Powers\n\n## Intuition\nThe problem involves calculating the maximum total damage that can be achieved by selecting non-consecutive power values from a given list.\n\n## Approach\n1. **Counting Damage Frequencies**:\n - Use an unordered map `damageCount` to cou... | 1 | 0 | ['Hash Table', 'Dynamic Programming', 'Greedy', 'Sorting', 'C++'] | 0 |
maximum-total-damage-with-spell-casting | ✅ [CPP] | 100% Beats | Recursion + Memoization + Tabulation | Very Simple + Explanation | cpp-100-beats-recursion-memoization-tabu-zbaf | Approach \n In DP problems, we generally ask the number of ways or optimal solution. In this question, we asked the optimal solution to find out the maximum tot | codemitrayt | NORMAL | 2024-06-16T04:46:15.008932+00:00 | 2024-06-16T04:48:35.913665+00:00 | 158 | false | ### Approach \n* In DP problems, we generally ask the number of ways or optimal solution. In this question, we asked the optimal solution to find out the maximum total damage.\n* We have ways to select spells. For the current spell, take or not take; if we take, then our next spell is `power[i] + 2 < power[j]`.\n* We s... | 1 | 0 | ['Dynamic Programming', 'Memoization', 'C++'] | 1 |
maximum-total-damage-with-spell-casting | Javascript sliding window dp | javascript-sliding-window-dp-by-henryche-95ss | \nconst counter = (a_or_s) => { let m = new Map(); for (const x of a_or_s) m.set(x, m.get(x) + 1 || 1); return m; };\nconst stmkey_in = (m) => new Map([...m].so | henrychen222 | NORMAL | 2024-06-16T04:40:54.647706+00:00 | 2024-06-16T04:41:18.938446+00:00 | 33 | false | ```\nconst counter = (a_or_s) => { let m = new Map(); for (const x of a_or_s) m.set(x, m.get(x) + 1 || 1); return m; };\nconst stmkey_in = (m) => new Map([...m].sort((x, y) => x[0] - y[0]));\n\nconst maximumTotalDamage = (a) => {\n let m = counter(a), n = m.size, dp = Array(n).fill(0), l = 0, max = 0;\n m = stmke... | 1 | 0 | ['Dynamic Programming', 'Sliding Window', 'JavaScript'] | 0 |
maximum-total-damage-with-spell-casting | Maximum Total Damage Calculation | maximum-total-damage-calculation-by-creg-uqvi | Intuition\nThe problem involves calculating the maximum total damage possible from a list of power values, considering constraints on consecutive power values.\ | Cregan_wolf | NORMAL | 2024-06-16T04:34:12.184043+00:00 | 2024-06-16T04:34:12.184067+00:00 | 4 | false | # Intuition\nThe problem involves calculating the maximum total damage possible from a list of power values, considering constraints on consecutive power values.\n\n# Approach\nThe approach involves using dynamic programming (DP) to maximize the total damage. We first count occurrences of each power value using a hash ... | 1 | 0 | ['C++'] | 0 |
maximum-total-damage-with-spell-casting | C++ | Bottom Up DP | c-bottom-up-dp-by-prakhargupta456-u65p | Include or not include current element. Use Binary search to figure out the next possible candidate\n\nlong long maximumTotalDamage(vector<int> &power) {\n s | prakhargupta456 | NORMAL | 2024-06-16T04:32:19.988268+00:00 | 2024-06-16T04:32:19.988295+00:00 | 13 | false | Include or not include current element. Use Binary search to figure out the next possible candidate\n```\nlong long maximumTotalDamage(vector<int> &power) {\n sort(power.begin(), power.end());\n int n = power.size();\n vector<long long> dp(n + 1, 0); // Base case, dp[n]=0\n for (int i = n - 1; i >= 0; i--)... | 1 | 0 | ['Dynamic Programming', 'C'] | 0 |
maximum-total-damage-with-spell-casting | SOLUTION BY ELDEN LORD HIMSELF | solution-by-elden-lord-himself-by-aditya-1vo9 | Intuition\n\n Describe your first thoughts on how to solve this problem. \nanyone can tell by the looks of it is dp the tricky part was \nto store the best p | adi_arr | NORMAL | 2024-06-16T04:21:15.692959+00:00 | 2024-06-16T04:21:15.692980+00:00 | 18 | false | # Intuition\n\n<!-- Describe your first thoughts on how to solve this problem. -->\nanyone can tell by the looks of it is dp the tricky part was \nto store the best poss... | 1 | 0 | ['Python3'] | 0 |
maximum-total-damage-with-spell-casting | 1-D Dp Super easy soln(take/ notTake) | 1-d-dp-super-easy-solntake-nottake-by-am-29eo | Intuition\nCreate a map to store the frequency of each element so that we can directly calculate sum from the current element\n\n# Approach\nNow create a vector | am_607 | NORMAL | 2024-06-16T04:16:34.428612+00:00 | 2024-06-16T04:16:34.428643+00:00 | 29 | false | # Intuition\nCreate a map to store the frequency of each element so that we can directly calculate sum from the current element\n\n# Approach\nNow create a vector of pair of int and int to store all the values and its frequencies together because iteration in vector is faster then map \n\n# Complexity\n- Time complexit... | 1 | 0 | ['C++'] | 1 |
maximum-total-damage-with-spell-casting | Beats 100% solution SimpL recursive solution C++ | beats-100-solution-simpl-recursive-solut-x5df | 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 | AshuChauhan | NORMAL | 2024-06-16T04:15:38.898021+00:00 | 2024-06-16T04:15:38.898042+00:00 | 120 | 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: recursive part: O(n ^ 2);\n sorting : O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space c... | 1 | 0 | ['Array', 'Hash Table', 'Dynamic Programming', 'Memoization', 'C++'] | 1 |
maximum-total-damage-with-spell-casting | Python Dp + Binary Search Solution | python-dp-binary-search-solution-by-salm-xzm1 | Code\n\nclass Solution:\n def maximumTotalDamage(self, power: List[int]) -> int:\n cnt = Counter(power)\n power = list(set(power))\n pow | SalmanAd01 | NORMAL | 2024-06-16T04:14:46.814582+00:00 | 2024-06-16T04:14:46.814629+00:00 | 235 | false | # Code\n```\nclass Solution:\n def maximumTotalDamage(self, power: List[int]) -> int:\n cnt = Counter(power)\n power = list(set(power))\n power.sort()\n n = len(power)\n \n @cache\n def recur(ind):\n if ind >= n: return 0\n \n notTake ... | 1 | 0 | ['Hash Table', 'Binary Search', 'Dynamic Programming', 'Recursion', 'Memoization', 'Sorting', 'Python', 'Python3'] | 0 |
maximum-total-damage-with-spell-casting | DP (NLOGN) + prefix indexing, tabulation DP Beats 100% | dp-nlogn-prefix-indexing-tabulation-dp-b-t0vr | \n# Code\n\nclass Solution {\npublic:\n long long maximumTotalDamage(vector<int>& v) {\n int n=v.size();\n sort(v.begin(),v.end());\n ve | himanshuyadavroxx | NORMAL | 2024-06-16T04:08:35.784795+00:00 | 2024-06-16T04:08:35.784833+00:00 | 46 | false | \n# Code\n```\nclass Solution {\npublic:\n long long maximumTotalDamage(vector<int>& v) {\n int n=v.size();\n sort(v.begin(),v.end());\n vector<int> pref(n);\n pref[0]=-1;\n for(int i=1;i<n;i++){\n if(v[i]!=v[i-1]) pref[i]=i-1;\n else pref[i]=pref[i-1];\n ... | 1 | 0 | ['Dynamic Programming', 'C++'] | 0 |
maximum-total-damage-with-spell-casting | easy c++ beats 100% | easy-c-beats-100-by-namanbangari-fho8 | 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 | NamanBangari | NORMAL | 2024-06-16T04:07:43.147916+00:00 | 2024-06-16T04:07:43.147933+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<!-- 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-total-damage-with-spell-casting | NlogN solution | nlogn-solution-by-kayvaibhav-x7jx | \n\n# JS Code\n\n/**\n * @param {number[]} power\n * @return {number}\n */\nvar maximumTotalDamage = function(power) {\n // Step 1: Count frequencies of each | kayvaibhav | NORMAL | 2024-06-16T04:07:10.275991+00:00 | 2024-06-16T04:07:10.276018+00:00 | 56 | false | \n\n# JS Code\n```\n/**\n * @param {number[]} power\n * @return {number}\n */\nvar maximumTotalDamage = function(power) {\n // Step 1: Count frequencies of each spell power\n let count = new Map();\n for (let ele of power) {\n if (count.has(ele)) {\n count.set(ele, count.get(ele) + 1);\n } else ... | 1 | 0 | ['Binary Search', 'Dynamic Programming', 'Sorting', 'JavaScript'] | 0 |
maximum-total-damage-with-spell-casting | Java DP Solution | java-dp-solution-by-sudasan3-lsjl | 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 | Sudasan3 | NORMAL | 2024-06-16T04:06:42.267235+00:00 | 2024-06-16T04:06:42.267266+00:00 | 354 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['Java'] | 1 |
maximum-total-damage-with-spell-casting | ✅[DP]✅Flatten the list and DP | dpflatten-the-list-and-dp-by-nisaacdz-yus7 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nSort the powers\nFlatte | nisaacdz | NORMAL | 2024-06-16T04:04:28.244562+00:00 | 2024-06-16T04:42:24.579910+00:00 | 67 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nSort the powers\nFlatten the power list\nUse 0/1 dp to find the best combination of powers\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g... | 1 | 0 | ['Dynamic Programming', 'C++', 'Rust'] | 0 |
maximum-total-damage-with-spell-casting | Easy Solution :) | easy-solution-by-user20222-s0qs | \n\n# Code\n\nclass Solution {\npublic:\n vector< long long> memo;\n\n long long f(vector<pair<int,int>>& p, int i) {\n if (i >= p.size()) return 0 | user20222 | NORMAL | 2024-06-16T04:00:40.952761+00:00 | 2024-06-16T04:00:40.952795+00:00 | 490 | false | \n\n# Code\n```\nclass Solution {\npublic:\n vector< long long> memo;\n\n long long f(vector<pair<int,int>>& p, int i) {\n if (i >= p.size()) return 0;\n if (memo[i]!=-1) return memo[i];\n long long nt = f(p, i + 1);\n \n int nextIndex = i + 1;\n while (nextIndex < p.size() && p... | 1 | 0 | ['C++'] | 2 |
maximum-total-damage-with-spell-casting | DP + BinarySearch + HashMap (nlogn) | dp-binarysearch-hashmap-nlogn-by-yashmal-i39d | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | YashMalav_945 | NORMAL | 2025-04-07T20:17:41.350861+00:00 | 2025-04-07T20:17:41.350861+00:00 | 2 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['C++'] | 0 |
maximum-total-damage-with-spell-casting | 1D DP solution in C++ | 1d-dp-solution-in-c-by-ishikkaaa-346j | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | ishikkaaa | NORMAL | 2025-04-07T06:48:27.532750+00:00 | 2025-04-07T06:48:27.532750+00:00 | 2 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['C++'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.