- Видео 48
- Просмотров 2 404
Uday Sharma
Индия
Добавлен 30 дек 2023
Kadane's Algorithm | GFG POTD | 24-11-24 | MEDIUM | GFG Problem of the day | GFG 160 Challenge
✅ Geeks for Geeks Problem of the Day (POTD) in C++ | Kadane's Algorithm
| Array | Algorithm | Why its called Kadane's Algorithm? | Easy☺️ and Complete Explained🧠
✅ GFG 160 Challenge
🎯 Companies that Asked about this Problem: Zoho Flipkart Morgan Stanley Accolite Amazon Microsoft Samsung Snapdeal 24*7 Innovation Labs Citrix D-E-Shaw FactSet Hike Housing.com MetLife Ola Cabs Oracle Payu Teradata Visa Walmart Adobe Google Arcesium
#amazon #meta #flipkart #adobe #microsoft #qualcomm #goldmansachs
#geeksforgeeks #problemoftheday #cpp #datastructures #potd #potdgfgtoday #gfg #gfgsolutions #gfgstreek #cpp #python #javascript #java #javaprogramming #datastructures #algorithm #algorithms #pythonprog...
| Array | Algorithm | Why its called Kadane's Algorithm? | Easy☺️ and Complete Explained🧠
✅ GFG 160 Challenge
🎯 Companies that Asked about this Problem: Zoho Flipkart Morgan Stanley Accolite Amazon Microsoft Samsung Snapdeal 24*7 Innovation Labs Citrix D-E-Shaw FactSet Hike Housing.com MetLife Ola Cabs Oracle Payu Teradata Visa Walmart Adobe Google Arcesium
#amazon #meta #flipkart #adobe #microsoft #qualcomm #goldmansachs
#geeksforgeeks #problemoftheday #cpp #datastructures #potd #potdgfgtoday #gfg #gfgsolutions #gfgstreek #cpp #python #javascript #java #javaprogramming #datastructures #algorithm #algorithms #pythonprog...
Просмотров: 6
Видео
Stock Buy and Sell - Max one Transaction Allowed | GFG POTD | 22-11-24 | Easy | GFG 160 Challenge
Просмотров 284 часа назад
✅ Geeks for Geeks Problem of the Day (POTD) | GFG Problem of the Day in C | Stock Buy and Sell - Max one Transaction Allowed | Greedy | Array | Data Structure | Easy☺️ and Complete Explained🧠 ✅ GFG 160 Challenge 🎯 Companies that Asked about this Problem: Bloomberg Facebook Intel Infosys Zoho Morgan Stanley Amazon Microsoft Samsung Yahoo PayPal Nvidia Oracle Visa Walmart Goldman Sachs TCS Adobe ...
Stock Buy and Sell | GFG POTD | 21-11-24 | Hard | GFG Problem of the day | GFG 160 Challenge
Просмотров 237 часов назад
✅ Geeks for Geeks Problem of the Day (POTD) in C | Stock Buy and Sell - Multiple Transaction Allowed | Array, Data Structures | Easy☺️ and Complete Explained🧠 ✅ GFG 160 Challenge 🎯 Companies that Asked this Problem: Paytm, Flipkart, Morgan Stanley, Accolite, Amazon, Microsoft, Samsung, D-E-Shaw, Hike, MakeMyTrip, Ola, Cabs, Oracle, Walmart, Goldman Sachs, Directi, Intuit, SAP Labs, Quikr, Faceb...
Majority Element II | GFG POTD | 20-11-24 | MEDIUM | GFG Problem of the day | GFG 160 Challenge
Просмотров 1889 часов назад
✅ Geeks for Geeks Problem of the Day (POTD) in C | Majority Element II | Hashmap| Easy☺️ and Complete Explained🧠 ✅ GFG 160 Challenge 🎯 Companies that Asked this Problem: Amazon Microsoft MAQ Software #amazon #meta #flipkart #adobe #microsoft #qualcomm #goldmansachs #geeksforgeeks #problemoftheday #cpp #datastructures #potd #potdgfgtoday #gfg #gfgsolutions #gfgstreek #cpp #python #javascript #ja...
Free GeeksForGeeks Bag🎒 | GfG 160 - 160 Days of Problem Solving Challenge🎯 | How to get it?🤔
Просмотров 4059 часов назад
✅GfG 160 - 160 Days of Problem Solving ✅Free GeeksforGeeks Bag🎒 🎯How to get it? Easy☺️ and Complete Explained🧠 ✅ Geeks for Geeks Problem of the Day (POTD) #amazon #meta #flipkart #microsoft # #geeksforgeeks #problemoftheday #cpp #datastructures #potd #potdgfgtoday #gfg #gfgsolutions #gfgstreek #cpp #python #javascript #java #javaprogramming #datastructures #algorithm #algorithms #pythonprogramm...
Rotate Array | GFG POTD | 18-11-24 | MEDIUM | GFG Problem of the day | GFG 160 Challenge | Amzon
Просмотров 4514 часов назад
✅ Geeks for Geeks Problem of the Day (POTD) in C | Rotate Array | Array | Easy☺️ and Complete Explained🧠 Without Extra Space Complexity 🎯 Companies that Asked this Problem: Amazon Microsoft MAQ Software #amazon #meta #flipkart #adobe #microsoft #qualcomm #goldmansachs #geeksforgeeks #problemoftheday #cpp #datastructures #potd #potdgfgtoday #gfg #gfgsolutions #gfgstreek #cpp #python #javascript ...
Reverse an Array | GFG POTD | 17-11-24 | Easy | GFG Problem of the day | GFG 160 Challenge | Array
Просмотров 4216 часов назад
✅ Geeks for Geeks Problem of the Day (POTD) in C | Reverse an Array | Array | Easy☺️ and Complete Explained🧠 Without Extra Space Complexity 🎯 Companies that Asked This Problem were Bloomberg, Facebook, TCS, Adobe, Google, Infosys, Capgemini, Morgan Stanley, Amazon, Microsoft, Apple, Yahoo, PayPal, and Uber. #amazon #meta #flipkart #adobe #microsoft #qualcomm #goldmansachs #geeksforgeeks #proble...
Intersection Point in Y Shaped Linked Lists | GFG POTD | 13-11-24 | Medium | GFG Problem of the day
Просмотров 15День назад
✅ Geeks for Geeks Problem of the Day (POTD) in C | Intersection Point in Y Shaped Linked Lists | LinkedList | Easy☺️ and Complete Explained🧠 Without Extra Space Complexity 🎯 Companies Asked This Problem : VMWare | Flipkart | Accolite | Amazon | Microsoft | Snapdeal | D-E-Shaw | FactSet | MakeMyTrip | Visa | Goldman Sachs | MAQ Software | Adobe | Qualcomm #amazon #meta #flipkart #adobe #microsof...
Meeting Rooms | GFG POTD | 12-11-24 | Medium | GFG Problem of the day | Greedy | Sorting
Просмотров 24День назад
✅ Geeks for Geeks Problem of the Day (POTD) in C | Meeting Rooms | Array | Easy☺️ and Complete Explained🧠 Without Extra Space Complexity 🎯 Companies Asked This Problem : #geeksforgeeks #problemoftheday #cpp #datastructures #potd #potdgfgtoday #gfg #gfgsolutions #gfgstreek #cpp #python #javascript #java #javaprogramming #datastructures #algorithm #algorithms #pythonprogramming #coding #programmi...
Union of Two Sorted Arrays with Distinct Elements | GFG POTD | 10-11-24 | Easy | Array
Просмотров 2414 дней назад
✅ Geeks for Geeks Problem of the Day (POTD) in C | Union of Two Sorted Arrays with Distinct Elements | Array | Easy☺️ and Complete Explained🧠 4 Lines of Code 🎯 Companies Asked This Problem : #geeksforgeeks #problemoftheday #cpp #datastructures #potd #potdgfgtoday #gfg #gfgsolutions #gfgstreek #cpp #python #javascript #java #javaprogramming #datastructures #algorithm #algorithms #pythonprogrammi...
Minimum sum | GFG POTD | 9-11-24 | Medium Level | GFG Problem of the day | Sorting String | Google
Просмотров 2814 дней назад
✅ Geeks for Geeks Problem of the Day (POTD) in C | Minimum sum | String | Sorting | Easy☺️ and Fully Explained🧠 🎯 Companies Asked This Problem : Google #geeksforgeeks #problemoftheday #cpp #datastructures #potd #potdgfgtoday #gfg #gfgsolutions #gfgstreek #cpp #python #javascript #java #javaprogramming #datastructures #algorithm #algorithms #pythonprogramming #coding #programming #problemsolving...
Rotate by 90 degree | GFG POTD | 5-11-24 | Medium Level | GFG Problem of the day | Matrix
Просмотров 4014 дней назад
✅ Geeks for Geeks Problem of the Day (POTD) in C | Rotate by 90 degree | Matrix | 3 Lines of Code | Easy☺️ and Fully Explained🧠 🎯 Companies Asked This Problem : Paytm | Zoho | Morgan Stanley | Amazon | Microsoft | Samsung | Snapdeal | D-E-Shaw #geeksforgeeks #problemoftheday #cpp #datastructures #potd #potdgfgtoday #gfg #gfgsolutions #gfgstreek #cpp #python #javascript #java #javaprogramming #d...
Find All Triplets with Zero Sum | GFG POTD | 4-11-24 | Easy Level | GFG Problem of the day | Hash
Просмотров 9914 дней назад
Geeks for Geeks Problem of the Day (POTD) in C | Find All Triplets with Zero Sum| Hashmap | 2 Approaches | Easy☺️ and Fully Explained🧠 #geeksforgeeks #problemoftheday #cpp #datastructures #potd #potdgfgtoday #gfg #gfgsolutions #gfgstreek #cpp #python #javascript #java #javaprogramming #datastructures #algorithm #algorithms #pythonprogramming #coding #programming #problemsolving #problemsolved #...
Is Linked List Length Even? | GFG POTD | 3-11-24 | Basic Level | GFG Problem of the day |
Просмотров 6814 дней назад
Is Linked List Length Even? | GFG POTD | 3-11-24 | Basic Level | GFG Problem of the day |
Kth distance | GFG POTD | 2-11-24 | Easy Level | GFG Problem of the day | 4 Lines of Code | Amazon
Просмотров 6921 день назад
Kth distance | GFG POTD | 2-11-24 | Easy Level | GFG Problem of the day | 4 Lines of Code | Amazon
Swap and Maximize | GFG POTD | 1-11-24 | Easy Level | GFG Problem of the day | 3 Lines of Code
Просмотров 3421 день назад
Swap and Maximize | GFG POTD | 1-11-24 | Easy Level | GFG Problem of the day | 3 Lines of Code
Insert in Sorted way in a Sorted DLL | Medium Level | GFG POTD | 31-10-24 | GFG Problem of the day
Просмотров 6221 день назад
Insert in Sorted way in a Sorted DLL | Medium Level | GFG POTD | 31-10-24 | GFG Problem of the day
Pairs with difference k | EASY | GFG POTD | 30-10-24 | GFG Problem of the day | Adobe | 2 Approaches
Просмотров 3821 день назад
Pairs with difference k | EASY | GFG POTD | 30-10-24 | GFG Problem of the day | Adobe | 2 Approaches
1 Lakhs+ Internships opportunity in 2024| PM internship Scheme | How to Apply | Eligibility Criteria
Просмотров 3821 день назад
1 Lakhs Internships opportunity in 2024| PM internship Scheme | How to Apply | Eligibility Criteria
Remove duplicates in array | EASY | GFG POTD | 26-10-24 | GFG Problem of the day | GeeksforGeeks |
Просмотров 1621 день назад
Remove duplicates in array | EASY | GFG POTD | 26-10-24 | GFG Problem of the day | GeeksforGeeks |
Triplet Family👪 | Basic problem | GFG POTD | 27-10-24 | GFG Problem of the day | Easy Explanation |
Просмотров 1928 дней назад
Triplet Family👪 | Basic problem | GFG POTD | 27-10-24 | GFG Problem of the day | Easy Explanation |
Occurrence of an integer in a Linked List | EASY | GFG POTD | 26-10-24 | GFG Problem of the day
Просмотров 5328 дней назад
Occurrence of an integer in a Linked List | EASY | GFG POTD | 26-10-24 | GFG Problem of the day
Alternative Sorting | GFG POTD | 25-10-24 | Basic | GFG Problem of the day | Sorting |
Просмотров 3328 дней назад
Alternative Sorting | GFG POTD | 25-10-24 | Basic | GFG Problem of the day | Sorting |
Modify the Array | Easy | GFG POTD | 24-10-24 | 2 Approaches | GFG Problem of the day |
Просмотров 40Месяц назад
Modify the Array | Easy | GFG POTD | 24-10-24 | 2 Approaches | GFG Problem of the day |
Find the Sum of Last N nodes of the Linked List | EASY | GFG POTD | 23-10-24| GFG Problem of the day
Просмотров 38Месяц назад
Find the Sum of Last N nodes of the Linked List | EASY | GFG POTD | 23-10-24| GFG Problem of the day
Sub-arrays with equal number of occurrences | HARD💀| GFG POTD | 22-10-24 | GFG Problem of the day
Просмотров 259Месяц назад
Sub-arrays with equal number of occurrences | HARD💀| GFG POTD | 22-10-24 | GFG Problem of the day
Split the Array | GFG POTD | 21-10-24 | Easy | GFG Problem of the day | Bitwise XOR |
Просмотров 82Месяц назад
Split the Array | GFG POTD | 21-10-24 | Easy | GFG Problem of the day | Bitwise XOR |
Sort a k sorted doubly linked list | GFG POTD | 20-10-24 | Easy | GFG Problem of the day | Min Heap
Просмотров 113Месяц назад
Sort a k sorted doubly linked list | GFG POTD | 20-10-24 | Easy | GFG Problem of the day | Min Heap
Nearest multiple of 10 | GFG POTD | 19-10-24 | Easy | GFG Problem of the day | C++ | Java | python
Просмотров 91Месяц назад
Nearest multiple of 10 | GFG POTD | 19-10-24 | Easy | GFG Problem of the day | C | Java | python
Single Number | GFG POTD | 18-10-24 | Easy | 3 ways | GFG Problem of the day | C++ | Java | python
Просмотров 56Месяц назад
Single Number | GFG POTD | 18-10-24 | Easy | 3 ways | GFG Problem of the day | C | Java | python
Code GitHub Link: github.com/UdaySharmaGitHub/GFG-160-Challenge.git
class Solution { public: // Function to find the sum of contiguous subarray with maximum sum. int maxSubarraySum(vector<int> &arr) { // code here... // Time Complexity O(n) | Space Complexity: O(1); int res = INT_MIN , max_so_far = 0; for(int i=0;i<arr.size();i++){ max_so_far += arr[i]; if(res < max_so_far) res = max_so_far; if(max_so_far < 0) max_so_far = 0; // kadane's } return res; } };
bhai maina aj se 24 nov se start kiya ky ma starting question kr skta or sarre question 1 din me kr skta 24 tak ke question ya muza per day one question krna padega ?
Previous question sare karlo and ajj se GFG 160 streak maintain karna means ajj ka question ajj hi karna hai or usko social media pe post karne hai ase hi 80 days ki streak maintain karni hai apko
or woman k liya compulsory bag ha but iska kya matlab agar humne complte kiya humko bag nehi milaga kya
vi maine aj start kiya ha ,to mereko sirf day 1 ka Second Largest wala problem hi sollve karna padega kya?or day 2 ka kal ,aise karke 160 din tak?
Apko minimum 80 days consecutive streak maintains karni hai, apko GFG 160 challenge ke problem jo current day per ayi hai apko use din solve karke social media pe post karna hai ase hi apko Jo GFG 160 challenge ki problem aa rahi hai vo solve karni hai
Hey, I just had a confusion. Please help me out, Actually jab me 160 days ke actual panel se question solve karta hu jaisa aapne video me bataya hai to wo POTD Streak me count nahi ho raha, udhar streak 0 hi show ho rahi hai. So mujhe POTD Streak ko hi 80 tak lana hoga means Bag claim karne keliye right? PS: actually I enrolled in this course just 3 days before, that's why this problem is happening. I think mujhe directly wahi karne hai jo POTD me specific day keliye listed hai?
Apko previous problem jo 160 challenge me hai vo solve kar leni hai and apko fir regular current day ki POTD solve karni hai and apko ase hi 80 days ki POTD consecutive streak maintain karni hai aur unke solution social media pe post karne hai.
Code Link (GitHub): github.com/UdaySharmaGitHub/GFG-160-Challenge/blob/main/Arrays/Day8_Stock_Buy_and_Sell_Max_one_Transaction_Allowed.cpp
Let's crack it.
SUBSCRIBE
class Solution { public: int maximumProfit(vector<int> &prices) { // code here // Accumate Profit // Time Complexity O(n) | Space Complexity O(1); int maxProfit = 0 ; for(int i=1;i<prices.size();i++){ if(prices[i] > prices[i-1]) maxProfit += prices[i] - prices[i-1]; } return maxProfit; } };
GitHub Link: github.com/UdaySharmaGitHub/GFG-160-Challenge.git
there is no such Repository Named GFG-160-Challenge in your Github.
Here it is:- github.com/UdaySharmaGitHub/GFG-160-Challenge.git
class Solution { public: // Function to find the majority elements in the array vector<int> findMajority(vector<int>& arr) { // Your code goes here. unordered_map<int,int> map; int n = arr.size() /3; for(int i:arr) map[i]++; arr.clear(); for(auto i:map) if(i.second > n ) arr.push_back(i.first); if(arr.size() == 2 && arr[0] > arr[1]) swap(arr[0],arr[1]); return arr; } };
✨✨Apply Link🔗: www.geeksforgeeks.org/courses/gfg-160-series
We have to solve just one problem a day or we have to complete the whole 5 given questions in 1 day(like i registered today itself and its showing 5 problems in array)? And what if the given questions is already solved before the start of challenge, will we still eligible?
You can start any time between 15th to 30th nov , And then you have to start doing the problem of the day of the current day And you have to maintain at least 80 consecutive days of POTD streak, and post the image of the solved POTD with the mentioned hashtags and tag the GFG on the social media(like x or LinkedIn) that you're posting. You can start solving from today's POTD and maintain at least 80 consecutive days streak
@@codewithuday I have 1 more doubt if I have started on 19th November then what about the remaining 5 questions? of 15,16,17 and 18, uss din ke questions kb karne h and post bhi karne h kya uss din ke bhi? And maine jb 19 ko start kiya tha tb maine 15th nov ka question solve kar liya tha 19th nov ka nhi kiya....so will i still be eligible for the challenge? Please reply
No it's not eligible, agar app 19th November se start kar te ho toh apko 19 ya uske agle din ki regular POTD karni hogi and apko use din POTD day solve karni and post karna hai , aur ase hi apko 80 days ki regular POTD streak maintain karni hai. Let us suppose app 23 nov se start karte ho toh apko 23 nov ki POTD se start karna hai and Roz POTD karni hogi from 23 nov and maintain the regular 80 POTD streak
@@codewithuday ok so maine 19 ko 15th nov ka question kar liya tha but fir 20th nov se 20th nov wala he potd kiya tha...chalega na? Registered on - 19th nov did wrong potd But from 20th nov doing all correct questions
Works but make sure apko 160 days GFG Wale page per hi Jake problem solve karni hai
Impressive... Bro.. Thanks.. Fr sharing
Most welcome 🤗 Glad you like it 😊
SUBSCRIBE
class Solution { public: // Function to rotate an array by d elements in counter-clockwise direction. void rotateArr(vector<int>& arr, int d) { // code here // reverse(arr_starting_postion , arrr_ending_postion); d%=arr.size(); // faltu rotate operation unhe avoid kar sake reverse(arr.begin(),arr.begin()+d); reverse(arr.begin()+d,arr.end()); reverse(arr.begin(),arr.end()); } };
class Solution { public: void reverseArray(vector<int> &arr) { // code here int i = 0 , j = arr.size() -1; while(i<j) swap(arr[i++],arr[j--]); } };
class Solution { public: // Function to find intersection point in Y shaped Linked Lists. // length function int getLen(Node* head){ int len = 0 ; while(head){ len++; head= head->next;} return len; } // head1 -> longest , head2 =smallest; int getIntersectionPoint(int diff,Node* head1,Node* head2){ for(int i = 0 ;i<diff;i++){ head1 = head1->next; } while(head1 && head2){ if(head1 == head2) return head1->data; head1= head1->next; head2= head2->next; } return -1; } int intersectPoint(Node* head1, Node* head2) { // O(m+n) | O(1) int n1 = getLen(head1) ; int n2 = getLen(head2); int diff =0; if(n1 > n2){ diff = n1 - n2; return getIntersectionPoint(diff,head1,head2); } diff = n2 - n1; return getIntersectionPoint(diff,head2,head1); } };
class Solution { public: // Function to find intersection point in Y shaped Linked Lists. int intersectPoint(Node* head1, Node* head2) { // Your Code Here // 2nd Approach // O(m+n) | O(m+n) unordered_map<Node*,bool> map; while(head1){ map[head1] = 1; head1 = head1->next; } while(head2){ if(map[head2]) return head2->data; head2 = head2->next; } return -1; } };
Nice 👍 explanation
Glad you like it ☺️
Good going Uday!!
Thank you 😊
class Solution { public: bool canAttend(vector<vector<int>> &arr) { // Your Code Here int count = 1; int st = arr[0][0] , en = arr[0][1]; for(int i=1;i<arr.size();i++){ if(st <= arr[i][0] && en <= arr[i][0]) count++; st = arr[i][0] ,en = arr[i][1]; } return count == arr.size(); } };
bhaiya time complexity O(nlog(n)) nahi hogi? kyon ki insertion in set is O(log(N)) he to??
Thanks for correcting time complexity is O(m+n *log(m+n)). But the space complexity is O(m+n). If you want to solve this in O(m+n) you can use the merge sort approach
class Solution { public: // a,b : the arrays // Function to return a list containing the union of the two arrays. vector<int> findUnion(vector<int> &a, vector<int> &b) { // Your code here // return vector with correct order of elements set<int> set; // storing for(int i:a) set.insert(i); // O(m) for(int i:b) set.insert(i); // o(n) a.clear(); for(auto i:set) a.push_back(i); // O(n+m) return a; } };
// User function template for C++ class Solution { public: string addString(string s1,string s2){ int i = s1.size()-1 ,j= s2.size()-1; string ans = ""; int carry = 0; while(i>=0 || j>=0 || carry){ int a = 0 , b = 0 ; if(i>=0) a = s1[i]-'0'; if(j>=0) b = s2[j]-'0'; int sum = a+b+carry; int digit = sum%10; carry =sum/10; if(sum) ans.push_back('0'+digit); i--;j--; } reverse(ans.begin(),ans.end()); return ans; } string minSum(vector<int> &arr) { // code here sort(arr.begin(),arr.end()); string s1 = "" ,s2 =""; for(int i =0;i<arr.size();i++){ if(i&1) s2.push_back('0'+arr[i]); else s1.push_back('0'+arr[i]); } return addString(s1,s2); } };
Nice... Explaination
Glad you like it 😊
Nice explanation
Glad you like it 😊
void rotate(vector<vector<int> >& mat) { // Your code goes here // Reverse -> Transpose reverse(mat.begin(),mat.end()); // reverse // Transpose for(int i=0;i<mat.size()-1;i++){ for(int j = i+1;j<mat.size();j++) swap(mat[i][j],mat[j][i]); } }
Nice explanation bro, keep it up. Will you see again tomorrow with next gfg daily challenge problem.
Glad you like it ☺️, Sure bro 😊😊
// User function Template for C++ class Solution { public: vector<vector<int>> findTriplets(vector<int> &arr) { // Code here unordered_map<int,vector<int>> map; vector<vector<int>> res ; for(int i=0;i<arr.size();i++) map[arr[i]].push_back(i); for(int j=1;j<arr.size()-1;j++){ for(int k=j+1;k<arr.size();k++){ int sum = -1*(arr[j] +arr[k]); for(int i:map[sum]){ if(i<j) res.push_back({i,j,k}); } } } return res; } };
class Solution { public: bool isLengthEven(struct Node **head) { // Code here int count = 0 ; while(*head){ count++; (*head) = (*head)->next; } return !(count&1); // return count%2==0; } };
class Solution { public: bool checkDuplicatesWithinK(vector<int>& arr, int k) { // your code unordered_map<int,int> map; map[0] = -1; // best practice for(int i=0;i<arr.size();i++){ // main condition if(map.find(arr[i]) != map.end()){ // duplicate value within the k distance if(i - map[arr[i]] <= k) return 1; } // updating the old index value with new Value map[arr[i]] = i; // insert value } return 0; } };
class Solution { public: long long maxSum(vector<int>& arr) { // code here sort(arr.begin(),arr.end()); int n = arr.size(); long long int diff = 0; for(int i =0;i<n/2;i++){ // Main Iteration // Array Circular hai tabhi multiple 2 // L -> R || R -> L diff += (2*(arr[n-1-i] - arr[i])); } return diff; } };
Best concepts 🎉❤❤❤❤
Glad you like it 😊✨😊
class Solution { public: Node* sortedInsert(Node* head, int x) { // Code here Node* curr = head,* nxt = head->next; Node* node = getNode(x); if(!head->next){ if(head->data <x){ head->next = node; node->prev = head; return head; } node->next= head; head ->prev = node; return node; } if(head->data> x){ node->next = head; head -> prev = node; head = node; return head; } while(x>nxt->data && nxt){ curr = nxt; nxt = nxt->next; if(!nxt) break; } if(!nxt){ curr->next = node; node->prev = curr; return head; } curr->next = node; node->prev = curr; node->next= nxt; nxt -> prev = node; return head; } };
Age 20 years and engineering ke 7th sem me hu to kya apply kar sakta hu?
Age ka criteria 21 se 24 ka hai , may app 8th sem ya uske baad apply kar sakte ho , according to your Date of birth in government ID
Bsc cs walo ke liye kuch hai kya? Cs Mai?
Sab ke liye hai jo under graduate course me enroll jese Bsc , bca , btech etc... or every field or domain ke students apply kar sakte hai
// 3rd Approach class Solution { public: vector<int> removeDuplicate(vector<int>& arr) { // code here unordered_set<int> set; vector<int> ans; for(int i:arr){ if(set.find(i) == set.end()){ ans.push_back(i); } set.insert(i); } return ans; } };
// 2nd Approach class Solution { public: vector<int> removeDuplicate(vector<int>& arr) { // code here unordered_map<int,bool> map; vector<int> ans; for(int i:arr){ if(map[i] ==0){ ans.push_back(i); map[i] = 1; } } return ans; } };
// 1 Approach class Solution { public: vector<int> removeDuplicate(vector<int>& arr) { // code here // Freq stored vector<int> freq(101,0); vector<int> ans; for(int i=0;i<arr.size();i++){ if( freq[arr[i]] == 0){ ans.push_back(arr[i]); freq[arr[i]] = 1; } } return ans; } };
// Triplet Family Similar to 3 Sum or Triplets Sum in the Array class Solution { public: bool findTriplet(vector<int>& arr) { // Your code sort(arr.begin(),arr.end()); // O(n*log(n)) // O(n^2) for(int i = arr.size()-1;i>=0 ;i--){ int j = 0, k = i-1; while(j<k){ int sum = arr[j] + arr[k]; if(sum==arr[i]) return 1; else if(sum > arr[i]) k--; else if(sum <arr[i]) j++; } } return 0; } };
Very good bhai Keep going 🎉👏🏼👏🏼👏🏼
// Using Set class Solution { public: int count(struct Node* head, int key) { // add your code here set<int> set; int count = 0 ; while(head){ if(set.find(key) != set.end()){ count++; set.erase(key); } set.insert(head->data); head = head->next; } if(set.find(key) != set.end()){ count++; set.erase(key); } return count ; } };
// Using HaspMap or HashTable class Solution { public: int count(struct Node* head, int key) { // add your code here map<int,int> map; while(head){ map[head->data]++; head = head->next; } return map[key]; } };
// Using Counting class Solution { public: int count(struct Node* head, int key) { // add your code here int count = 0; while(head){ if(head->data == key )count++; head = head->next; } return count; } };
class Solution { public: vector<int> alternateSort(vector<int>& arr) { // Your code goes here sort(arr.begin(),arr.end()); int n = arr.size(),k=0; vector<int> ans(n,0); for(int i =0 ;i<n;i++){ if(i&1) ans[i] = arr[k++]; else ans[i] = arr[n-k-1]; } return ans; } };
// Every Possible modification for this type of question class Solution { public: vector<int> modifyAndRearrangeArray(vector<int> &arr) { // Complete the function vector<int> ans(arr.size(),0); for(int i = 0 ; i<arr.size()-1;i++){ if(arr[i] != 0 && arr[i+1]!=0){ if(arr[i] == arr[i+1]){ ans[i] = arr[i]*2; arr[i+1] = 0;} else{ ans[i] = arr[i] ; ans[i+1] = arr[i+1]; } } else if(arr[i] == 0 && arr[i+1] != 0){ ans[i+1] = arr[i+1]; } else if(arr[i] != 0 && arr[i+1] == 0){ ans[i] = arr[i] ; ans[i+1] = arr[i+1]; } arr[i] = 0; } arr[arr.size()-1]= 0; int j = 0 ; for(int i:ans) if(i>0) arr[j++] = i; return arr; } };
class Solution { public: vector<int> modifyAndRearrangeArray(vector<int> &arr) { // Complete the function vector<int> ans; for(int i=0;i<arr.size();i++){ if(arr[i] == arr[i+1]){ arr[i]*=2; arr[i+1] = 0; i++; } } for(int i =0;i<arr.size();i++){ if(arr[i]) ans.push_back(arr[i]); } for(int i =0;i<arr.size();i++){ if(arr[i] == 0) ans.push_back(arr[i]); } return ans; } };