Gale Praveen
Gale Praveen
  • Видео 16
  • Просмотров 1 506
Alternative Sorting | GFG POTD | Detailed Explanation(Different from others!!) | Arrays | C++
Hi guys,
Today I have solved gfg POTD, I have mentioned the code in comment box. Thanks for watching.
0:00 - Introduction
1:30 - Array Indexing
3:15 - Creating a Max Variable
5:00 - Encoding Process
7:45 - Compression Techniques
10:30 - Retrieving Values
13:00 - Final Implementation Steps
15:30 - Complexity Analysis
17:00 - Conclusion
#coding​​ #helpajobseeker​​ #easyrecipes​​
#coding​​ #helpajobseeker​​ #easyrecipes​​ #leetcode​​ #leetcodequestionandanswers​​ #leetcodesolution​​ #leetcodedailychallenge​​ #leetcodequestions​​ #leetcodechallenge​​ #hindi​​ #india​​ #hindiexplanation​​ #hindiexplained​​ #easyexplaination​​ #interview​​ #interviewtips​​ #interviewpreparation​​ #interview_ds_algo​​ #hin...
Просмотров: 30

Видео

Modify the Array | GFG POTD | Arrays | C++Modify the Array | GFG POTD | Arrays | C++
Modify the Array | GFG POTD | Arrays | C++
Просмотров 60День назад
Hi guys, Today I have solved gfg POTD, I have mentioned the code in comment box. Thanks for watching. 0:00 - Introduction 0:02 - Overview of the problem 0:10 - Problem description 0:28 - Explanation of valid and invalid numbers 1:30 - Example walkthrough 2:20 - Observations during the process 4:28 - Step 1 completion 5:39 - Step 2 explanation 6:59 - Valid pointer and zero count variable discuss...
Find the Sum of Last N nodes of the Linked List | GFG POTD | Linked Lists | C++Find the Sum of Last N nodes of the Linked List | GFG POTD | Linked Lists | C++
Find the Sum of Last N nodes of the Linked List | GFG POTD | Linked Lists | C++
Просмотров 722 дня назад
Hi guys, Today I have solved gfg POTD, I have mentioned the code in comment box. Thanks for watching. 0:00 - Introduction 0:05 - Problem Title: Find the Sum of Last N Nodes of the List 0:11 - Problem Description 0:30 - Explanation of the Problem 1:10 - Analyzing the Problem 2:09 - Mathematical Approach 3:19 - Length Calculation 3:36 - Using the Length in Sum Calculation 4:41 - Finding the Remai...
Sub-arrays with equal number of occurrences | GFG POTD | Hash Maps | C++Sub-arrays with equal number of occurrences | GFG POTD | Hash Maps | C++
Sub-arrays with equal number of occurrences | GFG POTD | Hash Maps | C++
Просмотров 3493 дня назад
Hi guys, Today I have solved gfg POTD, I have mentioned the code in comment box. Thanks for watching. 0:00 - 0:10: Introduction and welcome to the channel. 0:10 - 0:30: Overview of the problem of the day: counting subarrays with equal occurrences. 0:30 - 1:00: Explanation of the problem statement with an example. 1:00 - 2:00: Discussion of brute force approach and its limitations. 2:00 - 3:00: ...
Split the Array | GFG POTD | Bit Manipulation | C++Split the Array | GFG POTD | Bit Manipulation | C++
Split the Array | GFG POTD | Bit Manipulation | C++
Просмотров 2174 дня назад
Hi guys, Today I have solved GFG POTD. I have mentioned the code in comment box. Thanks for watching. 0:00 - 1:00: Introduce the problem. 1:00 - 3:00: Describe with examples. 3:00 - 5:00: Discuss XOR properties. 5:00 - 7:00: Outline solution steps. 7:00 - 8:00: Show code and final thoughts. #dsa #datastructures #algorithm #gfg #potd #coding #array #strings #tree #binarysearchtree #codekarlo #dy...
Sort a k sorted doubly linked list | GFG POTD | Min Heap | C++Sort a k sorted doubly linked list | GFG POTD | Min Heap | C++
Sort a k sorted doubly linked list | GFG POTD | Min Heap | C++
Просмотров 1645 дней назад
Hi guys, Today I have solved GFG POTD. I have mentioned the code in comment box. Thanks for watching. Problem Understanding: You need to sort a doubly linked list where each node can only be k positions away from its original position. Brute Force Approach: For each node, you check the next k nodes to find the minimum and swap values as necessary. This approach has a time complexity of O(n⋅k) O...
Nearest Multiple of 10 | GFG POTD | Mathematics | C++Nearest Multiple of 10 | GFG POTD | Mathematics | C++
Nearest Multiple of 10 | GFG POTD | Mathematics | C++
Просмотров 1266 дней назад
Hi guys, Today I have solved GFG POTD. I have mentioned the code in comment box. Thanks for watching. #dsa #datastructures #algorithm #gfg #potd #coding #array #strings #tree #binarysearchtree #codekarlo #dynamicprogramming #videomarketing​​ #gfg​​ #gfgstreek​​ #recursion​​ #cpp​​​ #motivation​ #motivation​ #developers #leetcode codingtools​ #gfg​ #potd​ #math #mathematics #bruteforce #teaching...
Single Number | GFG POTD | Bit Manipulation | C++Single Number | GFG POTD | Bit Manipulation | C++
Single Number | GFG POTD | Bit Manipulation | C++
Просмотров 197 дней назад
Hi guys, Today I have solved GFG POTD. I have mentioned the code in comment box. Thanks for watching. #dsa #datastructures #algorithm #gfg #potd #coding #array #strings #tree #binarysearchtree #codekarlo #dynamicprogramming #videomarketing​​ #gfg​​ #gfgstreek​​ #recursion​​ #cpp​​​ #motivation​ #motivation​ #developers #leetcode #codingtools​ #gfg​ #potd​ #hashmap #bitmanipulation #bits #brutef...
Split Linked List Alternatingly | GFG POTD | Linked Lists | C++Split Linked List Alternatingly | GFG POTD | Linked Lists | C++
Split Linked List Alternatingly | GFG POTD | Linked Lists | C++
Просмотров 468 дней назад
Hi guys, Today I have solved GFG POTD. I have mentioned the code in comment box. Thanks for watching. #dsa #datastructures #algorithm #gfg #potd #coding #array #strings #tree #binarysearchtree #codekarlo #dynamicprogramming #videomarketing​​ #gfg​​ #gfgstreek​​ #recursion​​ #cpp​​​ #motivation​ #motivation​ #developers #leetcode #codingtools​ #gfg​ #potd​ #linkedlist #bruteforce #teaching#educa...
Two Swaps | GFG POTD | Arrays | C++Two Swaps | GFG POTD | Arrays | C++
Two Swaps | GFG POTD | Arrays | C++
Просмотров 1699 дней назад
Hi guys, Today I have solved GFG POTD. I have mentioned the code in comment box. Thanks for watching. #dsa #datastructures #algorithm #gfg #potd #coding #array #strings #tree #binarysearchtree #codekarlo #dynamicprogramming #videomarketing​​ #gfg​​ #gfgstreek​​ #recursion​​ #cpp​​​ #motivation​ #motivation​ #developers #leetcode codingtools​ #gfg​ #potd​ #hashmap #bruteforce #teaching#education...
Subarray Range With Given Sum | GFG POTD | Hash Map | C++Subarray Range With Given Sum | GFG POTD | Hash Map | C++
Subarray Range With Given Sum | GFG POTD | Hash Map | C++
Просмотров 11910 дней назад
Hi guys, Today I have solved gfg POTD, I have mentioned the code in comment box. Thanks for watching. #coding​​ #helpajobseeker​​ #easyrecipes​​ #coding​​ #helpajobseeker​​ #easyrecipes​​ #leetcode​​ #leetcodequestionandanswers​​ #leetcodesolution​​ #leetcodedailychallenge​​ #leetcodequestions​​ #leetcodechallenge​​ #hindi​​ #india​​ #hindiexplanation​​ #hindiexplained​​ #easyexplaination​​ #in...
Delete Alternate Nodes | GFG POTD | Linked Lists | C++Delete Alternate Nodes | GFG POTD | Linked Lists | C++
Delete Alternate Nodes | GFG POTD | Linked Lists | C++
Просмотров 3812 дней назад
Hi guys, Today I have solved gfg POTD, I have mentioned the code in comment box. Thanks for watching. #coding​ #helpajobseeker​ #easyrecipes​ #coding​ #helpajobseeker​ #easyrecipes​ #leetcode​ #leetcodequestionandanswers​ #leetcodesolution​ #leetcodedailychallenge​ #leetcodequestions​ #leetcodechallenge​ #hindi​ #india​ #hindiexplanation​ #hindiexplained​ #easyexplaination​ #interview​ #intervi...
Two Smallests in Every Subarray | GFG POTD | Arrays | C++Two Smallests in Every Subarray | GFG POTD | Arrays | C++
Two Smallests in Every Subarray | GFG POTD | Arrays | C++
Просмотров 2413 дней назад
Hi guys, Today I have solved gfg POTD, I have mentioned the code in comment box. Thanks for watching. #coding​ #helpajobseeker​ #easyrecipes​ #coding​ #helpajobseeker​ #easyrecipes​ #leetcode​ #leetcodequestionandanswers​ #leetcodesolution​ #leetcodedailychallenge​ #leetcodequestions​ #leetcodechallenge​ #hindi​ #india​ #hindiexplanation​ #hindiexplained​ #easyexplaination​ #interview​ #intervi...
Reorganize The Array | GFG POTD | Arrays | C++Reorganize The Array | GFG POTD | Arrays | C++
Reorganize The Array | GFG POTD | Arrays | C++
Просмотров 4514 дней назад
Hi guys, Today I have solved gfg POTD, I have mentioned the code in comment box. Thanks for watching. #coding​ #helpajobseeker​ #easyrecipes​ #coding​ #helpajobseeker​ #easyrecipes​ #leetcode​ #leetcodequestionandanswers​ #leetcodesolution​ #leetcodedailychallenge​ #leetcodequestions​ #leetcodechallenge​ #hindi​ #india​ #hindiexplanation​ #hindiexplained​ #easyexplaination​ #interview​ #intervi...
Max distance between same elements | GFG POTD | Hash Map | C++Max distance between same elements | GFG POTD | Hash Map | C++
Max distance between same elements | GFG POTD | Hash Map | C++
Просмотров 2915 дней назад
Hi guys, Today I have solved gfg POTD, I have mentioned the code in comment box. Thanks for watching. #coding #helpajobseeker #easyrecipes #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips #interviewp...

