GeeksForGeeks - POTD | GFG POTD Answer
Canal cerrado
1 218
Suscriptores
Sin datos24 horas
-97 días
-5730 días
Archivo de publicaciones
1st December : C++ Solution ☝🏼
—————————————————————
🙋🏻♂️Discussion ⁉️
Join ✅ @GFG_Answer
⚡Register Yourself For -
Coding Ninja Studio Weekend Contest
class Solution{
public:
int isRepresentingBST(int arr[], int N)
{
for(int i=0; i< N; i++){
if(arr[i]<=arr[i-1]){
return 0;
}
}
return 1;
}
};
🚀 Join Coding Ninjas Studio Weekend Contest 102! 🚀
Unlock incredible opportunities:
🔍 Dream internship with Makerble & Pine & Lime
💼 Full-Time job opportunity with One Card
🌟 One Card Job:
Role: Software Engineer Backend
CTC: 20 - 30 LPA
🚀 Makerble Opportunities:
Ruby on Rails Jr. Developer
CTC: 3 - 4.5 LPA
Ruby on Rails Intern
CTC: 15,000 INR
🌐 Pine & Lime Internship:
Role: Full Stack Developer Intern
Stipend: 15,000 INR
👉 Register: https://tinyurl.com/4z4p2bwm
1st December : C++ Solution ☝🏼
—————————————————————
🙋🏻♂️Discussion ⁉️
Join ✅ @GFG_Answer
⚡Read This Blog
https://www.infowallah.tech/2023/11/Geeks%20For%20Geeks%20Free%20Goodies.html
class Solution{
private:
void solve(Node*root,bool&ans,unordered_map&mp)
{
if(!root) return;
mp[root->data]=true;
if(root->left==NULL && root->right==NULL)
{
//means we are at leaf node
int xp1=root->data+1;
int xm1=root->data-1==0?root->data:root->data-1;
if(mp.find(xp1)!=mp.end() && mp.find(xm1)!=mp.end())
{
//means both are already present
ans=true;
return;
}
}
//otherwise do the recursive calls to left and right
solve(root->left,ans,mp);
solve(root->right,ans,mp);
}
public:
bool isDeadEnd(Node *root)
{
bool ans=false;
unordered_mapmp; //this map is to keep track of nodes inserted till now
solve(root,ans,mp);
return ans;
}
};
https://www.infowallah.tech/2023/11/Geeks%20For%20Geeks%20Free%20Goodies.html
Geeks For Geeks Free Goodies | GFG Free T-Shirt, Bag, Hoodies Swags
30th November : C++ Solution ☝🏼
—————————————————————
🙋🏻♂️Discussion ⁉️
Join ✅ @GFG_Answer
class Solution{
public:
int minimumStep(int n)
{
int count=0;
while(n)
{
if(n/3) count+=1;
count+=n%3;
n=n/3;
if(n==1) break;
if(n==2) return ++count;
}
return count;
}
};
29th November : C++ Solution ☝🏼
—————————————————————
🙋🏻♂️Discussion ⁉️
Join ✅ @GFG_Answer
class Solution {
public:
int isEulerCircuit(int V, vectoradj[]){
int evens =0;
int odds =0;
for(int i =0;i< V;i++){
if(adj[i].size() & 1) odds++;
else evens++;
}
if(evens == V) return 2;
else if (odds <= 2) return 1;
else return 0;
}
};
28th November : C++ Solution ☝🏼
—————————————————————
🙋🏻♂️Discussion ⁉️
Join ✅ @GFG_Answer
class Solution {
public:
int sumOfDependencies(vector adj[], int V) {
int sum=0;
for(int i=0; i
27th November : C++ Solution ☝🏼
—————————————————————
🙋🏻♂️Discussion ⁉️
Join ✅ @GFG_Answer
class Solution
{
public:
int find_set(int v, vector &parent)
{
if (v != parent[v])
{
v = find_set(parent[v], parent);
}
return v;
}
void union_sets(int x, int y, vector &parent, vector &rank)
{
x = find_set(x, parent);
y = find_set(y, parent);
if (rank[x] < rank[y])
{
swap(x, y);
}
parent[y] = x;
rank[x] += rank[y];
}
int detectCycle(int V, vector adj[])
{
vector parent(V);
vector rank(V, 1);
unordered_set, PairHash> s;
for (int i = 0; i < V; i++)
{
parent[i] = i;
}
for (int u = 0; u < V; u++)
{
for (int j = 0; j < adj[u].size(); j++)
{
int v = adj[u][j];
if (s.count({u, v}) || s.count({v, u}))
{
continue;
}
s.insert({u, v});
int x = find_set(u, parent);
int y = find_set(v, parent);
if (x == y)
{
return 1;
}
union_sets(x, y, parent, rank);
}
}
return 0;
}
private:
struct PairHash
{
template
size_t operator()(const pair &p) const
{
auto h1 = hash{}(p.first);
auto h2 = hash{}(p.second);
return h1 ^ h2;
}
};
};
Repost from GeeksForGeeks - POTD | GFG POTD Answer
⚡REDEEM FAST GUYZ⚡
👉🏼Less Than 1000 Available
⭐REDEEM NOW⭐
We Provide Only CPP Solution.
Do You Want Python & JAVA Also ⁉️ (Multple Voting Option On)
26th November : C++ Solution ☝🏼
—————————————————————
🙋🏻♂️Discussion ⁉️
Join ✅ @GFG_Answer
class Solution{
public:
vector pattern(int N){
vectorans;
int i=N;
while(N>0){
ans.push_back(N);
N-=5;
}
N=N-5;
while(N
25th November : C++ Solution ☝🏼
—————————————————————
🙋🏻♂️Discussion ⁉️
Join ✅ @GFG_Answer
class Solution{
public:
void shuffleArray(int arr[],int n)
{
int ans[n];
for(int i=0, j=0; i
