#171

Поділитися
Вставка
  • Опубліковано 12 вер 2024
  • 🚀 Solving Geeks for Geeks Problem of the Day(POTD) in C++ | Trail of ones | Intuition Explained🧠
    Problem Statement : www.geeksforge...
    Solution Code : github.com/Mas...
    🌐 Connect with Me:
    GitHub: github.com/Mas...
    Instagram: www.instagram....
    Linkedin: www.linkedin.com/in/yugayu-garg-47a001225
    💬 Have questions or suggestions? Drop them in the comments below! Let's learn and grow together. Happy coding! 👨‍💻
    #GFG #POTD #geeksforgeeks #problemoftheday #c++

КОМЕНТАРІ • 11

  • @sauravchandra10
    @sauravchandra10 3 місяці тому +5

    Definitely not an easy one.

  • @ashwinbalaji26
    @ashwinbalaji26 3 місяці тому +4

    My solution with O(n) time complexity and O(1) space complexity
    int numberOfConsecutiveOnes(int n) {
    // code here
    if(n < 2) return 0;
    int f0=0,f1=1,f2;
    int ans = 1,mod = 1e9+7;
    for(int i=2;i

    • @ishanmusic677
      @ishanmusic677 3 місяці тому

      can you explain this please!

    • @k-CE-OmkarPathak
      @k-CE-OmkarPathak 3 місяці тому +1

      Same concept, Video is of tabulation and your's just space optimized

    • @rajrajesh1669
      @rajrajesh1669 3 місяці тому +1

      ​@@k-CE-OmkarPathak
      No it's a different approach.
      Here he is directly getting the number of consecutive 1's for a given n. Instead of finding the non consecutive 1's and Subtracting the non consecutive 1's from 2^n.

  • @AtharvaJagam
    @AtharvaJagam 3 місяці тому +1

    Very good explanation! Thanks🙏🙏

  • @umangbehl8152
    @umangbehl8152 3 місяці тому

    nice explanation but will be more easier if you dry run for some n how 0 is appended behind both the binary strings of b[i-1] as well as of a[i-1] and how 1 is appended behind the binary strings of only a[i-1]

  • @expertg1224
    @expertg1224 3 місяці тому

    Thank you sir🎉

  • @xyzhacker00999
    @xyzhacker00999 3 місяці тому

    thanks bro