ThinkCode
ThinkCode
  • 362
  • 334 806
Leetcode 3320 Count The Number of Winning Sequences Hindi
Leetcode 3320. Count The Number of Winning Sequences | Hindi
Leetcode 3320. Count The Number of Winning Sequences
3320 Count The Number of Winning Sequences
3320. Count The Number of Winning Sequences
Leetcode 3320. Count The Number of Winning Sequences
Leetcode contest 419
today's leetcode contest 419
Leetcode Count The Number of Winning Sequences
Count The Number of Winning Sequences leetcode
leetcode 3320 hindi
leetcode.com/problems/count-the-number-of-winning-sequences/
Leetcode contest 419
Leetcode 3320 todays leetcode contest Question
Leetcode 3320 leetcode contest
Leetcode 3320
LEETCODE CONTEST "419" CHALLENGE - VERY SIMPLE EXPLANATION with SIMPLE CODE.
Time Complexity of Incrementing the "LIKE" Variable: "LIKE++;" --- O(1)
Time Complexity of "SUBSCRIBING" to the channel: "SUBSCRIBE++;" -- O(1)
But yeah Time Complexity of Commenting is somewhat higher: O(size of comment), maybe you can reduce it by just commenting with an emoji 😉
มุมมอง: 230

วีดีโอ

