#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++
Definitely not an easy one.
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
can you explain this please!
Same concept, Video is of tabulation and your's just space optimized
@@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.
Very good explanation! Thanks🙏🙏
Glad it was helpful!
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]
Noted
Thank you sir🎉
thanks bro