ar
Feedback
LeetCode, GeeksForGeeks Problem of the day solution

LeetCode, GeeksForGeeks Problem of the day solution

الذهاب إلى القناة على Telegram

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

إظهار المزيد
1 250
المشتركون
+224 ساعات
+147 أيام
+2930 أيام

جاري تحميل البيانات...

سحابة العلامات
لا توجد بيانات
هل تواجه مشاكل؟ يرجى تحديث الصفحة أو الاتصال بمدير الدعم الخاص بنا.
الإشارات الواردة والصادرة
---
---
---
---
---
---
جذب المشتركين
ديسمبر '24
ديسمبر '24
+27
في 0 قنوات
نوفمبر '24
+65
في 0 قنوات
Get PRO
أكتوبر '24
+47
في 0 قنوات
Get PRO
سبتمبر '24
+47
في 0 قنوات
Get PRO
أغسطس '24
+62
في 0 قنوات
Get PRO
يوليو '24
+58
في 0 قنوات
Get PRO
يونيو '24
+93
في 0 قنوات
Get PRO
مايو '24
+87
في 0 قنوات
Get PRO
أبريل '24
+79
في 0 قنوات
Get PRO
مارس '24
+56
في 0 قنوات
Get PRO
فبراير '24
+29
في 0 قنوات
Get PRO
يناير '24
+53
في 0 قنوات
Get PRO
ديسمبر '23
+797
في 0 قنوات
التاريخ
نمو المشتركين
الإشارات
القنوات
21 ديسمبر+5
20 ديسمبر0
19 ديسمبر+2
18 ديسمبر0
17 ديسمبر+2
16 ديسمبر0
15 ديسمبر+4
14 ديسمبر0
13 ديسمبر0
12 ديسمبر0
11 ديسمبر0
10 ديسمبر+2
09 ديسمبر0
08 ديسمبر+3
07 ديسمبر+1
06 ديسمبر+1
05 ديسمبر+1
04 ديسمبر0
03 ديسمبر0
02 ديسمبر+4
01 ديسمبر+2
منشورات القناة
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