en
Feedback
GeeksForGeeks - POTD | GFG POTD Answer

GeeksForGeeks - POTD | GFG POTD Answer

Closed channel

🚩 Channel was restricted by Telegram

Show more
1 218
Subscribers
No data24 hours
-97 days
-5730 days
Posts Archive
19th December : C++ Solution☝🏼 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” Want JAVA ? πŸ‘‰πŸΌ /POTD πŸ™‹πŸ»β€β™‚οΈDiscussion ⁉️ Join βœ… @GFG_Answer

class Solution{ public: int posOfRightMostDiffBit(int m, int n) { if (m == n){ return -1; } int position = 1; while (((m & 1) == (n & 1)) && (m > 0) && (n > 0)){ m = m >> 1; n = n >> 1; position++; } return position; } };

18th December : C++ Solution☝🏼 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” Want JAVA ? πŸ‘‰πŸΌ /POTD πŸ™‹πŸ»β€β™‚οΈDiscussion ⁉️ Join βœ… @GFG_Answer

class Solution { public: int gameOfXor(int N, int A[]) { int result = 0; for (int i = 0; i < N; i++) { int count = (i + 1) * (N - i); if (count % 2 == 1) { result ^= A[i]; } } return result; } };

17th December : C++ Solution☝🏼 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” Want JAVA ? πŸ‘‰πŸΌ /POTD πŸ™‹πŸ»β€β™‚οΈDiscussion ⁉️ Join βœ… @GFG_Answer

17th December : C++ Solution ☝🏼 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” Want JAVA ? πŸ‘‰πŸΌ /POTD πŸ™‹πŸ»β€β™‚οΈDiscussion ⁉️ Join βœ… @GFG_Answer

16th December : C++ Solution ☝🏼 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” πŸ’»CPP - @GeeksForGeeks_POTD πŸ“±JAVA - @GfGJava πŸ™‹πŸ»β€β™‚οΈDiscussion ⁉️ Join βœ… @GFG_Answer

class Solution{ public: int findMaxSum(int *arr, int n) { vector dp(n,0); dp[0]=arr[0]; dp[1]=max(arr[0],arr[1]); for(int i=2;i

Just Delivered The πŸ‘•. #GfG_Reward ⚑Comment Down Your Reward Photos. Let's See How Many Rewards We Grabbed.
Just Delivered The πŸ‘•. #GfG_Reward ⚑Comment Down Your Reward Photos. Let's See How Many Rewards We Grabbed.

16th December : C++ Solution ☝🏼 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” πŸ™‹πŸ»β€β™‚οΈDiscussion ⁉️ Join βœ… @GFG_Answer

long long int countStr(long long int n){ if(n== 1){ return 3; } if(n== 2){ return 8; } long long int ans= (n*n*n+ 3*n+ 2)/2; return ans; }

15th December : C++ Solution ☝🏼 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” πŸ™‹πŸ»β€β™‚οΈDiscussion ⁉️ Join βœ… @GFG_Answer

class Solution{ public: void fib(int n,vector&ans){ ans[0]=1; ans[1]=1; for(int i=2;ians(n); fib(n,ans); return (ans[n-1]+ans[n-2])%1000000007; } };

14th December : C++ Solution ☝🏼 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” πŸ™‹πŸ»β€β™‚οΈDiscussion ⁉️ Join βœ… @GFG_Answer

class Solution { public: long long countWays(int n, int k) { // Base cases if (n == 0) { return 0; } else if (n == 1) { return k; } std::vector dp(n + 1, 0); const int mod = 1000000007; dp[1] = k; dp[2] = static_cast(k) * k; for (int i = 3; i <= n; ++i) { long long same_color = (k - 1) * dp[i - 1]; long long diff_color = (k - 1) * dp[i - 2]; dp[i] = (same_color + diff_color) % mod; } return dp[n]; } };

We Are 666 NowπŸ”₯ CPP Sol - @GeekForGeeks_POTD Join Group - @GFG_Answer
We Are 666 NowπŸ”₯ CPP Sol - @GeekForGeeks_POTD Join Group - @GFG_Answer

13th December : C++ Solution ☝🏼 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” πŸ™‹πŸ»β€β™‚οΈDiscussion ⁉️ Join βœ… @GFG_Answer

class Solution { public: #define ll long long ll countStrings(int n) { ll mod = 1e9 + 7; ll a[n], b[n]; a[0] = b[0] = 1; for(int i = 1; i < n; i++){ a[i] = (a[i - 1] + b[i - 1]) % mod; b[i] = a[i - 1] % mod; } return (a[n - 1] + b[n - 1]) % mod; } };

12th December : C++ Solution ☝🏼 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” πŸ™‹πŸ»β€β™‚οΈDiscussion ⁉️ Join βœ… @GFG_Answer

class Solution{ public: int ans = 0; vector> dp; int help(int i, int j, int n, int m, vector> &M) { if (i < 0 or i >= n ) return INT_MIN; if (j == m) return 0; if (dp[i][j] != -1) return dp[i][j]; return dp[i][j] = M[i][j] + max({help(i-1, j+1, n, m, M), help(i, j+1, n, m, M), help(i+1, j+1, n, m, M)}); } int maxGold(int n, int m, vector> M) { // code here dp.resize(n+1, vector(m+1, -1)); for (int i = 0; i < n; i++) { ans = max(ans, help(i, 0, n, m, M)); } return ans; } };