es
Feedback
LeetCode, GeeksForGeeks Problem of the day solution

LeetCode, GeeksForGeeks Problem of the day solution

Ir al canal en Telegram

Complete daily challenges from LeetCode, GeeksForGeeks and redeem their rewards Channel link : https://t.me/leetcode_gfg_potd

Mostrar más
1 250
Suscriptores
+224 horas
+147 días
+2930 días

Carga de datos en curso...

Nube de Etiquetas
Sin datos
¿Algún problema? Por favor, actualice la página o contacte a nuestro gerente de soporte.
Menciones Entrantes y Salientes
---
---
---
---
---
---
Atraer Suscriptores
diciembre '24
diciembre '24
+27
en 0 canales
noviembre '24
+65
en 0 canales
Get PRO
octubre '24
+47
en 0 canales
Get PRO
septiembre '24
+47
en 0 canales
Get PRO
agosto '24
+62
en 0 canales
Get PRO
julio '24
+58
en 0 canales
Get PRO
junio '24
+93
en 0 canales
Get PRO
mayo '24
+87
en 0 canales
Get PRO
abril '24
+79
en 0 canales
Get PRO
marzo '24
+56
en 0 canales
Get PRO
febrero '24
+29
en 0 canales
Get PRO
enero '24
+53
en 0 canales
Get PRO
diciembre '23
+797
en 0 canales
Fecha
Crecimiento de Suscriptores
Menciones
Canales
21 diciembre+5
20 diciembre0
19 diciembre+2
18 diciembre0
17 diciembre+2
16 diciembre0
15 diciembre+4
14 diciembre0
13 diciembre0
12 diciembre0
11 diciembre0
10 diciembre+2
09 diciembre0
08 diciembre+3
07 diciembre+1
06 diciembre+1
05 diciembre+1
04 diciembre0
03 diciembre0
02 diciembre+4
01 diciembre+2
Publicaciones del Canal
class Solution { public: vector> spiralMatrixIII(int rows, int cols, int rStart, int cStart) { int m = rows; int n = cols; vector> ans; vector> vis(m+n, vector(m+n, 0)); int x = rStart; int y = cStart; int k = 1; while(ans.size()=0 && j>=0 && x=0 && y>=0 && i=y-k; j--){ if(x>=0 && j>=0 && x=x-k; i--){ if(i>=0 && y>=0 && i

2
LeetCode | Daily challenge :
521
3
class Solution { public: int f(Node* root){ if(root==NULL){ return 0; } if(root->left==NULL && root->right==NULL){ return root->data; } int val=f(root->left)+f(root->right); if(val==root->data){ return 2*val; } return -1; } bool isSumTree(Node* root) { if(root==NULL){ return true; } return f(root)==-1?false:true; } };
488
4
GFG | Problem of the day :
421
5
class Solution { public: string numberToWords(int n) { long long int limit = 1000000000000, curr , t = 0; if(n==0) return "Zero"; string multiplier[]={"","Trillion","Billion","Million","Thousand"}; string first20[]={"","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"}; string tens[] = {"","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"}; if(n<20){ return first20[n]; } string ans = ""; for(long long int i = n;i>0;i%=limit, limit /= 1000){ curr = i/limit; while(curr == 0){ i %= limit; limit /= 1000; curr = i/limit; ++t; } if(curr>99){ ans += (first20[curr/100] + " Hundred "); } curr = curr%100; if(curr>0 && curr<20){ ans += (first20[curr] + " "); } else if(curr%10==0 && curr!=0){ ans += (tens[curr/10-1] + " "); } else if(curr>20 && curr<100){ ans += (tens[curr/10-1] + " " + first20[curr%10] + " "); } if(t<4){ ans += (multiplier[++t] + " "); } } int l = ans.length(); return ans.substr(0,l-1); } };
398
6
LeetCode | Daily challenge :
251
7
class Solution { public: int kthElement(int k, vector<int>& arr1, vector<int>& arr2) { size_t m=arr1.size(); size_t n=arr2.size(); int i=0,j=0; int c=0; while (i<m && j<n){ if (arr1[i]<arr2[j]){ if ((c)==k-1) return arr1[i]; c++; i++; } else { if ((c)==k-1) return arr2[j]; c++; j++; } } //chk left out arrays while (i<m){ if ((c)==k-1) return arr1[i]; c++; i++; } while (j<n){ if ((c)==k-1) return arr2[j]; c++; j++; } } };
250
8
GFG | Problem of the day :
195
9
class Solution { public: int minimumPushes(string word) { int c[123] = { 0 }; for (unsigned int i = 0, len = word.length(); i < len; ++i) ++c[word[i]]; bool sorted = false; do { sorted = true; for (unsigned short i = 97; i < 122; ++i) if (c[i] < c[i + 1]) { int temp = c[i]; c[i] = c[i + 1]; c[i + 1] = temp; sorted = false; } } while (!sorted); int steps = 0, count = 0; for (unsigned short i = 97; i < 123; ++i) if (c[i] != 0) { steps += c[i] * (count / 8 + 1); ++count; } return steps; } };
227
10
LeetCode | Daily challenge :
171
11
class Solution { public: int isValid(string str) { int dot = 0; string temp = ""; for(int i = 0 ; i < str.length() ; i++){ if(str[i] == '.'){ dot++; if(temp.empty()) return false; else if(temp.size() > 1 && temp[0] == '0') return false; int num = stoi(temp); if(num < 0 || num > 256) return false; temp = ""; } else temp += str[i]; } if(temp.empty()) return false; else if(temp.size() > 1 && temp[0] == '0') return false; int num = stoi(temp); if(num < 0 || num > 256) return false; return dot == 3 ? true : false; } };
188
12
GFG | Problem of the day :
161
13
class Solution { public: string kthDistinct(vector<string>& arr, int k) { unordered_map<string,int> mp; string ans=""; for(int i=0;i<arr.size();i++){ mp[arr[i]]++; } for(int i=0;i<arr.size();i++){ if(mp[arr[i]]<2){ k--; } if(k<=0){ ans+=arr[i]; break; } } return ans; } };
192
14
LeetCode | Daily challenge :
150
15
class Solution { public: vector <int> bottomView(Node *root) { vector<int> res; if(root==NULL){ return res; } map<int, int> mp; queue<pair<Node* , int>> q; q.push({root, 0}); while(!q.empty()){ auto temp = q.front(); q.pop(); Node* node = temp.first; int vLine = temp.second; mp[vLine] = node->data; if(node->left){ q.push({node->left, vLine-1}); } if(node->right){ q.push({node->right, vLine+1}); } } for(auto i:mp){ res.push_back(i.second); } return res; } };
240
16
GFG | Problem of the day :
219
17
class Solution { public: int rangeSum(vector<int>& nums, int n, int left, int right) { vector<int> sub; long long MOD = 1e9 + 7; for (int i = 0; i < n; i++) { int sum = 0; for (int j = i; j < n; j++) { sum += nums[j]; sub.push_back(sum); } } sort(sub.begin(), sub.end()); long long totalSum = 0; for (int i = left - 1; i < right; i++) { totalSum = (totalSum + sub[i]) % MOD; } return totalSum; } };
286
18
LeetCode | Daily challenge :
186
19
class Solution { public: static bool compare(pair<int,int>&a,pair<int,int>&b){ if(a.second==b.second) return a.first<b.first; return a.second<b.second; } int maxMeetings(int n, int start[], int end[]) { vector<pair<int,int>>vec; for(int i=0;i<n;i++) vec.push_back({start[i],end[i]}); sort(vec.begin(),vec.end(),compare); int ans=1; int prev=0; for(int i=1;i<n;i++){ if(vec[i].first>vec[prev].second){ prev=i; ans++; } } return ans; } };
210
20
GFG | Problem of the day :
208