From 1e46ccc0d267819cf69f2ed3216c0b8c097af9d7 Mon Sep 17 00:00:00 2001 From: chayan das Date: Sat, 11 Oct 2025 14:06:36 +0530 Subject: [PATCH] Create 3186. Maximum Total Damage With Spell Casting --- 3186. Maximum Total Damage With Spell Casting | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 3186. Maximum Total Damage With Spell Casting diff --git a/3186. Maximum Total Damage With Spell Casting b/3186. Maximum Total Damage With Spell Casting new file mode 100644 index 0000000..4ca1a85 --- /dev/null +++ b/3186. Maximum Total Damage With Spell Casting @@ -0,0 +1,38 @@ +class Solution { +public: + long long dp[100005]; + long long solve(vector>&nums,int idx){ + if(idx>=nums.size()) return 0; + + if(dp[idx]!=-1) return dp[idx]; + + long long take = 0,skip = 0; + + int j = idx+1; + while(j& power) { + + int n = power.size(); + mapmp; + for(auto &it:power) mp[it]++; + + vector>nums; + for(auto &it:mp){ + nums.push_back({it.first,it.second}); + } + + sort(nums.begin(),nums.end()); + + memset(dp,-1,sizeof(dp)); + + return solve(nums,0); + } +};