GeeksForGeeks - POTD | GFG POTD Answer
قناة بسيطة
1 218
المشتركون
لا توجد بيانات24 ساعات
-97 أيام
-5730 أيام
أرشيف المشاركات
11th July : C++ Solution☝🏼
————————————————————
🙋🏻♂️Discussion ⁉️
Join ✅ @GFG_Answer
🧩 Flutter Courses Uploaded 🧩
class Solution {
public:
vector<int> dirX={1,0,0,-1};
vector<int> dirY={0,1,-1,0};
void dfs(vector<vector<int>> &parent,map<int,int>&mp,int p,int i,int j, vector<vector<int>>&grid){
if(i<0 || j<0 || i>=grid.size() || j>=grid[0].size() || parent[i][j]!=-1 || grid[i][j]!=1){
return;
}
parent[i][j]=p;
mp[p]++;
for(int k=0;k<4;k++){
dfs(parent,mp,p,i+dirX[k],j+dirY[k],grid);
}
}
int MaxConnection(vector<vector<int>>& grid) {
vector<vector<int>> parent(grid.size(),vector<int>(grid[0].size(),-1));
map<int,int> mp;
int p=1;
for(int i=0;i<grid.size();i++){
for(int j=0;j<grid[i].size();j++){
if(grid[i][j]==1 && parent[i][j]==-1){
dfs(parent,mp,p,i,j,grid);
p++;
}
}
}
int maxi=0;
for(int i=0;i<grid.size();i++){
for(int j=0;j<grid[i].size();j++){
if(grid[i][j]==0){
set<int> s;
int curr=1;
for(int k=0;k<4;k++){
int x=i+dirX[k];
int y=j+dirY[k];
if(x>-1 && y>-1 && x<grid.size() && y<grid[0].size()){
if(parent[x][y]!=-1 && s.find(parent[x][y])==s.end()){
s.insert(parent[x][y]);
curr+=mp[parent[x][y]];
}
}
}
maxi=max(curr,maxi);
}
}
}
for(auto &i:mp){
maxi=max(maxi,i.second);
}
return maxi;
}
};🧩 React.JS 5 Days BootCamp 🧩
🗓 Starting from 15th July'24
💡 Daily at 6:00 PM
⚡ FREE of ₹ Cost
⚡ Basic to Advance Knowledge 📚
⚡ Advance Projects Building 👨🏻💻
⚡ Live Classes 🌱
🤔 Why Wait ? Enroll Now
10th July : C++ Solution☝🏼
————————————————————
🙋🏻♂️Discussion ⁉️
Join ✅ @GFG_Answer
🧩 Flutter Courses Uploaded 🧩
class Solution {
public:
int maxSquare(int n, int m, vector<vector<int>> mat) {
vector<vector<int>> dp(n,vector<int> (m,0));
int maxi =0;
for(int i =0;i< max(n,m);i++){
if(i < m && mat[n -1][i] == 1){
dp[n -1][i] =1;
maxi =max(maxi,dp[n -1][i]);
}
if(i < n && mat[i][m -1] == 1){
dp[i][m -1] =1;
maxi =max(maxi,dp[i][m -1]);
}
}
for(int i=n -2;i>=0;i--){
for(int j =m -2;j>=0;j--){
if(mat[i][j]){
dp[i][j] =1 + min(dp[i +1][j +1],min(dp[i +1][j],dp[i][j +1]));
}else{
dp[i][j] =0;
}
maxi =max(dp[i][j],maxi);
}
}
return maxi;
}
};9th July : C++ Solution☝🏼
————————————————————
🙋🏻♂️Discussion ⁉️
Join ✅ @GFG_Answer
class Solution {
public:
int threeSumClosest(vector<int> arr, int target) {
int dif=INT_MAX,ans=INT_MIN;
sort(arr.begin(),arr.end());
for(int i=0;i<arr.size();i++){
int start=i+1;
int end=arr.size()-1;
while(start<end){
int sum=arr[i]+arr[start]+arr[end];
if(sum==target)return sum;
else if(sum>target) end--;
else start++;
if(abs(sum-target)<dif){
dif=abs(sum-target);
ans=sum;
}
else if(abs(sum-target)==dif){
ans=max(ans,sum);
}
}
}
return ans;
}
};🧩 Complete Any Course You Like
📄 Get A Free Certificate
✅ Postman API Fundamentals
🔗 Enroll
🐍 Python Project Bootcamp
🔗 Enroll
💻 HTML & CSS Bootcamp
🔗 Enroll
💡 Javascript Bootcamp
🔗 Enroll
⚡️ Java Bootcamp
🔗 Enroll
😍 React Bootcamp
🔗 Enroll
🤖 Prompt Engineering Bootcamp
🔗 Enroll
🖥 Machine Learning using Python Bootcamp
🔗 Enroll
📊 Placement Prep. 5 Days Bootcamp
🔗 Enroll
📈 Data Analytics Bootcamp
🔗 Enroll
💡 Node.js Bootcamp
🔗 Enroll
👨🏻💻 C++ Bootcamp
🔗 Enroll
👽 Cyber Security and Ethical Hacking Bootcamp
🔗 Enroll
✅ SQL 5 Days Bootcamp
🔗 Enroll
💡 DSA with C++ Bootcamp
🔗 Enroll
📅 Excel Bootcamp
🔗 Enroll
🤖 ChatGPT Bootcamp
🔗 Enroll
📱 Graphic Designing Bootcamp
🔗 Enroll
👨🏻💻 Flutter Bootcamp
🔗 Enroll
📱 Build No-Code App with AppSheet Bootcamp
🔗 Enroll
🧑🏻⚖️ Data Science with Python Bootcamp
🔗 Enroll
💻 Canva Bootcamp
🔗 Enroll
🕯 Looker Studio Bootcamp
🔗 Enroll
🍃 Tailwind CSS Bootcamp
🔗 Enroll
⚡️ Google Sheets Bootcamp
🔗 Enroll
🧩 Complete Any Course You Like
📄 Get A Free Certificate
✅ Postman API Fundamentals
🔗 Enroll
🐍 Python Project Bootcamp
🔗 Enroll
💻 HTML & CSS Bootcamp
🔗 Enroll
💡 Javascript Bootcamp
🔗 Enroll
⚡️ Java Bootcamp
🔗 Enroll
😍 React Bootcamp
🔗 Enroll
🤖 Prompt Engineering Bootcamp
🔗 Enroll
🖥 Machine Learning using Python Bootcamp
🔗 Enroll
📊 Placement Prep. 5 Days Bootcamp
🔗 Enroll
📈 Data Analytics Bootcamp
🔗 Enroll
💡 Node.js Bootcamp
🔗 Enroll
👨🏻💻 C++ Bootcamp
🔗 Enroll
👽 Cyber Security and Ethical Hacking Bootcamp
🔗 Enroll
✅ SQL 5 Days Bootcamp
🔗 Enroll
💡 DSA with C++ Bootcamp
🔗 Enroll
📅 Excel Bootcamp
🔗 Enroll
🤖 ChatGPT Bootcamp
🔗 Enroll
📱 Graphic Designing Bootcamp
🔗 Enroll
👨🏻💻 Flutter Bootcamp
🔗 Enroll
📱 Build No-Code App with AppSheet Bootcamp
🔗 Enroll
🧑🏻⚖️ Data Science with Python Bootcamp
🔗 Enroll
💻 Canva Bootcamp
🔗 Enroll
🕯 Looker Studio Bootcamp
🔗 Enroll
🍃 Tailwind CSS Bootcamp
🔗 Enroll
⚡️ Google Sheets Bootcamp
🔗 Enroll
🧩 Complete Any Course You Like
📄 Get A Free Certificate
✅ Postman API Fundamentals
🔗 Enroll
🐍 Python Project Bootcamp
🔗 Enroll
💻 HTML & CSS Bootcamp
🔗 Enroll
💡 Javascript Bootcamp
🔗 Enroll
⚡️ Java Bootcamp
🔗 Enroll
😍 React Bootcamp
🔗 Enroll
🤖 Prompt Engineering Bootcamp
🔗 Enroll
🖥 Machine Learning using Python Bootcamp
🔗 Enroll
📊 Placement Prep. 5 Days Bootcamp
🔗 Enroll
📈 Data Analytics Bootcamp
🔗 Enroll
💡 Node.js Bootcamp
🔗 Enroll
👨🏻💻 C++ Bootcamp
🔗 Enroll
👽 Cyber Security and Ethical Hacking Bootcamp
🔗 Enroll
✅ SQL 5 Days Bootcamp
🔗 Enroll
💡 DSA with C++ Bootcamp
🔗 Enroll
📅 Excel Bootcamp
🔗 Enroll
🤖 ChatGPT Bootcamp
🔗 Enroll
📱 Graphic Designing Bootcamp
🔗 Enroll
👨🏻💻 Flutter Bootcamp
🔗 Enroll
📱 Build No-Code App with AppSheet Bootcamp
🔗 Enroll
🧑🏻⚖️ Data Science with Python Bootcamp
🔗 Enroll
💻 Canva Bootcamp
🔗 Enroll
🕯 Looker Studio Bootcamp
🔗 Enroll
🍃 Tailwind CSS Bootcamp
🔗 Enroll
⚡️ Google Sheets Bootcamp
🔗 Enroll
🧩 Complete Any Course You Like
📄 Get A Free Certificate
✅ Postman API Fundamentals
🔗 Enroll
🐍 Python Project Bootcamp
🔗 Enroll
💻 HTML & CSS Bootcamp
🔗 Enroll
💡 Javascript Bootcamp
🔗 Enroll
⚡️ Java Bootcamp
🔗 Enroll
😍 React Bootcamp
🔗 Enroll
🤖 Prompt Engineering Bootcamp
🔗 Enroll
🖥 Machine Learning using Python Bootcamp
🔗 Enroll
📊 Placement Prep. 5 Days Bootcamp
🔗 Enroll
📈 Data Analytics Bootcamp
🔗 Enroll
💡 Node.js Bootcamp
🔗 Enroll
👨🏻💻 C++ Bootcamp
🔗 Enroll
👽 Cyber Security and Ethical Hacking Bootcamp
🔗 Enroll
✅ SQL 5 Days Bootcamp
🔗 Enroll
💡 DSA with C++ Bootcamp
🔗 Enroll
📅 Excel Bootcamp
🔗 Enroll
🤖 ChatGPT Bootcamp
🔗 Enroll
📱 Graphic Designing Bootcamp
🔗 Enroll
👨🏻💻 Flutter Bootcamp
🔗 Enroll
📱 Build No-Code App with AppSheet Bootcamp
🔗 Enroll
🧑🏻⚖️ Data Science with Python Bootcamp
🔗 Enroll
💻 Canva Bootcamp
🔗 Enroll
🕯 Looker Studio Bootcamp
🔗 Enroll
🍃 Tailwind CSS Bootcamp
🔗 Enroll
⚡️ Google Sheets Bootcamp
🔗 Enroll
🧩 Complete Any Course You Like
📄 Get A Free Certificate
✅ Postman API Fundamentals
🔗 Enroll
🐍 Python Project Bootcamp
🔗 Enroll
💻 HTML & CSS Bootcamp
🔗 Enroll
💡 Javascript Bootcamp
🔗 Enroll
⚡️ Java Bootcamp
🔗 Enroll
😍 React Bootcamp
🔗 Enroll
🤖 Prompt Engineering Bootcamp
🔗 Enroll
🖥 Machine Learning using Python Bootcamp
🔗 Enroll
📊 Placement Prep. 5 Days Bootcamp
🔗 Enroll
📈 Data Analytics Bootcamp
🔗 Enroll
💡 Node.js Bootcamp
🔗 Enroll
👨🏻💻 C++ Bootcamp
🔗 Enroll
👽 Cyber Security and Ethical Hacking Bootcamp
🔗 Enroll
✅ SQL 5 Days Bootcamp
🔗 Enroll
💡 DSA with C++ Bootcamp
🔗 Enroll
📅 Excel Bootcamp
🔗 Enroll
🤖 ChatGPT Bootcamp
🔗 Enroll
📱 Graphic Designing Bootcamp
🔗 Enroll
👨🏻💻 Flutter Bootcamp
🔗 Enroll
📱 Build No-Code App with AppSheet Bootcamp
🔗 Enroll
🧑🏻⚖️ Data Science with Python Bootcamp
🔗 Enroll
💻 Canva Bootcamp
🔗 Enroll
🕯 Looker Studio Bootcamp
🔗 Enroll
🍃 Tailwind CSS Bootcamp
🔗 Enroll
⚡️ Google Sheets Bootcamp
🔗 Enroll
⚠ Important Announcement🧩 Google Cloud Arcade Swags 🔥 For Sale 🔥 ✅ Full Set Will Be Given ⭐ 10 Points - ₹ 1k 🧩 25 Points - ₹ 1.5k 🔥 40 Points - ₹ 2k ⚡ Contact Admin
8th July : C++ Solution☝🏼
————————————————————
🙋🏻♂️Discussion ⁉️
Join ✅ @GFG_Answer
class Solution {
public:
int search(vector<int>& arr, int key) {
int s = 0, e = arr.size() - 1;
while(s <= e)
{
if(arr[s] == key)
{
return s;
}
else{
s++;
}
if(arr[e] == key)
{
return e;
}
else{
e--;
}
}
return -1;
}
};7th July : C++ Solution☝🏼
————————————————————
🙋🏻♂️Discussion ⁉️
Join ✅ @GFG_Answer
class Solution {
public:
bool ancestor(vector<int>&ans,struct Node *root,int target){
if(root==NULL){
return false;
}
if(ancestor(ans,root->left,target)){
ans.push_back(root->data);
return true;
}
if(root->data==target){
return true;
}
if(ancestor(ans,root->right,target)){
ans.push_back(root->data);
return true;
}
return false;
}
// Function should return all the ancestor of the target node
vector<int> Ancestors(struct Node *root, int target) {
vector<int>ans;
ancestor(ans,root,target);
return ans;
}
};Repost from Free Courses | Udemy Paid Courses Mega Link
🧩 Abdul Bari All Courses
• Abdul Bari Udemy Course Link • Abdul Bari Mega Link • Abdul Bari DSA Course[Abdul Bari] 👩🏻💻 Learn C++ Programming -Beginner to Advance- Deep Dive in C++ ⚡ https://nanolinks.in/I9QlJ Decryption 🔑 -
sirM1wuw3_WFX0M-cKMKUw/folder/U2hBQa6I
—*—*—*—*—*—*—*—*—*—*—*—*—
[Abdul Bari]
⭐️ Learn Core JAVA Programming - Beginner to Master
⚡ https://nanolinks.in/yc4dn
Decryption 🔑 - sirM1wuw3_WFX0M-cKMKUw/folder/EvwjVYrZ
—*—*—*—*—*—*—*—*—*—*—*—*—
[Abdul Bari]
🤖 Mastering Data Structures and Algorithms using C and C++
⚡ https://nanolinks.in/cty89
Decryption 🔑 -
sirM1wuw3_WFX0M-cKMKUw/folder/4zhXlA6A
—*—*—*—*—*—*—*—*—*—*—*—*—
[Abdul Bari]
💻 Mastering Java SE programming from Beginner to Master
⚡ https://nanolinks.in/kfzMd
Decryption 🔑 - sirM1wuw3_WFX0M-cKMKUw/folder/Vq4TSIzB
—*—*—*—*—*—*—*—*—*—*—*—*—
Decryption Key 🔑 - Tap To Copy—*—*—*—*—*—*—*—*—*—*—*—*— ⚡️ Join For More - @nanocourse 🔥 @gfg_answer
6th July : C++ Solution☝🏼
————————————————————
🙋🏻♂️Discussion ⁉️
Join ✅ @GFG_Answer
class Solution {
public:
void inorder(Node* root, vector<Node*> &in)
{
if(!root)
{
return;
}
inorder(root->left, in);
in.push_back(root);
inorder(root->right, in);
}
void populateNext(Node *root) {
vector<Node*> in;
inorder(root, in);
for(int i = 0; i < in.size() - 1; i++)
{
in[i]->next = in[i+1];
}
root= in[0];
}
};5th July : C++ Solution☝🏼
————————————————————
🙋🏻♂️Discussion ⁉️
Join ✅ @GFG_Answer