Комментарии

  • @galepraveen9468
    @galepraveen9468 8 часов назад

    vector<int> alternateSort(vector<int>& arr) { int n = arr.size(); sort(begin(arr), end(arr)); int maxNum = arr[n-1] + 1; // ENCODING for(int i = 0; i < n; ++i){ if(i % 2 == 0){ int evenIndex = (n - 1 - (i/2)); int compressedNum = (arr[evenIndex] % maxNum) * maxNum; arr[i] = arr[i] + compressedNum; }else{ int oddIndex = (i/2); int compressedNum = (arr[oddIndex] % maxNum) * maxNum; arr[i] = arr[i] + compressedNum; } } // DECODING for(int i = 0; i < n; ++i){ arr[i] = arr[i] / maxNum; } return arr; }

  • @abhijitmanna4524
    @abhijitmanna4524 День назад

    Today very good explanation, no stuck in explanation, liked it very much

    • @galepraveen9468
      @galepraveen9468 День назад

      Thanks Abhijit, I actually stammer a lot, but trying to deliver and overcome it. Your comment made my day ❤️. Keep supporting 🙌

  • @Angopoonam
    @Angopoonam День назад

    Nice explanation Sir 👏 really helpful 😊

  • @galepraveen9468
    @galepraveen9468 День назад

    vector<int> modifyAndRearrangeArray(vector<int> &arr) { int n = arr.size(); // STEP : 1 for(int i = 0; i < n-1; ++i){ if(arr[i] == arr[i+1]){ arr[i] *= 2; arr[i+1] = 0; i += 1; } } // STEP = 2 int validPointer = 0; for(int i = 0; i < n; ++i){ if(arr[i] != 0){ arr[validPointer] = arr[i]; validPointer += 1; } } for(int i = validPointer; i < n; ++i){ arr[i] = 0; } return arr; }

  • @galepraveen9468
    @galepraveen9468 2 дня назад

    int getTotalLength(Node* head){ int length = 0; while(head){ length += 1; head = head->next; } return length; } int sumOfLastN_Nodes(struct Node* head, int n) { int totalLength = getTotalLength(head); int firstNNodesLength = totalLength - n; int firstNNodesSum = 0, totalSum = 0; Node* curr = head; while(curr){ totalSum += curr->data; if(firstNNodesLength > 0){ firstNNodesSum += curr->data; firstNNodesLength -= 1; } curr = curr->next; } return totalSum - firstNNodesSum; }

  • @himanshuraghav5614
    @himanshuraghav5614 2 дня назад

    Nice explanation coded myself after understanding 👍 👌

  • @nownow1025
    @nownow1025 3 дня назад

    how subarrays were counted i.e res+=mpp[i] this part could have been explained more .. anyways thank you bhaiya

    • @galepraveen9468
      @galepraveen9468 3 дня назад

      When you encounter the same diff again, it means that the elements between the previous occurrence of that diff and the current index have resulted in equal numbers of x and y. Suppose [a,b] have already contributed with diff 0 and res is 1. Now when we get the same diff with [c,d] it will also contribute to res and res becomes 2. But with [a,b,c,d], a new combination pair is found as both have same diff right. So res will be 3. We do the same thing with every repetition of pair. because subarray is individual, as well as, it will contribute in pair for others. That’s why we are tracking the count of diff, so that I could add as individual + with some other pair of same diff. Hope you got it bro. Thanks for taking out time and commenting ❤️

  • @nownow1025
    @nownow1025 3 дня назад

    Thank you

    • @galepraveen9468
      @galepraveen9468 3 дня назад

      Thank you brother for commenting. Keep learning ❤️

  • @dewmepie2511
    @dewmepie2511 3 дня назад

    why are we adding count of those whose diff is 1..we need diff=0 subarrays right

    • @galepraveen9468
      @galepraveen9468 3 дня назад

      It is irrespective of diff brother. We are checking for same repetition, not for diff = 0. Thanks for commenting by taking out time ❤️

  • @Boomingsoldier
    @Boomingsoldier 3 дня назад

    bhaiya aapne to shi samjaya but sumj nhi aaya

  • @galepraveen9468
    @galepraveen9468 3 дня назад

    int sameOccurrence(vector<int>& arr, int x, int y) { int n = arr.size(); unordered_map<int,int> mp; mp[0] = 1; int diff = 0; int res = 0; for(int i = 0; i < n; ++i){ if(arr[i] == x){ diff += 1; }else if(arr[i] == y){ diff -= 1; } if(mp.count(diff)){ res += mp[diff]; } mp[diff] += 1; } return res; }

  • @galepraveen9468
    @galepraveen9468 4 дня назад

    Why (1 << (arr.size()-1)) - 1? If we consider the example for {2, 2, 3, 3} where the length is 4 There are 16 distinct valid combinations: {2} | {2, 3, 3} {2} | {2, 3, 3} {2, 3, 3} | {2} {3} | {2, 2, 3} {3} | {2, 2, 3} {2, 2} | {3, 3} {3, 3} | {2, 2} {2, 3} | {2, 3} {} | {2, 2, 3, 3} -- excluded .. so on Thus, The total number of subsets is 16. If we consider distinct valid combinations, we need to account for how many unique pairs we can form from these subsets while avoiding duplicates: The total number of subsets (including the empty and full set) is 2 ^ n . By subtracting 2 from this total (one for the empty set and one for the complete set), we get 2 ^ n −2. And by halving the pairs(as each pair is duplicate and removing both empty set) the overall formula becomes (2 ^ (n-1)) - 1 (or) (1 << (n-1)) - 1 The above thing I couldn't capture during morning as all test cases got passed. Thanks for understanding.

  • @nocodelimits
    @nocodelimits 4 дня назад

    I am getting wrong answer in the testcases Test Cases Passed: 1 /1113 For Input: 5 5 1 1 3 3 Your Code's output is: 6 It's Correct output is: 31

    • @gautamjangir8927
      @gautamjangir8927 4 дня назад

      int countgroup(vector<int>& arr) { int n = arr.size(); int ans = 0; for(int i=0; i<n; i++) { ans ^= arr[i]; } if(ans==0) { return (1<<(n-1))-1; } return 0; }

    • @gautamjangir8927
      @gautamjangir8927 4 дня назад

      Test Case Updated

    • @galepraveen9468
      @galepraveen9468 4 дня назад

      I have updated the code in comment. I've missed the main test cases.Sorry for that.

  • @PulkitMalhotra
    @PulkitMalhotra 4 дня назад

    Your code will fail for testcase 2 2 3 3 GFG missed this

    • @galepraveen9468
      @galepraveen9468 4 дня назад

      Precisely, as I have a lack of time, i couldn't explore much on custom examples. Thanks for pointing it out ☺️

    • @shashank3374
      @shashank3374 4 дня назад

      ​@@galepraveen9468 It will also fail for 5 5 1 1 3 3

    • @galepraveen9468
      @galepraveen9468 4 дня назад

      I have updated the code in comment. I've missed the main test cases.Sorry for that

  • @rajanprajati115
    @rajanprajati115 4 дня назад

    i really like your content

    • @galepraveen9468
      @galepraveen9468 4 дня назад

      Thank you so much for taking out time and commenting on this video. Your comment really made my day ❤. I'll deliver more content like this, in fact better. Keep supporting.❤

  • @galepraveen9468
    @galepraveen9468 4 дня назад

    UPDATED CODE int countgroup(vector<int>& arr) { int res = 0; for(auto& num : arr) res ^= num; if(res != 0) return 0; return (1 << (arr.size()-1)) - 1; }

  • @rrichard8719
    @rrichard8719 5 дней назад

    For input like 5 6 7 8 3 4 K=3 Expected output= 5 3 4 6 7 8 Why?? It's wrong right When it can be 3 4 5 6 7 8

  • @galepraveen9468
    @galepraveen9468 5 дней назад

    DLLNode *sortAKSortedDLL(DLLNode *head, int k) { priority_queue<int, vector<int>, greater<int> > pq; DLLNode* tail = head; DLLNode* nexty = NULL; int freq = k + 1; while(tail && freq > 0){ pq.push(tail->data); tail = tail->next; nexty = tail; freq -= 1; } tail = head; while(nexty){ int minVal = pq.top(); pq.pop(); tail->data = minVal; tail = tail->next; pq.push(nexty->data); nexty = nexty->next; } while(tail && !pq.empty()){ int minVal = pq.top(); pq.pop(); tail->data = minVal; tail = tail->next; } return head; }

    • @galepraveen9468
      @galepraveen9468 5 дней назад

      Issue from my side, i should also have added 5 in heap and processed the execution. Sorry for that ❤️

  • @Angopoonam
    @Angopoonam 6 дней назад

    Thank you so much for such a detailed explanation Sir 😊 🎉

  • @galepraveen9468
    @galepraveen9468 6 дней назад

    string roundToNearest(string str) { int n = str.size(); if(str[n-1] - '0' <= 5){ str[n-1] = '0'; return str; } int carry = 1; str[n-1] = '0'; for(int i = n-2; i >= 0; --i){ if(carry){ int num = str[i] - '0'; num += 1; carry = num / 10; str[i] = (num % 10) + '0'; }else break; } if(carry){ char ch = carry + '0'; str = ch + str; } return str; }

  • @galepraveen9468
    @galepraveen9468 7 дней назад

    int getSingle(vector<int>& arr) { int res = 0; for(auto& x : arr){ res ^= x; } return res; }

  • @galepraveen9468
    @galepraveen9468 8 дней назад

    vector<Node*> alternatingSplitList(struct Node* head) { if(!head->next) return {head, NULL}; Node* head1 = head, *head2 = head->next; Node* tail1 = head1, *tail2 = head2; while(tail2){ tail1->next = tail2->next; tail1 = tail1->next; if(tail1){ tail2->next = tail1->next; } tail2 = tail2->next; } return {head1, head2}; }

  • @galepraveen9468
    @galepraveen9468 9 дней назад

    bool checkSorted(vector<int> &arr) { int n = arr.size(); int swapCount = 2; int i = 0; while(swapCount > 0){ int j = arr[i]; swap(arr[i], arr[j - 1]); if(arr[i] == i+1) i += 1; swapCount -= 1; } for(int i = 0; i < n; ++i){ if(arr[i] != i + 1) return false; } return true; }

  • @shashank3374
    @shashank3374 10 дней назад

    ❤ best

    • @galepraveen9468
      @galepraveen9468 10 дней назад

      Thanks Shashank, your comment made my day ❤️

    • @shashank3374
      @shashank3374 10 дней назад

      @@galepraveen9468 the way you explain the problem was incredible specially that equation concept let y , x and x=y-A continue this approach 👍

    • @galepraveen9468
      @galepraveen9468 10 дней назад

      @@shashank3374 Thank you so much for valuable feedback brother, please maintain the constant support and I'll deliver more content similar to it ❤️

  • @Angopoonam
    @Angopoonam 10 дней назад

    Great explanation Sir...learnt a lot today,Thanks 👏 👍

  • @galepraveen9468
    @galepraveen9468 10 дней назад

    int subArraySum(vector<int>& arr, int tar) { int n = arr.size(); unordered_map<int,int> mp; mp[0] = 1; int count = 0, currSum = 0; for(auto& num : arr){ currSum += num; if(mp.count(currSum - tar)){ count += mp[currSum - tar]; } mp[currSum] += 1; } return count; }

  • @Angopoonam
    @Angopoonam 13 дней назад

    Wonderful explanation Sir 👏 👌 👍

  • @galepraveen9468
    @galepraveen9468 13 дней назад

    int pairWithMaxSum(vector<int>& arr) { int n = arr.size(); if(n <= 1) return -1; int maxSum = 0; for(int i = 1; i < n; ++i){ maxSum = max(maxSum, arr[i] + arr[i-1]); } return maxSum; }

  • @galepraveen9468
    @galepraveen9468 14 дней назад

    vector<int> rearrange(vector<int>& arr) { int n = arr.size(); for(int i = 0; i < n; ++i){ int ind = arr[i]; while(ind != -1 && arr[i] != arr[ind]){ swap(arr[i], arr[ind]); ind = arr[i]; } } return arr; }

  • @galeraju6285
    @galeraju6285 14 дней назад

    Mast explain kare bro 🥳

  • @Angopoonam
    @Angopoonam 14 дней назад

    🎉🎉🎉🎉Nice explanation sir

  • @Angopoonam
    @Angopoonam 15 дней назад

    Wonderful explanation sir🎉🎉

  • @galepraveen9468
    @galepraveen9468 15 дней назад

    int maxDistance(vector<int> &arr) { unordered_map<int,int> mp; int n = arr.size(); int maxDist = 0; for(int i = 0; i < n; ++i){ int num = arr[i]; if(!mp.count(num)){ mp[num] = i; }else{ maxDist = max(maxDist, i - mp[num]); } } return maxDist; }

  • @Angopoonam
    @Angopoonam 16 дней назад

    Need more videos sir😊Thank you!

  • @Angopoonam
    @Angopoonam 16 дней назад

    Kudos...great explanation Sir🎉🎉🎉🎉