fa
Feedback
GeeksForGeeks - POTD | GFG POTD Answer

GeeksForGeeks - POTD | GFG POTD Answer

کانال بسته

🚩 Channel was restricted by Telegram

نمایش بیشتر
1 218
مشترکین
اطلاعاتی وجود ندارد24 ساعت
-97 روز
-5730 روز
آرشیو پست ها
29th May : C++ Solution ☝🏼 Get Upto ₹250 - https://g.navi.com/GcIXf

class Solution { public: struct Trie{ Trie *arr[26]; vector str; Trie(){ for(int i=0;i<26;i++) arr[i]=nullptr; str.clear(); } }; void insert(string curr, Trie *root) { for(int i=0;i'Z')continue; if(root->arr[curr[i]-'A']==nullptr) { Trie *node = new Trie(); root->arr[curr[i]-'A']=node; } // cout<arr[curr[i]-'A']; root->str.push_back(curr); i++; while(i='a' and curr[i]<='z') i++; i--; } } void solve(Trie *root, string pat, vector &ans){ for(int i=0;iarr[pat[i]-'A']!=nullptr)root= root->arr[pat[i]-'A']; else return ; } if(root==nullptr)return; ans = root->str; } vector CamelCase(int N, vector D, string Pattern) { Trie *root = new Trie(); for(int i=0;i ans; solve(root, Pattern, ans); if(ans.size()==0)return {"-1"}; return ans; } };

28th May : C++ Solution ☝🏼 Get Upto ₹250 - https://g.navi.com/GcIXf

int getNthFromLast(Node *head, int n) { Node* i = head; Node* j = head; for(int x = 0; x < n; x++){ if(j == NULL) return -1; j = j -> next; } while(j != NULL){ i= i-> next; j = j-> next; } int ans = i->data; return ans; }

27th May : C++ Solution ☝🏼 Get Upto ₹250 - https://t.me/OnlineEarningbyAfzal

class Solution{ public: struct Node* modifyTheList(struct Node *head) { Node* temp = head; vector v; while (temp != NULL) { v.push_back(temp->data); temp = temp->next; } int lo = 0, hi = v.size() - 1; while (lo <= hi) { int temp = v[lo]; v[lo] = v[hi] - v[lo]; v[hi] = temp; lo++; hi--; } Node* nw = new Node(v[0]); Node* hd = nw; for (int i = 1; i < v.size(); i++) { Node* temp_nw = new Node(v[i]); hd->next = temp_nw; hd = temp_nw; } hd->next = NULL; // Set the last node's next pointer to NULL return nw; // Return the modified linked list } };

26th May : C++ Solution ☝🏼 Get Upto ₹250 - https://t.me/OnlineEarningbyAfzal

class Solution{ public: int mod=1e9+7; int solve(int i,int j,int &n,vector&pre,vector>&dp){ if(i>=pre.size() or j>n){ return 0; } if(j==n){ return 1; } if(dp[i][j]!=-1){ return dp[i][j]; } return dp[i][j]=(solve(i+1,j+pre[i],n,pre,dp)+solve(i+1,j,n,pre,dp))%mod; } int numOfWays(int n, int x) { int limit=0; for(int i=1;i<=n;i++){ if(n<=pow(i,x)){ limit=i; break; } } vectorpre(limit+2,0); for(int i=1;i<=limit+1;i++){ pre[i]=pow(i,x); } vector>dp(limit+2,vector(n+1,-1)); return solve(1,0,n,pre,dp); } };

I’ve been learning to code with Mimo. I think you’d like it too. Use my invite link and try the Pro version for 14 days for free. This way you’ll unlock all the features for even faster learning: https://getmimo.com/invite/vlhgec The Easiest Way To Learn Web Dev, Python, SQL Etc.

25th May : C++ Solution ☝🏼 Get Upto ₹250 - https://t.me/OnlineEarningbyAfzal

class Solution { public: void f(int ind,string s,int target,vector &ans,string tmp,long long prev,long long res) { if(ind==s.size()) { if(res==target) ans.push_back(tmp); return; } string st=""; long long curr=0; for(int i=ind;iind && s[ind]=='0') break; st+=s[i]; curr=curr*10+s[i]-'0'; if(ind==0) f(i+1,s,target,ans,tmp+st,curr,curr); else { f(i+1,s,target,ans,tmp+"+"+st,curr,res+curr); f(i+1,s,target,ans,tmp+"-"+st,-curr,res-curr); f(i+1,s,target,ans,tmp+"*"+st,prev*curr,res-prev+prev*curr); } } return; } vector addOperators(string s, int target) { vector ans; string tmp=""; long long prev=0; f(0,s,target,ans,tmp,prev,0); return ans; } };

100 Geekbits Redeemed 😅 Recieved Finally🥳❤️ Stay Connected With @GeeksForGeeks_POTD 🤓❤️
+1
100 Geekbits Redeemed 😅 Recieved Finally🥳❤️ Stay Connected With @GeeksForGeeks_POTD 🤓❤️

Join Here For Online Earning Tricks 💲 T.me/OnlineEarningByAfzal

24th May : C++ Solution ☝🏼 Get Upto ₹250 - https://t.me/Figbyte/21

class Solution { public: int getMaximum(int N, vector &arr) { long long int sum=0; for(int &i:arr) sum+=i; for(int i=N;i>0;i--) if(sum%i==0) return i; return -1; } };

23rd May : C++ Solution ☝🏼

class Solution{ public: int i; int tl; Node* left(int pre[], int level){ if(level == tl) return NULL; Node *root = new Node(pre[i++]); root->left = left(pre, level + 1); root->right = left(pre, level + 1); return root; } Node* constructBinaryTree(int pre[], int preMirror[], int size) { i = 0; tl = log(size+1)/log(2); return left(pre, 0); } };

22nd May : C++ Solution ☝🏼

class Solution { public: int solve(int n, vectorp){ int i,ans=n-1; vectordegree(n+1,0); for(i=1;i

21st May : C++ Solution ☝🏼