Leetcode 3306 Count of Substrings Containing Every Vowel and K Consonants II - Hindi
มุมมอง 73121 วันที่ผ่านมา
Leetcode 3306. Count of Substrings Containing Every Vowel and K Consonants II | Hindi Leetcode 3306. Count of Substrings Containing Every Vowel and K Consonants II 3306 Count of Substrings Containing Every Vowel and K Consonants II 3306. Count of Substrings Containing Every Vowel and K Consonants II Leetcode 3306. Count of Substrings Containing Every Vowel and K Consonants II Leetcode contest 4...
Leetcode 3305 Count of Substrings Containing Every Vowel and K Consonants I
มุมมอง 22221 วันที่ผ่านมา
Brute force to check every substring, explained the thought process in easy manner in Hindi Count of Substrings Containing Every Vowel and K Consonants I | Hindi Leetcode 3305. Count of Substrings Containing Every Vowel and K Consonants I 3305 Count of Substrings Containing Every Vowel and K Consonants I 3305. Count of Substrings Containing Every Vowel and K Consonants I Leetcode 3296. Minimum ...
Leetcode 3296 Minimum Number of Seconds to Make Mountain Height Zero | Binary Search | Hindi
มุมมอง 1.6Kหลายเดือนก่อน
Binary Searched two times, explained the thought process in easy manner in Hindi Minimum Number of Seconds to Make Mountain Height Zero | Hindi Leetcode 3282. Minimum Number of Seconds to Make Mountain Height Zero 3296 Minimum Number of Seconds to Make Mountain Height Zero 3296. Minimum Number of Seconds to Make Mountain Height Zero Leetcode 3296. Minimum Number of Seconds to Make Mountain Heig...
Leetcode 3282 Reach End of Array With Max Score Hindi
มุมมอง 263หลายเดือนก่อน
Simple Greedy, explained the thought process in easy manner in Hindi Reach End of Array With Max Score | Hindi Leetcode 3282. Reach End of Array With Max Score 3282 Reach End of Array With Max Score 3282. Reach End of Array With Max Score Leetcode 3282. Reach End of Array With Max Score Leetcode contest 414 today's leetcode contest 414 Leetcode Reach End of Array With Max Score Reach End of Arr...
Leetcode 3281 Maximize Score of Numbers in Ranges
มุมมอง 852หลายเดือนก่อน
Using binary search on answer , explained the thought process in easy manner in Hindi Maximize Score of Numbers in Ranges | Hindi Leetcode 3281. Maximize Score of Numbers in Ranges 3281 Maximize Score of Numbers in Ranges 3281. Maximize Score of Numbers in Ranges Leetcode 3281. Maximize Score of Numbers in Ranges Leetcode contest 414 today's leetcode contest 414 Leetcode Maximize Score of Numbe...
Leetcode 3259. Maximum Energy Boost From Two Drinks Hindi
มุมมอง 1602 หลายเดือนก่อน
Using recursion memo, explained the thought process in easy manner in Hindi Maximum Energy Boost From Two Drinks | Hindi Leetcode 3259. Maximum Energy Boost From Two Drinks 3259 Maximum Energy Boost From Two Drinks 3259. Maximum Energy Boost From Two Drinks Leetcode 3259. Maximum Energy Boost From Two Drinks Leetcode contest 411 today's leetcode contest 411 Leetcode Maximum Energy Boost From Tw...
Komal Kungwani SDE2 @Microsoft organising a happiness workshop on how to crack interviews. Register!
มุมมอง 1943 หลายเดือนก่อน
“𝐇𝐚𝐩𝐩𝐲 𝐒𝐭𝐮𝐝𝐞𝐧𝐭𝐬 = 𝐒𝐮𝐜𝐜𝐞𝐬𝐬𝐟𝐮𝐥 𝐒𝐭𝐮𝐝𝐞𝐧𝐭𝐬! 🎉 Join me, 𝐊𝐨𝐦𝐚𝐥, on July 6th, as I share secrets and tricks to crack any Interview. 🤩 - Develop a 𝐩𝐨𝐬𝐢𝐭𝐢𝐯𝐞 𝐦𝐢𝐧𝐝𝐬𝐞𝐭 that will help you crush any challenge 💡 - Build resilience and 𝐜𝐨𝐧𝐟𝐢𝐝𝐞𝐧𝐜𝐞 that will make you unstoppable 💪 - Learn to 𝐬𝐦𝐢𝐥𝐞 𝐭𝐡𝐫𝐨𝐮𝐠𝐡 𝐜𝐡𝐚𝐥𝐥𝐞𝐧𝐠𝐞𝐬 and come out stronger on the other side 🌈 - 𝐀𝐜𝐡𝐢𝐞𝐯𝐞 𝐘𝐨𝐮𝐫 𝐀𝐢𝐦𝐬 ! 🎉 This session is NOT just about p...
Leetcode Maximize Total Cost of Alternating Subarrays Hindi
มุมมอง 1464 หลายเดือนก่อน
Using recursion memo, explained the thought process in easy manner in Hindi Maximize Total Cost of Alternating Subarrays | Hindi Leetcode 3196. Maximize Total Cost of Alternating Subarrays 3196.Maximize Total Cost of Alternating Subarrays 3196. Maximize Total Cost of Alternating Subarrays Leetcode 3196. Maximum Total Damage With Spell Casting Leetcode contest 403 today's leetcode contest 403 Le...
Leetcode Maximum Total Damage With Spell Casting | Recursion + Memo
มุมมอง 2004 หลายเดือนก่อน
Using recursion memo, explained the thought process in easy manner in Hindi 3186. Maximum Total Damage With Spell Casting | Hindi Leetcode 3186. Maximum Total Damage With Spell Casting 3186.Maximum Total Damage With Spell Casting 3186. Maximum Total Damage With Spell Casting Leetcode 3186. Maximum Total Damage With Spell Casting Leetcode contest 402 today's leetcode contest 402 Leetcode Maximum...
Leetcode 3043. Find the Length of the Longest Common Prefix Hindi
มุมมอง 2628 หลายเดือนก่อน
Simpel Trie Very Simple Explanation, explained in easy manner in Hindi 3043. Find the Length of the Longest Common Prefix | Hindi Leetcode 3043. Find the Length of the Longest Common Prefix 3043. Find the Length of the Longest Common Prefix 3044. Most Frequent Prime Leetcode 3043. Find the Length of the Longest Common Prefix Leetcode contest 385 today's leetcode contest 385 Leetcode Most Freque...
Leetcode 3044. Most Frequent Prime TLE? Hindi
มุมมอง 2588 หลายเดือนก่อน
TLE ? Very Simple Explanation, explained in easy manner in Hindi 3044. Most Frequent Prime | Hindi Leetcode 3044. Most Frequent Prime 3044. Most Frequent Prime 3044. Most Frequent Prime Leetcode 3044. Most Frequent Prime Leetcode contest 385 today's leetcode contest 385 Leetcode Most Frequent Prime Most Frequent Prime leetcode leetcode 3044 hindi leetcode.com/problems/most-frequent-prime/ Leetc...
Leetcode 1642. Furthest Building You Can Reach Hindi
มุมมอง 858 หลายเดือนก่อน
Intuitive and Easy Explanation, explained in easy manner in Hindi 1642. Furthest Building You Can Reach | Hindi Leetcode 1642. Furthest Building You Can Reach 1642. Furthest Building You Can Reach Furthest Building You Can Reach Leetcode 1642. Furthest Building You Can Reach today's leetcode challenge Leetcode Furthest Building You Can Reach Furthest Building You Can Reach leetcode leetcode 164...
Leetcode 1481. Least Number of Unique Integers after K Removals Hindi
มุมมอง 638 หลายเดือนก่อน
Intuitive and Easy Explanation, explained in easy manner in Hindi 1481 Least Number of Unique Integers after K Removals | Hindi Leetcode 1481 Least Number of Unique Integers after K Removals 1481. Least Number of Unique Integers after K Removals Least Number of Unique Integers after K Removals Leetcode 1481. Least Number of Unique Integers after K Removals today's leetcode challenge Leetcode Le...
Built Simple Splitwise in js | Live Coding from Scratch 🔥🔥 | Low Level Design | Part 1
มุมมอง 1319 หลายเดือนก่อน
Built Simple Splitwise in js | Live Coding from Scratch 🔥🔥 | Low Level Design | Part 1
Leetcode 2147 Number of Ways to Divide a Long Corridor
มุมมอง 11810 หลายเดือนก่อน
Leetcode 2147 Number of Ways to Divide a Long Corridor
Leetcode 741 Cherry Pickup - Intuitive And Easy - Hindi
มุมมอง 1.3K11 หลายเดือนก่อน
Leetcode 741 Cherry Pickup - Intuitive And Easy - Hindi
Leetcode 1877 Minimize Maximum Pair Sum in Array
มุมมอง 12711 หลายเดือนก่อน
Leetcode 1877 Minimize Maximum Pair Sum in Array
Leetcode 2905 Find Indices With Index and Value Difference II
มุมมอง 783ปีที่แล้ว
Leetcode 2905 Find Indices With Index and Value Difference II
Leetcode 2895 Minimum Processing Time
มุมมอง 414ปีที่แล้ว
Leetcode 2895 Minimum Processing Time
Leetcode 2896 Apply Operations to Make Two Strings Equal
มุมมอง 2.2Kปีที่แล้ว
Leetcode 2896 Apply Operations to Make Two Strings Equal
Leetcode 2865 Beautiful Towers I
มุมมอง 2Kปีที่แล้ว
Leetcode 2865 Beautiful Towers I
Leetcode 1282 Group the People Given the Group Size They Belong To
มุมมอง 331ปีที่แล้ว
Leetcode 1282 Group the People Given the Group Size They Belong To
Leetcode 2849 Determine if a Cell Is Reachable at a Given Time Hindi
มุมมอง 444ปีที่แล้ว
Leetcode 2849 Determine if a Cell Is Reachable at a Given Time Hindi
Leetcode 2844 Minimum Operations to Make a Special Number Hindi
มุมมอง 770ปีที่แล้ว
Leetcode 2844 Minimum Operations to Make a Special Number Hindi
Hunter in the House! 🔥🔥
มุมมอง 406ปีที่แล้ว
Hunter in the House! 🔥🔥
Leetcode 459 Repeated Substring Pattern + TIME COMPLEXITY IN DEPTH + Hindi
มุมมอง 188ปีที่แล้ว
Leetcode 459 Repeated Substring Pattern TIME COMPLEXITY IN DEPTH Hindi
Leetcode 2831 Find the Longest Equal Subarray | Hindi
มุมมอง 1.1Kปีที่แล้ว
Leetcode 2831 Find the Longest Equal Subarray | Hindi
Leetcode 2828 Check if a String Is an Acronym of Words Hindi
มุมมอง 413ปีที่แล้ว
Leetcode 2828 Check if a String Is an Acronym of Words Hindi
Leetcode 2830 Maximize the Profit as the Salesman Hindi
มุมมอง 1.6Kปีที่แล้ว
Leetcode 2830 Maximize the Profit as the Salesman Hindi

