es
Feedback
GeeksForGeeks - POTD | GFG POTD Answer

GeeksForGeeks - POTD | GFG POTD Answer

Canal cerrado

🚩 Channel was restricted by Telegram

Mostrar más
1 218
Suscriptores
Sin datos24 horas
-97 días
-5730 días
Archivo de publicaciones
13th September : C++ Solution ☝🏼 ———————————————————— 🖥Java - @GFGPOTD_Java 📱Python - @GFGPOTD_Python 🙋🏻‍♂️Discussion ⁉️ Join ✅ @GFG_Answer

class Solution{ public: string findLargest(int N, int S){ if(S == 0 && N==1) return "0"; if(S == 0 && N > 1) return "-1"; string ans = ""; for(int i{0}; i < N; ++i){ if(S > 9){ ans += '9'; S -= 9; } else{ ans +=(S + '0'); S = 0; } } return S == 0 ? ans : "-1"; } };

⭐Every Sunday 7PM to 8.30PM⭐ 🙋🏻‍♂️CONTEST : 👉🏼 @gfg_weeklyy ⚡You will be asked to solve 2-3 problems based on data struct
⭐Every Sunday 7PM to 8.30PM⭐ 🙋🏻‍♂️CONTEST : 👉🏼 @gfg_weeklyy ⚡You will be asked to solve 2-3 problems based on data structures and algorithms in 90 minutes. ⚡You will have access to hints. Just like in a real interview, asking for hints may have a negative impact on your overall score. ⚡You can solve the questions in C++, Java, Python. ———————————————————— 😍REWARDS : ⚡Get 2 Geeksbits for participation. ⚡Be among the top 8 rankers on Monthly leaderboard; get 8 Geekbits as bonus. ⭐Join @GFG_Weeklyy For Weekly Contest Answers✨

12th September : C++ Solution ☝🏼 ———————————————————— 🖥Java - @GFGPOTD_Java 📱Python - @GFGPOTD_Python 🙋🏻‍♂️Discussion ⁉️ Join ✅ @GFG_Answer

class Solution { public: int isPerfectNumber(long long N) { if(N==1)return 0; long long sum=1; for(long long i=2;i*i

11th September : C++ Solution ☝🏼 ———————————————————— 🖥Java - @GFGPOTD_Java 📱Python - @GFGPOTD_Python 🙋🏻‍♂️Discussion ⁉️ Join ✅ @GFG_Answer

class Solution{ public: bool isLucky(int n) { if(n%2==0)return false; int len=n; int skip=2; while(skip<=len) { if(n%skip==0)return false; n=n-n/skip; skip++; len=n; } return true; } };

⭐ POTDs ➡️ CPP 💻 | Java 🖥 | Python📱

10th September : C++ Solution ☝🏼 ———————————————————— 🖥Java - @GFGPOTD_Java 📱Python - @GFGPOTD_Python 🙋🏻‍♂️Discussion ⁉️ Join ✅ @GFG_Answer

class Solution { public: Node* insert(Node* node, int data) { // Your code goes here if(!node) return new Node(data); Node* curr = node; while(curr){ if(curr->data == data) return node; if(curr->data > data){ if(curr->left==NULL) {curr->left = new Node(data);break;} curr = curr->left; } else if(curr->data right ==NULL){curr->right = new Node(data);break;} curr = curr->right; } } return node; } };

9th September : C++ Solution ☝🏼

class Solution { public: int kthLargest(Node *root, int K) { vectorans; queueq; q.push(root); while(!q.empty()) { Node *temp=q.front(); q.pop(); ans.push_back(temp->data); if(temp->left!=NULL) { q.push(temp->left); } if(temp->right!=NULL) { q.push(temp->right); } } sort(ans.begin(),ans.end(),greater()); return ans[K-1]; } };

‼️Important‼️ ⚡We Provide Only CPP Solution. ➡️What Do You Want -
Anonymous voting

8th September : C++ Solution ☝🏼

class Solution{ private: int index = 0; void dfs(Node *root,vector &nodes,int nodesReady){ if(root == NULL) return; dfs(root->left,nodes,nodesReady); if(nodesReady) root->data = nodes[index++]; else nodes.push_back(root->data); dfs(root->right,nodes,nodesReady); } public: Node *binaryTreeToBST (Node *root){ vector nodes; dfs(root,nodes,0); sort(nodes.begin(),nodes.end()); dfs(root,nodes,1); return root; } };

7th September : C++ Solution ☝🏼

class Solution { public: int minimumMultiplications(vector& arr, int start, int end) { vectorvis(100000,1e8); queue>q; q.push({start,0}); while(!q.empty()) { int temp=q.front().first; int step=q.front().second; q.pop(); if(temp==end)return step; for(auto x:arr) { int y=(temp*x)%100000; if(1+step

6th September : C++ Solution ☝🏼

class Solution { private: void dfs(vector &vis,vector adj[],int node, set &st) { vis[node]=1; st.insert(node); for(auto it : adj[node]) { if(st.find(it)==st.end()) dfs(vis,adj,it,st); } } public: //Function to find a Mother Vertex in the Graph. int findMotherVertex(int V, vectoradj[]) { vector vis(V,0); //set st; for(int i=0;i st; if(!vis[i]) dfs(vis,adj,i,st); if(st.size()==V) return i; } return -1; } };

5th September : C++ Solution ☝🏼