fa
Feedback
GeeksForGeeks - POTD | GFG POTD Answer

GeeksForGeeks - POTD | GFG POTD Answer

کانال بسته

🚩 Channel was restricted by Telegram

نمایش بیشتر
1 218
مشترکین
اطلاعاتی وجود ندارد24 ساعت
-97 روز
-5730 روز
آرشیو پست ها
💸 Get RS 100 CASHBACK now‼️ Use it to pay bills on Groww, The EASIEST way to make UPI transactions and pay bills. ⚡Follow th
💸 Get RS 100 CASHBACK now‼️ Use it to pay bills on Groww, The EASIEST way to make UPI transactions and pay bills. ⚡Follow these steps : ➡️ Download the Groww App. ⭐ Set up your UPI account. 👉🏼 Enter my Referral code - ‼️⚡MY3XQU⚡‼️ ➡️In the refer section under the profile section. ‼️RECHARGE 1ST & GET REWARD‼️ 🎉Download Groww Now : https://app.groww.in/v3cO/3dtoa50w ⚡And use my code: MY3XQU

2nd October : C++ Solution ☝🏼 ————————————————————— 🙋🏻‍♂️Discussion ⁉️ Join ✅ @GFG_Answer ⚡Visit Once Daily To Get FREE Codedamn T-Shirt 👕 — https://codedamn.com/referred-by/4f24l

//User function template for C++ class Solution{ public: int distinctSubsequences(string s) { int n = s.size(); int dp[n + 1]; int mod = 1e9 + 7; dp[0] = 1; // Space : O(n) unordered_map mp; // Time : O(n) for(int i = 1;i <= n;i++){ dp[i] = (dp[i - 1] * 2) % mod; char c = s[i - 1]; if(mp.find(c) != mp.end()){ dp[i] = (dp[i] - dp[mp[c] - 1] + mod) % mod; } mp[c] = i; } return dp[n] % mod; } };

1st October : C++ Solution ☝🏼 ————————————————————— 🙋🏻‍♂️Discussion ⁉️ Join ✅ @GFG_Answer ⚡Visit Once Daily To Get Codedamn T-Shirt 👕 — https://codedamn.com/referred-by/4f24l