ความคิดเห็น

  • @bhushanasutkar6135
    @bhushanasutkar6135 6 วันที่ผ่านมา

    Will sum>0 always? I doubt. If sum becomes negative then we cannot use dp array

    • @Think_Code
      @Think_Code 6 วันที่ผ่านมา

      yes bro thats why sum>1000 not sum>0 to encounter negative values in dp, so basically sum=0 is represented as sum=1000, and sum=-1 is represented as sum=-999 and so on...

    • @Think_Code
      @Think_Code 6 วันที่ผ่านมา

      since the size is 1000, the worst sum could be -1000, and -1000 is represented as 0. so we just add 1000 to each value whether negative or positive.

  • @shivamchaudhary7574
    @shivamchaudhary7574 7 วันที่ผ่านมา

    bhai solution ka link bhi attatch kr diya kro, Nice explanation👍👍

    • @Think_Code
      @Think_Code 7 วันที่ผ่านมา

      upar hai toh code 😅

  • @Think_Code
    @Think_Code 13 วันที่ผ่านมา

    Like, Subscribe, Comment. Code: class Solution { public: int mod; long long solve(string &s, int index, vector<vector<vector<int> > > &dp, int sum, int w){ if(index==s.size()){ if(sum>s.size()){ return 1; } else{ return 0; } } if(dp[index][sum][w]!=-1){ return dp[index][sum][w]%mod; } if(w==0){ if(s[index]=='F'){ return dp[index][sum][w]=(solve(s,index+1,dp,sum, 1)%mod+solve(s,index+1,dp,sum+1, 2)%mod + solve(s,index+1,dp,sum-1, 3)%mod)%mod; } else if(s[index]=='W'){ return dp[index][sum][w]=(solve(s,index+1,dp,sum, 2)%mod+solve(s,index+1,dp,sum-1, 1)%mod + solve(s,index+1,dp,sum+1, 3)%mod)%mod; } else if(s[index]=='E'){ return dp[index][sum][w]=(solve(s,index+1,dp,sum, 3)%mod+solve(s,index+1,dp,sum-1, 2)%mod + solve(s,index+1,dp,sum+1, 1)%mod)%mod; } } else if(w==1){ if(s[index]=='F'){ return dp[index][sum][w]=(solve(s,index+1,dp,sum+1, 2) %mod+ solve(s,index+1,dp,sum-1, 3)%mod)%mod; } else if(s[index]=='W'){ return dp[index][sum][w]=(solve(s,index+1,dp,sum, 2)%mod+ solve(s,index+1,dp,sum+1, 3)%mod)%mod; } else if(s[index]=='E'){ return dp[index][sum][w]=(solve(s,index+1,dp,sum, 3)%mod+solve(s,index+1,dp,sum-1, 2)%mod )%mod; } } else if(w==2){ if(s[index]=='F'){ return dp[index][sum][w]=(solve(s,index+1,dp,sum, 1)%mod+ solve(s,index+1,dp,sum-1, 3)%mod)%mod; } else if(s[index]=='W'){ return dp[index][sum][w]=(solve(s,index+1,dp,sum-1, 1)%mod + solve(s,index+1,dp,sum+1, 3)%mod)%mod; } else if(s[index]=='E'){ return dp[index][sum][w]=(solve(s,index+1,dp,sum, 3)%mod+solve(s,index+1,dp,sum+1, 1)%mod)%mod; } } else{ if(s[index]=='F'){ return dp[index][sum][w]=(solve(s,index+1,dp,sum, 1)%mod+solve(s,index+1,dp,sum+1, 2)%mod )%mod; } else if(s[index]=='W'){ return dp[index][sum][w]=(solve(s,index+1,dp,sum, 2)%mod+solve(s,index+1,dp,sum-1, 1)%mod )%mod; } else if(s[index]=='E'){ return dp[index][sum][w]=(solve(s,index+1,dp,sum-1, 2)%mod + solve(s,index+1,dp,sum+1, 1)%mod)%mod; } } return 0; } int countWinningSequences(string s) { // vector<vector<int>> dp(s.size(),vector<int>(2001,-1)); mod=pow(10,9)+7; int n=s.size(); vector<vector<vector<int> > > dp( n, vector<vector<int> >(2*n+1, vector<int>(4,-1))); return solve(s,0 , dp, n, 0); } };

  • @iamnoob7593
    @iamnoob7593 17 วันที่ผ่านมา

    Superb man thanks

    • @Think_Code
      @Think_Code 15 วันที่ผ่านมา

      welcome !!!

  • @shristisrivastava7054
    @shristisrivastava7054 19 วันที่ผ่านมา

    Amazing explanation. I also solved this question using a sliding window but couldn't figure out during the contest that if we find a substring with ≥ k consonants and subtract the substring with ≥ k+1 consonants, we can get the substring with exactly k consonants. I learned something new and won't forget this now. Thank you so much for making amazing videos. How do you figure out these tricks? I also want to learn them.

    • @Think_Code
      @Think_Code 19 วันที่ผ่านมา

      Actually it was tricky, I couldn't figure it out during contest, I read discussion posts.

  • @shivnathsinghgaur5972
    @shivnathsinghgaur5972 24 วันที่ผ่านมา

    Thanks 🙏

    • @Think_Code
      @Think_Code 23 วันที่ผ่านมา

      welcome !! 😄

  • @Abhay14
    @Abhay14 27 วันที่ผ่านมา

    bhai sbb kuchh to shi h bss ek doubt h clear krdo, ans += word.size() - j; means we are assuming agr hmme 0 to j tk condition satisfy ho gyi to baaki bache substring me bhi ho jaeggi but catche ye h ki hmme exactly k constant chahiye then how we can assume baki ke word.size() - j substring me k constant honge k se jyada hue to ?

    • @Think_Code
      @Think_Code 27 วันที่ผ่านมา

      yes buddy you understood it correctly, we are finding for >=k and then we will use same function to calculate for >=k+1 so to find for exactly k, we need to subtract them.

    • @Abhay14
      @Abhay14 27 วันที่ผ่านมา

      @@Think_Code i got it thanks bro

  • @Think_Code
    @Think_Code 27 วันที่ผ่านมา

    " i " is the left pointer and " j " is right pointer, we will increment j till the point we are not satisfying our condition of having all vowels and k consonants and when the condition is satisfied we will increment i pointer ( which is left pointer ) till we are still satisfying the condition. Like, Subscribe, Comment if you have doubts. Subscribe !! class Solution { public: long long solve(string word, int k){ int i=0; int j=0; long long ans=0; map<char,int> mp; int cnt=0; while(j<word.size()){ if(word[j]=='a' || word[j]=='e' || word[j]=='i' || word[j]=='o' || word[j]=='u'){ mp[word[j]]++; } else{ cnt++; } // while(mp.size()==5 && cnt>=k){ ans+=word.size()-j; if(mp.find(word[i])!=mp.end()){ mp[word[i]]--; if(mp[word[i]]==0){ mp.erase(word[i]); } } else{ cnt--; } i++; } j++; } return ans; } long long countOfSubstrings(string word, int k) { return solve(word, k) - solve(word,k+1); // Leetcode Count of Substrings Containing Every Vowel and K Consonants II } };

  • @Abhay14
    @Abhay14 27 วันที่ผ่านมา

    Thanks buddy

    • @Think_Code
      @Think_Code 27 วันที่ผ่านมา

      welcome!!

  • @Think_Code
    @Think_Code 27 วันที่ผ่านมา

    Like, Subscribe, Comment. Subscribe !! Code: class Solution { public: int countOfSubstrings(string word, int k) { // a e i o u int ans=0; for(int i=0;i<word.size();i++){ int a=0,e=0,p=0,o=0,u=0,c=0; for(int j=i;j<word.size();j++){ if(word[j]=='a'){ a++; } else if(word[j]=='e'){ e++; } else if(word[j]=='i'){ p++; } else if(word[j]=='o'){ o++; } else if(word[j]=='u'){ u++; } else { c++; } if(a>0 && e>0 && p>0 && o>0 && u >0 && c==k){ ans++; } } } return ans; } };

  • @lunagok7395
    @lunagok7395 หลายเดือนก่อน

    bhai tu 8 min tak output ko hi leke chal raha hai logic toh taab pata chlalega na jab output aaya kaise woh baatega tu output ho hi justify kar raha hai ye baatana ki output aaise aaya

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      First of all, dont use casual language.

    • @lunagok7395
      @lunagok7395 หลายเดือนก่อน

      @@Think_Code you're stuck on the output for 8 minutes straight. You'll only understand the logic once you explain how the output came about. You're justifying the output itself without explaining how it was generated. is this better?

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      @@lunagok7395 Because output we get by binary searching over it. I thought first to explain how you check the correctness of a `assumed answer`. Then i explained we will run a binary search over all the possible answers and check if the assumed answer is possible or not.

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      in the later part, mostly in the last part i have told how we will choose l and r to binary search over all possible answers.

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      i would suggest you to solve how to find sqrt of a number. In which we run a binary search from 1 to n and check if the mid value is answer or not by checking mid*mid==n.

  • @bhavukkalra1786
    @bhavukkalra1786 หลายเดือนก่อน

    Saw a lot of videos overcomplicating this. simplest solution there is.

    • @Think_Code
      @Think_Code 27 วันที่ผ่านมา

      Thanks !!

  • @shristisrivastava7054
    @shristisrivastava7054 หลายเดือนก่อน

    Very clear and amazing explanation. I figured out the first binary search since it’s a max-min type of question, but I couldn’t figure out the second one in the contest. But now its all clear. I’ll be looking forward to your video for the other weekly contest questions as well!

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      Thanks !! Sure! 😄

  • @Mihir_kathpal
    @Mihir_kathpal หลายเดือนก่อน

    Thanks

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      thanks for commentating, it really means a lot.

  • @abhisheksharma1788
    @abhisheksharma1788 หลายเดือนก่อน

    badhiya

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      thanks !! 😃

  • @user-tj4kc9re9t
    @user-tj4kc9re9t หลายเดือนก่อน

    nhi samaj aya ,mere pas dimag nhi hai🤧🤧

    • @gauravkungwani
      @gauravkungwani หลายเดือนก่อน

      Ye aisa question hai ki khud se karo toh hi ache se samaj aaega. Ek binary tak toh theek hai, but dusra binary search lagta hai how would i solve.

  • @Think_Code
    @Think_Code หลายเดือนก่อน

    Like , Subscribe, Comment. Don't forget to SUBSCRIBE !! Code : class Solution { public: int cal(int val, vector<long long > &pre, long long x){ long long l=0; long long r=pre.size()-1; int ans=-1; while(l<=r){ long long mid=l+(r-l)/2; if(pre[mid]*(long long )val<=x){ ans=mid; l=mid+1; } else{ r=mid-1; } } return ans; } bool check(int m, vector<int> &w, long long x,vector<long long > &pre){ // [2,1,1] //ith worker ne kitni h reduce kari x sec // 2,[1,3,6,10,,] // 2,6,12,12,.. // ans = 3 sec possible hai ? for(int i=0;i<w.size();i++){ int p=cal(w[i],pre,x); if(p!=-1){ m-=(p+1); } } if(m<=0){ return true; } return false; } long long minNumberOfSeconds(int m, vector<int>& w) { long long o=(long long )m*(long long )(m+1)/2; long long u=*max_element(w.begin(),w.end()); long long r=o*u; long long l=0; long long ans=pow(10,16); vector<long long > pre; pre.push_back(1); long long t=2; while(1){ if(pre.size()>m){ break; } pre.push_back(pre[pre.size()-1]+t); t++; } // pre = [1,3,6,10,15,21,...] while(l<=r){ long long mid=l+(r-l)/2; if(check(m,w,mid,pre)){ ans=mid; r=mid-1; } else{ l=mid+1; } } return ans; } };

  • @ShivangiSingh-wc3gk
    @ShivangiSingh-wc3gk หลายเดือนก่อน

    Thank you, it would be really hard to come up with this on my own unless I ran through a lot of patterns

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      With Practice, it would be easy. Also some problems click you, sometimes they don't.

  • @New-r8f
    @New-r8f หลายเดือนก่อน

    Didi what was your CGPA?

  • @VIVEKKUMAR-xs9zp
    @VIVEKKUMAR-xs9zp หลายเดือนก่อน

    all testcases are passing but you do not perform bitwise AND, why??

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      because performing the bitwise AND will only reduce the value, so we just have to take maximum element and count its continuous occurence.

    • @VIVEKKUMAR-xs9zp
      @VIVEKKUMAR-xs9zp หลายเดือนก่อน

      @@Think_Code But the same logic is not correct for bitwise OR operation

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      @@VIVEKKUMAR-xs9zp might be, but it Is AND here not OR.

  • @latestmovies9361
    @latestmovies9361 หลายเดือนก่อน

    bro one question is sorting the given array wont effect the absolute difference of orignal array

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      yes it will not effect. How it will ? You only have to choose elements from the array, doesn't matter the order.

    • @latestmovies9361
      @latestmovies9361 หลายเดือนก่อน

      @@Think_Code thank you bro

  • @pranjal-barnwal
    @pranjal-barnwal หลายเดือนก่อน

    Can you please explain, why you took low as 0 for starting condition of Binary Search. Suppose you have array: [0, 4, 8] and d=1. Here the minimum valid difference shouldn't be: 4 I have doubt for this not being Monotonic in this way.

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      yes in that case you can calculate the low value as i have calculated the high value.

  • @AyushiSharmaDSA
    @AyushiSharmaDSA หลายเดือนก่อน

    thank you for mentioning my channel 😊😊

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      W E L C O M E !! 😄

  • @shristisrivastava7054
    @shristisrivastava7054 หลายเดือนก่อน

    The best video I found for this question. Huge shoutout!

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      T H A N K S !! 😄

  • @unknown__899
    @unknown__899 หลายเดือนก่อน

    not able to solve in contest 😭😭

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      Koi na !! Next time 👊

  • @abhinay.k
    @abhinay.k หลายเดือนก่อน

    Thanks

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      welcome!!

  • @mukulkhanna5071
    @mukulkhanna5071 หลายเดือนก่อน

    nice bro keep posting

  • @Think_Code
    @Think_Code หลายเดือนก่อน

    Like! SUBSCRIBE! Comment! Below is the code : Code : class Solution { public: long long findMaximumScore(vector<int>& nums) { long long ans=0; int curr=nums[0]; int j=0; for(int i=1;i<nums.size();i++){ if(nums[i]>curr){ ans+=(long long )curr*(long long )(i-j); curr=nums[i]; j=i; } } if(j!=nums.size()-1){ ans+=(long long )curr*(long long )(nums.size()-1-j); } return ans; } };

  • @Think_Code
    @Think_Code หลายเดือนก่อน

    Like! SUBSCRIBE! Comment! Below is the code : Code : class Solution { public: bool check(long long x, vector<long long> &start, int d){ long long curr=start[0]; for(int i=1;i<start.size();i++){ if(start[i]>curr+(long long )x){ curr=start[i]; } else if(curr+(long long)x <= (long long )start[i]+(long long )d){ curr = curr+x; } else{ return 0; } } return 1; } int maxPossibleScore(vector<int>& s, int d) { vector<long long > start; for(int i=0;i<s.size();i++){ start.push_back((long long )s[i]); } sort(start.begin(),start.end()); int l=0; int r=d+start[start.size()-1]-start[0]; int ans=0; while(l<=r){ long long mid=l+(r-l)/2; if(check(mid,start,d)){ ans=mid; l=mid+1; } else{ r=mid-1; } } return ans; } };

  • @SonuSharma-fc9hd
    @SonuSharma-fc9hd หลายเดือนก่อน

    Nice Explanation bro👊

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      thanks

  • @princysinha740
    @princysinha740 2 หลายเดือนก่อน

    cant we have visited array rather than using masking?

    • @Think_Code
      @Think_Code หลายเดือนก่อน

      how will you store that in the dp array? you can make a dp array of dp[ u ] [ mask ], since mask is just an integer

  • @iamnoob7593
    @iamnoob7593 2 หลายเดือนก่อน

    I wrote recursive code for this same as house robber. Thanks

  • @idiomz4104
    @idiomz4104 2 หลายเดือนก่อน

    good video. Friendly feedback: the voice volume is low. I had to plug in my headphones. Had a question, in such dp questions, how do you first find the overlapping subproblems though? Maine input ke sath try kiya tha and also with some test cases i made up. i still couldn't find any overlaps at all. Har baar alag alag test cases ke trees banane padhenge ya we just wing it with the dp cache and hope there are overlaps? Contest mai kaise solve karen is type ke dp questions? Mujhe laga ye dp question hoga hi nahi kyunki i didnt any overlaps, i wasted 1 hour 15 mins of my contesst time trying to solve it with greedy. i got pretty close (502/563) test cases passed and it took me until today to figure out why greedy won't work. How do I improve at this?

    • @Think_Code
      @Think_Code 2 หลายเดือนก่อน

      dekho aisa hota hai, ki 2-3 bar tumhe dekhna padega ki overlap hai ki nahi, phir muscle memory se khud hi dikh jata hai ki hain overlap hai. Vahi tree banake dekhna padega ki subproblems repeat ho rahi hai. Greedy ke liye ek-2 test case khud sochne padenge jinpe run nahi karega. Bahut simply mil jate hai, jaise [1,3,2] [3,1,1] hota agar toh 3 lete second array se phir agar upar wale array me jaoge. toh ek leave karna padega phir 2 le loge greedy se but answer 6 hoga not 5.

  • @AbhishekSharma-sj3hw
    @AbhishekSharma-sj3hw 2 หลายเดือนก่อน

    Efforts 👍🏻👍🏻

    • @Think_Code
      @Think_Code 2 หลายเดือนก่อน

      thanks!

  • @Anonymous____________A721
    @Anonymous____________A721 2 หลายเดือนก่อน

    Excellentttttt

    • @Think_Code
      @Think_Code 2 หลายเดือนก่อน

      thanks !!

  • @Anonymous____________A721
    @Anonymous____________A721 2 หลายเดือนก่อน

    Thank youuuuuuu

    • @Think_Code
      @Think_Code 2 หลายเดือนก่อน

      Welcome!

  • @BABATUNDE-h7d
    @BABATUNDE-h7d 2 หลายเดือนก่อน

    thanks mere sindhi bhai

    • @Think_Code
      @Think_Code 2 หลายเดือนก่อน

      thanks bhai !!

  • @asmitamhetre
    @asmitamhetre 2 หลายเดือนก่อน

    Best explanation 👍

    • @Think_Code
      @Think_Code 2 หลายเดือนก่อน

      thanks !! 😄

  • @vaibhzDixit
    @vaibhzDixit 3 หลายเดือนก่อน

    Perfect ❤

    • @Think_Code
      @Think_Code 2 หลายเดือนก่อน

      thanks !!

  • @chitranshjain9714
    @chitranshjain9714 3 หลายเดือนก่อน

    class Solution { public: void order(vector<pair<long long, long long>>& vec) { int n = vec.size(); for (auto& it : vec) { it.second = (it.second + (n - 1)) % n; } } long long minCost(vector<int>& nums, int x) { vector<pair<long long, long long>> vec; int n = nums.size(); for (long long i = 0; i < n; i++) { vec.push_back({nums[i], i}); } vector<long long> ans; for (auto& it : vec) { ans.push_back(it.first); } long long minm = accumulate(ans.begin(), ans.end(), 0ll); for (long long op = 1; op < n; op++) { order(vec); long long result = 0; for (int i = 0; i < n; i++) { long long val = vec[i].first; long long idx = vec[i].second; if (ans[idx] > val) { result += val; ans[idx] = val; } else { result += ans[idx]; } } result += (long long)(op * x); minm = min(result, minm); } return minm; } };

  • @pratikpranjal716
    @pratikpranjal716 3 หลายเดือนก่อน

    You'll get MLE on this solution

    • @Think_Code
      @Think_Code 2 หลายเดือนก่อน

      i didnt got

  • @iceyyeah
    @iceyyeah 3 หลายเดือนก่อน

    Amazing explaination

    • @Think_Code
      @Think_Code 3 หลายเดือนก่อน

      thanks !!😃

  • @shivamdubey4631
    @shivamdubey4631 3 หลายเดือนก่อน

    Good explanation sir.

    • @Think_Code
      @Think_Code 3 หลายเดือนก่อน

      thanks !! 😄

  • @khushvantkumar1670
    @khushvantkumar1670 3 หลายเดือนก่อน

    👎👎👎

  • @ritik6095
    @ritik6095 3 หลายเดือนก่อน

    so smooth bro,nicely done😁😁😁

    • @Think_Code
      @Think_Code 3 หลายเดือนก่อน

      thanks !!😄

  • @mukulkhanna5071
    @mukulkhanna5071 3 หลายเดือนก่อน

    bhai video ekdum bdia hai par voice mai thoda issue tha difficulty horhi ha samajhne mai thodi

    • @Think_Code
      @Think_Code 3 หลายเดือนก่อน

      @@mukulkhanna5071 haan dikkat toh hai 😓😓

  • @rakeshbijarniya3321
    @rakeshbijarniya3321 3 หลายเดือนก่อน

    Great

    • @Think_Code
      @Think_Code 3 หลายเดือนก่อน

      thanks !! 😄

  • @redder02
    @redder02 3 หลายเดือนก่อน

    no need to use max in first and third if, btw good solution

  • @vatsalshingala3225
    @vatsalshingala3225 4 หลายเดือนก่อน

    what is rans

    • @Think_Code
      @Think_Code 3 หลายเดือนก่อน

      i guess its not getting used, so you can ignore

  • @Think_Code
    @Think_Code 4 หลายเดือนก่อน

    Subscribe !! Like !! Comment !! Code : class Solution { public: long long solve(vector<int> &nums, vector<vector<long long >> &dp, int index, int choice){ if(index==nums.size()){ return 0; } if(dp[index][choice]!=INT_MIN){ return dp[index][choice]; } if(choice==0){ return (long long )nums[index]+solve(nums, dp, index+1, 1); } long long newS= (long long )nums[index]+solve(nums, dp, index+1, 1); long long cont = (long long )(-nums[index])+solve(nums, dp, index+1, 0); return dp[index][choice] = max(newS,cont); } long long maximumTotalCost(vector<int>& nums) { vector<vector<long long >> dp(nums.size(),vector<long long > (2,INT_MIN)); return solve(nums, dp, 0, 0); } };