- Видео 51
- Просмотров 2 826
Om Verma
Добавлен 20 июл 2024
Non-overlapping Intervals | Sorting | GFG POTD | Dry Run & Explanation
Guyz If you Like the Content
Plz Consider:
-Subscribing the Channel
-Like the video
-Comment your review
0:00 Introduction
0:07 Problem Statement
0:32 Explanation
2:32 Approach
3:20 Dry Run
7:44 Code
#sorting
#gfgpotd
#leetcodepotd
#algorithm
#graph
#datastructure
#topologicalsort
#directedgraph
#graphalgorithm
#sortalgorithm
#dfs
#kahnalgorithm
#programming
#coding
#competitiveprogramming
#codinginterview
#interviewprep
#graphtraversal
#cp
#dsa
#GraphAlgorithms
#GraphTheory
#Algorithms
#GFGPOTD (GeeksForGeeks Problem of the Day)
#LeetCodePOTD (LeetCode Problem of the Day)
#CompetitiveProgramming
#DataStructures
#SortingAlgorithms
#DFS (Depth First Search)
#KahnsAlgorithm
#CodingChallenge
#Programming
#InterviewPrep
#TechInterview
Plz Consider:
-Subscribing the Channel
-Like the video
-Comment your review
0:00 Introduction
0:07 Problem Statement
0:32 Explanation
2:32 Approach
3:20 Dry Run
7:44 Code
#sorting
#gfgpotd
#leetcodepotd
#algorithm
#graph
#datastructure
#topologicalsort
#directedgraph
#graphalgorithm
#sortalgorithm
#dfs
#kahnalgorithm
#programming
#coding
#competitiveprogramming
#codinginterview
#interviewprep
#graphtraversal
#cp
#dsa
#GraphAlgorithms
#GraphTheory
#Algorithms
#GFGPOTD (GeeksForGeeks Problem of the Day)
#LeetCodePOTD (LeetCode Problem of the Day)
#CompetitiveProgramming
#DataStructures
#SortingAlgorithms
#DFS (Depth First Search)
#KahnsAlgorithm
#CodingChallenge
#Programming
#InterviewPrep
#TechInterview
Просмотров: 72
Видео
Santa Banta | Graph | Sieve of Eratosthenes| GFG Practice | Dry Run & Explanation
Просмотров 3621 день назад
Guyz If you Like the Content Plz Consider: -Subscribing the Channel -Like the video -Comment your review 0:00 Introdunction 0:37 Problem Explanation 4:58 Max No. of Girls (Part 1) 9:47 Sieve of Eratosthenes (Part 2) 13:25 Code #graph #sieveOfEratosthenes #gfgalgorithms #gfgpotd #algorithm #graph #datastructure #topologicalsort #directedgraph #graphalgorithm #sortalgorithm #dfs #kahnalgorithm #p...
2.Fundamentals (Part-1) | Javascript | Basics to Advance
Просмотров 97Месяц назад
Guyz If you Like the Content Plz Consider: -Subscribing the Channel -Like the video -Comment your review 0:00 Introduction 0:34 Link Js With HTML 4:12 Comments 4:42 Strict Mode 7:57 Variables 15:09 Hoisting 18:53 Variables Rivision 25:56 Interaction with User #JavaScript #LearnJavaScript #javascripttutorial #hoisting #alert #prompt #confirmation #JavaScriptTips #CodingWithJavaScript #JavaScript...
1.Introduction | Javascript | Basics To Advance
Просмотров 35Месяц назад
Guyz If you Like the Content Plz Consider: -Subscribing the Channel -Like the video -Comment your review #JavaScript #LearnJavaScript #JavaScriptTutorial #JavaScriptTips #CodingWithJavaScript #JavaScriptForBeginners #JavaScriptProgramming #WebDevelopment #FrontendDevelopment #BackendDevelopment #FullStackDevelopment #CodingTutorial #WebDesign #JavaScriptES6 #AsyncAwait #JavaScriptDebugging #Jav...
Rotate Array | Array | GFG POTD | Dry Run & Explanation
Просмотров 15Месяц назад
Guyz If you Like the Content Plz Consider: -Subscribing the Channel -Like the video -Comment your review #sorting #Array #gfgpotd #gfgalgorithms #gfgpotdtoday #Tree #BST #gfgpotd #leetcodepotd #algorithm #graph #datastructure #topologicalsort #directedgraph #graphalgorithm #sortalgorithm #dfs #kahnalgorithm #programming #coding #competitiveprogramming #codinginterview #interviewprep #graphtrave...
Quick Sort on Linked List | Sorting | GFG POTD | Dry Run & Explanation
Просмотров 732 месяца назад
Guyz If you Like the Content Plz Consider: -Subscribing the Channel -Like the video -Comment your review #sorting #linkedlist #gfgpotd #gfgalgorithms #gfgpotdtoday #Tree #BST #gfgpotd #leetcodepotd #algorithm #graph #datastructure #topologicalsort #directedgraph #graphalgorithm #sortalgorithm #dfs #kahnalgorithm #programming #coding #competitiveprogramming #codinginterview #interviewprep #graph...
Sub-arrays with equal number of occurences | Hashmap | GFG POTD | Dry Run & Explanation
Просмотров 592 месяца назад
Guyz If you Like the Content Plz Consider: -Subscribing the Channel -Like the video -Comment your review #hashmap #array #gfgpotd #gfgalgorithms #gfgpotdtoday #Tree #BST #gfgpotd #leetcodepotd #algorithm #graph #datastructure #topologicalsort #directedgraph #graphalgorithm #sortalgorithm #dfs #kahnalgorithm #programming #coding #competitiveprogramming #codinginterview #interviewprep #graphtrave...
Subarray range with given sum | HashMap | GFG POTD | Dry Run & Explanation
Просмотров 812 месяца назад
Guyz If you Like the Content Plz Consider: -Subscribing the Channel -Like the video -Comment your review #hashmap #array #gfgpotd #gfgalgorithms #gfgpotdtoday #Tree #BST #gfgpotd #leetcodepotd #algorithm #graph #datastructure #topologicalsort #directedgraph #graphalgorithm #sortalgorithm #dfs #kahnalgorithm #programming #coding #competitiveprogramming #codinginterview #interviewprep #graphtrave...
Majority Vote | Boyer-Moore's Majority Voting Algorithm | GFG POTD | Dry Run & Explanation
Просмотров 1113 месяца назад
Guyz If you Like the Content Plz Consider: -Subscribing the Channel -Like the video -Comment your review #array #gfgpotd #gfgalgorithms #gfgpotdtoday #Tree #BST #gfgpotd #leetcodepotd #algorithm #graph #datastructure #topologicalsort #directedgraph #graphalgorithm #sortalgorithm #dfs #kahnalgorithm #programming #coding #competitiveprogramming #codinginterview #interviewprep #graphtraversal #cp ...
Rotate and delete | Array | GFG POTD | Dry Run & Explanation
Просмотров 633 месяца назад
Guyz If you Like the Content Plz Consider: -Subscribing the Channel -Like the video -Comment your review #Array #gfgpotd #algorithm #leetcodepotd #graph #datastructure #topologicalsort #directedgraph #graphalgorithm #sortalgorithm #dfs #kahnalgorithm #programming #coding #competitiveprogramming #codinginterview #interviewprep #graphtraversal #cp #dsa #GraphAlgorithms #GraphTheory #Algorithms #G...
Bipartite Graph | Graph | GFG PRACTICE | Dry Run & Explanation
Просмотров 363 месяца назад
Guyz If you Like the Content Plz Consider: -Subscribing the Channel -Like the video -Comment your review #graph #gfgpotd #leetcodepotd #algorithm #graph #datastructure #topologicalsort #directedgraph #graphalgorithm #sortalgorithm #dfs #kahnalgorithm #programming #coding #competitiveprogramming #codinginterview #interviewprep #graphtraversal #cp #dsa #GraphAlgorithms #GraphTheory #Algorithms #G...
Merge two BST 's | Binary Search Tree | GFG POTD | Dry Run & Explanation
Просмотров 2263 месяца назад
Guyz If you Like the Content Plz Consider: -Subscribing the Channel -Like the video -Comment your review #Tree #BST #gfgpotd #leetcodepotd #algorithm #graph #datastructure #topologicalsort #directedgraph #graphalgorithm #sortalgorithm #dfs #kahnalgorithm #programming #coding #competitiveprogramming #codinginterview #interviewprep #graphtraversal #cp #dsa #GraphAlgorithms #GraphTheory #Algorithm...
Minimal Cost | Recursion | Dynamic Programing | GFG POTD | Dry Run & Explanation
Просмотров 563 месяца назад
Guyz If you Like the Content Plz Consider: -Subscribing the Channel -Like the video -Comment your review #Recursion #DP #gfgpotd #leetcodepotd #algorithm #graph #datastructure #topologicalsort #directedgraph #graphalgorithm #sortalgorithm #dfs #kahnalgorithm #programming #coding #competitiveprogramming #codinginterview #interviewprep #graphtraversal #cp #dsa #GraphAlgorithms #GraphTheory #Algor...
Palindrome Linked List | Linked List | GFG POTD | Dry Run & Explanation
Просмотров 293 месяца назад
Guyz If you Like the Content Plz Consider: -Subscribing the Channel -Like the video -Comment your review #Linkedlist #gfgpotd #leetcodepotd #algorithm #graph #datastructure #topologicalsort #directedgraph #graphalgorithm #sortalgorithm #dfs #kahnalgorithm #programming #coding #competitiveprogramming #codinginterview #interviewprep #graphtraversal #cp #dsa #GraphAlgorithms #GraphTheory #Algorith...
Smallest window in a string containing all the characters of another string | GFG POTD | Dry Run
Просмотров 583 месяца назад
Guyz If you Like the Content Plz Consider: -Subscribing the Channel -Like the video -Comment your review #slidingwindows #gfgpotd #leetcodepotd #algorithm #graph #datastructure #topologicalsort #directedgraph #graphalgorithm #sortalgorithm #dfs #kahnalgorithm #programming #coding #competitiveprogramming #codinginterview #interviewprep #graphtraversal #cp #dsa #GraphAlgorithms #GraphTheory #Algo...
Missing And Repeating | Arrays | GFG POTD | Dry Run & Explanation
Просмотров 783 месяца назад
Missing And Repeating | Arrays | GFG POTD | Dry Run & Explanation
Longest Prefix Suffix | String Matching(KMP) | GFG POTD | Dry Run & Explanation
Просмотров 673 месяца назад
Longest Prefix Suffix | String Matching(KMP) | GFG POTD | Dry Run & Explanation
Clone a linked list with next and random pointer | Linked List | GFG POTD | Dry Run & Explanation
Просмотров 713 месяца назад
Clone a linked list with next and random pointer | Linked List | GFG POTD | Dry Run & Explanation
Facing the sun | Array | GFG POTD | Dry Run & Explanation
Просмотров 303 месяца назад
Facing the sun | Array | GFG POTD | Dry Run & Explanation
Reverse Words | Strings | GFG POTD | Dry Run & Explanation
Просмотров 243 месяца назад
Reverse Words | Strings | GFG POTD | Dry Run & Explanation
Parenthesis Checker | Stack | GFG POTD | Dry Run & Explanation
Просмотров 243 месяца назад
Parenthesis Checker | Stack | GFG POTD | Dry Run & Explanation
Minimize the Heights II | Greedy | GFG POTD | Dry Run & Explanation
Просмотров 1123 месяца назад
Minimize the Heights II | Greedy | GFG POTD | Dry Run & Explanation
Longest valid Parentheses | Stack | GFG POTD | Dry Run & Explanation
Просмотров 1283 месяца назад
Longest valid Parentheses | Stack | GFG POTD | Dry Run & Explanation
Binary Tree to DLL(Doubly Linked List) | Binary Tree | GFG POTD | Dry Run & Explanation
Просмотров 623 месяца назад
Binary Tree to DLL(Doubly Linked List) | Binary Tree | GFG POTD | Dry Run & Explanation
Topological sort | Kahn's Algorithm(BFS) | Graph | GFG Practice | Dry Run & Explanation
Просмотров 123 месяца назад
Topological sort | Kahn's Algorithm(BFS) | Graph | GFG Practice | Dry Run & Explanation
Alternate positive and negative numbers | Arrays | GFG POTD | Dry Run & Explained
Просмотров 343 месяца назад
Alternate positive and negative numbers | Arrays | GFG POTD | Dry Run & Explained
Mirror Tree | Tree | GFG POTD | Dry Run & Explanation
Просмотров 603 месяца назад
Mirror Tree | Tree | GFG POTD | Dry Run & Explanation
Middle of a Linked List | Linked List | GFG POTD | Dry Run & Explanation
Просмотров 533 месяца назад
Middle of a Linked List | Linked List | GFG POTD | Dry Run & Explanation
Minimum Cost of ropes | Queue | Heap | GFG POTD | Dry Run & Explanation
Просмотров 693 месяца назад
Minimum Cost of ropes | Queue | Heap | GFG POTD | Dry Run & Explanation
Circle of strings | Graph | Eulerian Cycle | GFG POTD | Dry Run & Explanation
Просмотров 1333 месяца назад
Circle of strings | Graph | Eulerian Cycle | GFG POTD | Dry Run & Explanation
If you Like the content the plzz Subscribe 😄. CODE: class Solution { public: int minRemoval(vector<vector<int>> &intervals) { sort(intervals.begin(),intervals.end(),[](vector<int>& a,vector<int>& b){ return a[1] < b[1]; }); int count = 0; int last = intervals[0][1]; for(int i=1;i<intervals.size();i++){ if(last > intervals[i][0]){ count++; } else{ last = intervals[i][1]; } } return count; } };
CODE: class Solution{ public: vector<int> prime; void precompute(){ //Sieve Of Eratosthenes vector<int> isPrime(1e6+10,true); isPrime[0] = false; isPrime[1] = false; for(int i=2;i<1e6+10;i++){ if(isPrime[i] == true){ prime.push_back(i); for(int j=i*2;j<1e6+10;j+=i){ isPrime[j] = false; } } } } void dfs(int u,int& count,unordered_map<int,vector<int>>& adj,vector<int>& visited){ visited[u] = true; count++; for(auto v: adj[u]){ if(!visited[v]){ dfs(v,count,adj,visited); } } } int helpSanta(int n, int m, vector<vector<int>> &g){ unordered_map<int,vector<int>> adj; for(int i=0;i<g.size();i++){ int u = g[i][0]; int v = g[i][1]; adj[u].push_back(v); adj[v].push_back(u); } vector<int> visited(n+1,0); int candidate = 1; for(int i=1;i<=n;i++){ if(!visited[i]){ int count = 0; dfs(i,count,adj,visited); candidate = max(candidate,count); } } if(candidate == 1){ return -1; } return prime[candidate-1]; } };
If You Like the Video then Plzz Consider Subscribing ☺. CODE: class Solution { public: void reversal(vector<int>& arr,int start,int end){ while(start <= end){ swap(arr[start++],arr[end--]); } } void rotateArr(vector<int>& arr, int d) { d = d%arr.size(); reversal(arr,0,d-1); reversal(arr,d,arr.size()-1); reversal(arr,0,arr.size()-1); } };
If You Like the Video then Plzz Consider Subscribing ☺. CODE: class Solution { public: struct Node* findTail(struct Node* head){ struct Node* tail = head; while(head != NULL){ tail = head; head = head->next; } return tail; } struct Node* partition(struct Node* head,struct Node* tail){ struct Node* pivot = head; struct Node* pre = head; struct Node* curr = head; while(curr != tail->next){ if(curr->data < pivot->data){ swap(pre->next->data,curr->data); pre = pre->next; } curr = curr->next; } swap(pivot->data,pre->data); return pre; } void quickSortOG(struct Node* head,struct Node* tail){ if(head == NULL || head == tail){ return; } struct Node* pivot = partition(head,tail); quickSortOG(head,pivot); quickSortOG(pivot->next,tail); } struct Node* quickSort(struct Node* head) { struct Node* tail = findTail(head); quickSortOG(head,tail); return head; } };
Nice explanation!
Glad you liked it .😊
If You Like the Video then Plzz Consider Subscribing ☺. CODE: class Solution { public: int sameOccurrence(vector<int>& arr, int x, int y) { vector<int> count_x(arr.size()); vector<int> count_y(arr.size()); vector<int> diff(arr.size()); count_x[0] = (arr[0] == x) ? 1 : 0; count_y[0] = (arr[0] == y) ? 1 : 0; diff[0] = count_x[0]-count_y[0]; for(int i=1;i<arr.size();i++){ if(arr[i] == x){ count_x[i] = 1 + count_x[i-1]; } else{ count_x[i] = count_x[i-1]; } if(arr[i] == y){ count_y[i] = 1 + count_y[i-1]; } else{ count_y[i] = count_y[i-1]; } diff[i] = count_x[i]-count_y[i]; } unordered_map<int,int> mp; for(int i=0;i<diff.size();i++){ mp[diff[i]]++; } long long ans = mp[0]; for(auto it: mp){ long long freq = it.second; ans = ans + (freq*(freq-1))/2LL; } return ans; } };
keep it up bro......inshallah you will get 100 million subscribers one day
So glad it was helpful ☺️
Tq ur video is very helpful
So nice of you 😊
If You Like the Video then Plzz Consider Subscribing ☺. CODE: class Solution { public: int subArraySum(vector<int>& arr, int tar) { int sum = 0; int count = 0; unordered_map<int,int> mp; for(int i=0;i<arr.size();i++){ sum += arr[i]; if(sum == tar){ count++; } if(mp.find(sum-tar) != mp.end()){ count += mp[sum-tar]; } mp[sum]++; } return count; } };
If You Like the Video then Plzz Consider Subscribing ☺. CODE: class Solution { public: vector<int> findMajority(vector<int>& nums) { int count1 = 0,count2 = 0; int major1 = nums[0],major2 = nums[0]; int n = nums.size(); for(int i=0;i<nums.size();i++){ if(major1 == nums[i]){ count1++; } else if(major2 == nums[i]){ count2++; } else if(count1 == 0){ major1 = nums[i]; count1 = 1; } else if(count2 == 0){ major2 = nums[i]; count2 = 1; } else{ count1--; count2--; } } vector<int> ans; int freq1 = 0,freq2 = 0; for(int i=0;i<nums.size();i++){ if(nums[i] == major1){ freq1++; } else if(nums[i] == major2){ freq2++; } } if(freq1 > n/3){ ans.push_back(major1); } if(freq2 > n/3){ ans.push_back(major2); } if(ans.size() == 0){ return {-1}; } return ans; } };
Thank you brother
Clear explaining 🤩
Glad you liked it 😊.
@@Veom03 😊
If You Like the Video then Plzz Consider Subscribing ☺. CODE: class Solution { public: int rotateDelete(vector<int> &arr) { int k = 1; while(arr.size() > 1){ arr.insert(arr.begin(),arr[arr.size()-1]); arr.pop_back(); int remove_ind = arr.size()-k; if(remove_ind < 0){ remove_ind = 0; } arr.erase(arr.begin()+remove_ind); k++; } return arr[0]; } };
If You Like the Video then Plzz Consider Subscribing ☺. CODE: class Solution { public: bool solve(int u,vector<int> adj[],vector<int>& color,int curr){ color[u] = curr; for(auto v: adj[u]){ if(color[v] == color[u]){ return false; } if(color[v] == -1){ int new_color = 1-curr; if(solve(v,adj,color,new_color) == false){ return false; } } } return true; } bool isBipartite(int V, vector<int>adj[]){ vector<int> color(V,-1); for(int i=0;i<V;i++){ if(color[i] == -1){ if(solve(i,adj,color,0) == false){ return false; } } } return true; } };
Nice explanation
Glad you liked it 😊.
If You Like the Video then Plzz Consider Subscribing ☺. CODE: class Solution { public: void store_left(Node* root,stack<Node*>& st){ Node* curr = root; while(curr != NULL){ st.push(curr); curr = curr->left; } } vector<int> merge(Node *root1, Node *root2) { stack<Node*> st1,st2; vector<int> ans; store_left(root1,st1); store_left(root2,st2); while(!st1.empty() && !st2.empty()){ if(st1.top()->data < st2.top()->data){ Node* curr = st1.top(); st1.pop(); ans.push_back(curr->data); store_left(curr->right,st1); } else if(st2.top()->data < st1.top()->data){ Node* curr = st2.top(); st2.pop(); ans.push_back(curr->data); store_left(curr->right,st2); } else{ Node* curr1 = st1.top(); Node* curr2 = st2.top(); st1.pop(); st2.pop(); ans.push_back(curr1->data); ans.push_back(curr2->data); store_left(curr1->right,st1); store_left(curr2->right,st2); } } while(!st1.empty()){ Node* curr1 = st1.top(); st1.pop(); ans.push_back(curr1->data); store_left(curr1->right,st1); } while(!st2.empty()){ Node* curr2 = st2.top(); st2.pop(); ans.push_back(curr2->data); store_left(curr2->right,st2); } return ans; } };
Your explanation made everything so clear!
Glad it was helpful 😊.
If you Like the video then plzz consider Subscribing ☺. CODE: class Solution { public: int solve(int ind,int k,vector<int>& arr,vector<int>& dp){ if(ind == arr.size()-1){ return 0; } if(dp[ind] != -1){ return dp[ind]; } int ans = INT_MAX; for(int i=1;i<=k;i++){ if(ind+i < arr.size()){ int temp = abs(arr[ind]-arr[ind+i]) + solve(ind+i,k,arr,dp); ans = min(ans,temp); } } return dp[ind] = ans; } int minimizeCost(int k, vector<int>& arr) { vector<int> dp(arr.size()+1,-1); return solve(0,k,arr,dp); } };
If you Like the video then plzz consider Subscribing ☺. CODE: class Solution { public: int count(Node* head){ int temp = 0; while(head != NULL){ head = head->next; temp++; } return temp; } bool isPalindrome(Node *head) { string first,second; int size = count(head); int temp = size/2; Node* a = head; while(temp--){ first += ('0'+a->data); a = a->next; } if(size&1){ a = a->next; } temp = size/2; while(temp--){ second += ('0'+a->data); a = a->next; } reverse(second.begin(),second.end()); return first == second; } };
If you Like the Video then Plzz consider Subscribing .☺ CODE: class Solution{ public: string smallestWindow (string s, string p){ if(p.length()>s.length()){ return "-1"; } unordered_map<char,bool> mp; int p_hash[26] = {0}; for(int i=0;i<p.size();i++){ p_hash[p[i]-'a']++; mp[p[i]] = true; } int count=mp.size(); int startindex=-1; int length=0; int minlength=INT_MAX; int i = 0,j = 0; while(j < s.size()){ if(mp[s[j]] == true){ p_hash[s[j]-'a']--; if(p_hash[s[j]-'a'] == 0){ count--; } } while(count == 0){ length = j-i+1; if(length < minlength){ startindex = i; minlength = length; } if(mp[s[i]] == true){ p_hash[s[i]-'a']++; if(p_hash[s[i]-'a'] > 0){ count++; } } i++; } j++; } if(startindex == -1) return "-1"; else return s.substr(startindex,minlength); } };
If you Like the Video then Plzz consider Subscribing ☺. CODE: class Solution { public: vector<int> findTwoElement(vector<int>& arr) { int miss,rep; for(int i=0;i<arr.size();i++){ int tar = abs(arr[i])-1; if(arr[tar] < 0){ rep = abs(arr[i]); } else{ arr[tar] = -arr[tar]; } } //Missing for(int i=0;i<arr.size();i++){ if(arr[i] > 0){ miss = i+1; break; } } return {rep,miss}; } };
If You Like the Video then Plzz Consider Subscribing ☺. CODE: class Solution { public: int lps(string str) { vector<int> LPS(str.size(),0); int length = 0; LPS[0] = 0; for(int i=1;i<str.size();){ if(str[i] == str[length]){ length++; LPS[i] = length; i++; } else{ if(length != 0){ length = LPS[length-1]; } else{ LPS[i] = 0; i++; } } } return LPS[str.size()-1]; } };
If You Like the video plzz consider Subscribing ☺. CODE: class Solution{ public: void Insert_tail(Node* &head,Node* &tail,int data){ Node* newNode = new Node(data); if(head == NULL){ head = newNode; tail = newNode; return; } tail->next = newNode; tail = newNode; } Node *copyList(Node *head){ Node* Clone_head = NULL; Node* Clone_tail = NULL; Node* temp = head; while(temp != NULL){ Insert_tail(Clone_head,Clone_tail,temp->data); temp = temp->next; } unordered_map<Node*,Node*> OldToNew; Node* Original = head; Node* Clone = Clone_head; while(Original != NULL && Clone != NULL){ OldToNew[Original] = Clone; Clone = Clone->next; Original = Original->next; } Original = head; Clone = Clone_head; while(Original != NULL){ Clone->random = OldToNew[Original->random]; Original = Original->next; Clone = Clone->next; } return Clone_head; } };
If you Like the video the plzz Consider Subscribing ☺. CODE: class Solution { public: string reverseWords(string str) { string ans = ""; for(int i=str.size()-1;i>=0;){ string temp = ""; while(i >= 0 && str[i] != '.'){ temp += str[i]; i--; } reverse(temp.begin(),temp.end()); ans += temp; ans += str[i--]; } ans.pop_back(); return ans; } };
If you Like the video the plzz Consider Subscribing ☺. CODE: class Solution{ public: bool ispar(string x){ stack<char> st; unordered_map<char,char> mp; mp[')'] = '('; mp['}'] = '{'; mp[']'] = '['; for(int i=0;i<x.size();i++){ if(x[i] == '(' || x[i] == '{' || x[i] == '['){ st.push(x[i]); } else{ if(st.size() == 0){ return false; } else if(st.top() == mp[x[i]]){ st.pop(); } else{ return false; } } } if(st.size() > 0){ return false; } return true; } };
If you Like the video the plzz Consider Subscribing 😁. CODE: class Solution { public: int getMinDiff(vector<int> &arr, int k) { int n = arr.size(); sort(arr.begin(),arr.end()); int diff=arr[n-1]-arr[0]; int maxi,mini; for(int i=1;i<n;i++){ if(arr[i]-k<0)continue; maxi=max(arr[i-1]+k,arr[n-1]-k); mini=min(arr[0]+k,arr[i]-k); diff=min(diff,maxi-mini); } return diff; } };
great explanation
Glad it was helpful! 😊
If you Like the video the plzz Consider Subscribing ☺. CODE- class Solution{ public: int maxLength(string S){ stack<int> st; st.push(-1); int maxi = 0; for(int i=0;i<S.size();i++){ if(S[i] == '('){ st.push(i); } else{ st.pop(); if(st.empty()){ st.push(i); } else{ int len = i-st.top(); maxi = max(maxi,len); } } } return maxi; } };
If You Like the Video then Plzz Consider Subscribing ☺. CODE class Solution{ public: void Convert_DDL(Node* root,Node* &head,Node* &prev,int &count){ if(root == NULL){ return; } Convert_DDL(root->left,head,prev,count); if(count == 0){ count++; head = root; prev = root; } else{ root->left = prev; prev->right = root; prev = root; } Convert_DDL(root->right,head,prev,count); } Node * bToDLL(Node *root){ Node* prev = NULL; Node* head = NULL; int count = 0; Convert_DDL(root,head,prev,count); return head; } };
If You Like the Video then Plzz Consider Subscribing ☺. CODE class Solution{ public: vector<int> topoSort(int V, vector<int> adj[]) { //Using BFS vector<int> inDegree(V,0); for(int u=0;u<V;u++){ for(auto v: adj[u]){ inDegree[v]++; } } queue<int> que; vector<int> ans; for(int i=0;i<inDegree.size();i++){ if(inDegree[i] == 0){ que.push(i); ans.push_back(i); } } while(!que.empty()){ int node = que.front(); que.pop(); for(auto v: adj[node]){ inDegree[v]--; if(inDegree[v] == 0){ ans.push_back(v); que.push(v); } } } return ans; } };
If You Like the Video then Plzz Consider Subscribing ☺. CODE- class Solution { public: long long minCost(vector<long long>& arr) { priority_queue<long long,vector<long long>,greater<long long>> pq; for(int i=0;i<arr.size();i++){ pq.push(arr[i]); } long long sum = 0; while(pq.size() > 1){ long long first = pq.top(); pq.pop(); long long second = pq.top(); pq.pop(); sum += first+second; pq.push(first+second); } return sum; } };
If You Like the Video then Plzz Consider Subscribing ☺. class Solution { public: void DFS(char u,unordered_map<char,vector<char>>& adj,unordered_map<int,bool>& visited){ visited[u] = true; for(auto v: adj[u]){ if(visited[v] == false){ DFS(v,adj,visited); } } } int isCircle(vector<string> &arr) { unordered_map<char,vector<char>> adj; for(int i=0;i<arr.size();i++){ int u = arr[i][0]; int v = arr[i][arr[i].size()-1]; adj[u].push_back(v); adj[v].push_back(u); } int count = 0; unordered_map<int,bool> visited; for(int i=0;i<arr.size();i++){ if(visited[arr[i][0]] == false){ DFS(arr[i][0],adj,visited); count++; } } int odd = 0; for(auto i: adj){ if(adj[i.first].size()&1){ odd++; } } if(count > 1 || odd != 0){ return 0; } return 1; } };
can u please give the code of the solution in description or comments .
class Solution { public: void sort012(vector<int>& arr) { int l = 0,m = 0; int h = arr.size()-1; while(m <= h){ if(arr[m] == 0){ swap(arr[l],arr[m]); l++; m++; } else if(arr[m] == 1){ m++; } else{ swap(arr[m],arr[h]); h--; } } } };
Keep it Up bro 👍Your teaching Skill's is good
Thanks bro..😊 It really motivates me alot
Nice explanation. Keep doing bro.
@@tejaswaniguttula5961 Thanks Bro 😊