DAY 204 - Cutting Binary String | DP, Strings , BitMagic | JAVA | C++ | GFG POTD 16 May

Sdílet
Vložit
  • čas přidán 14. 05. 2023
  • I have tried explaining all approaches possible for today's GFG POTD question. Watch at 1.5 or 2x for a better experience
    C++ and Java source code, use ctrl+f to search the question name:
    DSA REPOSITORY: github.com/AkshayAnil1080/DSA
    Methods:
    1.O(str(len)^2), O(str(len))
    Code "AKSHAYS10" for 10% off at GFG courses:
    practice.geeksforgeeks.org/co...
    GFG POTD Playlist - • DAY 1 | Filling Bucket...
    Arrays - • Reverse a String | Ep-01
    Recursion - • Lec-1 What is Recursio...
    DP playlist - • Reverse a String | Ep-01
    Linkedin/Instagram: linktr.ee/aksh_yay
    My Insta Acc (specifically made for all of you for any doubts and guidance) - / dsa_with_akshay
    My GFG Profile: auth.geeksforgeeks.org/user/a...
    Hello, I am Akshay.
    I am a Software Engineer at @Brillio. I have made this channel to help all ready to learn, grow, and do something big in Tech. I create content on Data Structures and Algorithms, to fine-tune the problem-solving skills that will help students and software engineers.
    Happy Coding 🤝
    .
    .
    .
    LIKE | SHARE | SUBSCRIBE
    #AkshayAnil #dsa #programming #gfg #gfgpotd #problemsolving #coding #softwareengineer #faang #dsa_with_akshay

Komentáře • 6

  • @HemantKumar-mn7bv
    @HemantKumar-mn7bv Před 11 měsíci

    In this question, the constraint is given that the length of string

  • @devennandapurkar7786
    @devennandapurkar7786 Před rokem +1

    DP ka solution suchjta hi nahi hai yaar 😭😭😭😭

    • @AkshayAnil0-1
      @AkshayAnil0-1  Před rokem

      Krte rho ....aa jaega.... Dp is an advanced dsa topic. Gfg sde sheet ka dp questions solve kr lo . Ho jaega. It will take time

  • @Shujaathullakhan
    @Shujaathullakhan Před rokem +1

    im guessing TC: O(n*|left String Size|+log5(n))
    bool isPowfive(string s){
    long long num=0;
    for(int i=0; i1){
    if(num%5!=0)return false;
    num/=5;
    }
    return true;
    }
    int cuts(string s){
    //code
    if(s.size()==0||s[0]=='0')return -1;
    if(isPowfive(s))return 1;
    int minCut=INT_MAX;
    for(int i=1; i

    • @pushanmukhopadhyay3379
      @pushanmukhopadhyay3379 Před rokem

      public class Solution {
      public boolean isPow5(long n) {
      if (n == 0)
      return false;
      while (n > 1) {
      if (n % 5 != 0)
      return false;
      n /= 5;
      }
      return true;
      }
      public int func(long sum, int j, String s) {
      for (; j < s.length(); j++) {
      sum *= 2;
      sum += (s.charAt(j) == '1') ? 1 : 0;
      if (isPow5(sum)) {
      int x = func(sum, j + 1, s);
      int y = 1 + func(0, j + 1, s);
      return Math.min(x, y);
      }
      if (sum == 0)
      return 100;
      }
      if (sum == 0)
      return 0;
      if (isPow5(sum))
      return 1;
      return 100;
      }
      public int cuts(String s) {
      int temp = func(0, 0, s);
      if (temp > 50)
      return -1;
      return temp;
      }
      }

    • @444yoshitha8
      @444yoshitha8 Před rokem

      it is only valid for even-length string right??