class Solution { public: //Function to return list of integers that form the boundary //traversal of the matrix in a clockwise manner. vector boundaryTraversal(vector > mat, int n, int m) { vectorans; for(int i=0;i=0;i--) ans.push_back(mat[n-1][i]); if(m!=1) for(int i=n-2;i>0;i--) ans.push_back(mat[i][0]); return ans; } };

30th September : C++ Solution ☝🏼 ————————————————————— 🙋🏻‍♂️Discussion ⁉️ Join ✅ @GFG_Answer ⚡Visit Once Daily To Get Codedamn T-Shirt 👕 — https://codedamn.com/referred-by/4f24l

class Solution { public: //Function to modify the matrix such that if a matrix cell matrix[i][j] //is 1 then all the cells in its ith row and jth column will become 1. void booleanMatrix(vector > &matrix) { int col_0 = 0, row = matrix.size(), col = matrix[0].size(); for(int i=0; i=0; i--) { for(int j=col-1; j>=1; j--) if(matrix[i][0] == 1 || matrix[0][j] == 1) matrix[i][j] = 1; if(col_0 == 1) matrix[i][0] = 1; } } };

29th September : C++ Solution ☝🏼 ————————————————————— 🙋🏻‍♂️Discussion ⁉️ Join ✅ @GFG_Answer ⚡Visit Once Daily To Get Codedamn T-Shirt 👕 — https://codedamn.com/referred-by/4f24l

// User function Template for C++ class Solution { private: void dfs(int row,int col,int delrow[],int delcol[], vector> &grid, vector> &vis){ vis[row][col]=1; int n=grid.size(); int m=grid[0].size(); for(int i=0; i<4; i++){ int drow = row + delrow[i]; int dcol = col + delcol[i]; if(drow>=0 && drow=0 && dcol> &grid) { // Code here int delrow[4] = {-1,0,1,0}; int delcol[4] = {0,1,0,-1}; int n=grid.size(); int m=grid[0].size(); vector>vis(n,vector(m,0)); for(int i=0; i

28th September : C++ Solution ☝🏼 ————————————————————— 🙋🏻‍♂️Discussion ⁉️ Join ✅ @GFG_Answer ⚡Visit Once Daily To Get Codedamn T-Shirt 👕 — https://codedamn.com/referred-by/4f24l

class Solution{ public: void convertToWave(int n, vector& arr){ for(int i=0;i

27th September : C++ Solution ☝🏼 ————————————————————— 🙋🏻‍♂️Discussion ⁉️ Join ✅ @GFG_Answer ⚡Visit Once Daily To Get Codedamn T-Shirt 👕 — https://codedamn.com/referred-by/4f24l

class Solution{ public: vector printClosest(int arr[], int brr[], int n, int m, int x) { int i=0; int j=m-1; int mini=INT_MAX; vectorans(2); while(i=0) { int sum=arr[i]+brr[j]; if(mini>abs(sum-x)) { mini=abs(sum-x); ans[0]=arr[i]; ans[1]=brr[j]; } if(sum<=x) i++; else j--; } return ans; } };

26th September : C++ Solution ☝🏼 ————————————————————— 🙋🏻‍♂️Discussion ⁉️ Join ✅ @GFG_Answer ⚡Visit Once Daily To Get Codedamn T-Shirt 👕 — https://codedamn.com/referred-by/4f24l

class Ksum{ private: vector> sums; void generateSums(int L,int R,int K,int T,vector &currElements,vector &nums){ if(K == 2){ while(L < R){ int currSum = nums[L] + nums[R]; if(currSum == T){ currElements.push_back(nums[L++]); currElements.push_back(nums[R--]); sums.push_back(currElements); currElements.pop_back(); currElements.pop_back(); while(L < R && nums[L] == nums[L-1]) L++; while(L < R && nums[R] == nums[R+1]) R--; } else if(currSum < T) L++; else R--; } return; } while(L < R){ currElements.push_back(nums[L]); generateSums(L+1,R,K-1,T-nums[L],currElements,nums); currElements.pop_back(); L++; while(L < R && nums[L] == nums[L-1]) L++; } } public: vector> findSums(vector nums,int k,int target){ sums.resize(0); sort(nums.begin(),nums.end()); vector currElements; generateSums(0,nums.size()-1,k,target,currElements,nums); return sums; } }; class Solution{ public: vector > fourSum(vector &nums, int target){ Ksum ksumFinder; return ksumFinder.findSums(nums,4,target); } };

25th September : C++ Solution ☝🏼 ————————————————————— 🙋🏻‍♂️Discussion ⁉️ Join ✅ @GFG_Answer ⚡Visit Once Daily To Get Codedamn T-Shirt 👕 — https://codedamn.com/referred-by/4f24l

class Solution { public: vector<int> maxCombinations(int N, int K, vector<int> &A, vector<int> &B) { sort(A.begin(),A.end()); sort(B.begin(),B.end()); vector<int> ans; priority_queue<pair<int,pair<int,int>>> pq; for(int i=0;i<N;i++) { pq.push({A[i]+B[N-1],{i,N-1}}); } while(!pq.empty() && K--) { pair<int,pair<int,int>> tp = pq.top(); int vl = tp.first; int x = tp.second.first, y = tp.second.second; pq.pop(); ans.push_back(vl); if(y != 0) pq.push({A[x]+B[y-1],{x, y-1}}); } return ans; } };

Get FREE Codedamn T-Shirt 👕 ⚡How To Get This ❓ 1. Open The Link - https://codedamn.com/referred-by/4f24l 2. Login And Verify
Get FREE Codedamn T-Shirt 👕 ⚡How To Get This ❓ 1. Open The Link - https://codedamn.com/referred-by/4f24l 2. Login And Verify Mobile Number. 3. Refer Your 7 Friends. 4. Unlock T-Shirt 👕 And It's Yours 😍 ⭐ Go CLAIM Nowww ⭐ #VerifiedReferral ⚡Verified referrals are your friends who have verified their account with a phone number and are actively using the platform.

24th September : C++ Solution ☝🏼 ————————————————————— 🙋🏻‍♂️Discussion ⁉️ Join ✅ @GFG_Answer ⚡Subscribe To - YouTube.com/@PhoneTuber_

class Solution{ public: vector duplicates(int arr[], int n) { map mp; int count = 0 ; vectorvec ; for(int i = 0 ; i < n ;i++){ mp[arr[i]]++; } for(auto it:mp){ if(it.second >= 2){ vec.push_back(it.first); count++; } } if(count == 0 ){ return {-1}; } return vec; } };