Simplest Soln ever possible -> Full Detailed With Comments 🤷‍♀️✔
IntuitionJust Read the Comments.
U will Get it.ApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
Just Read the Comments.
U will Get it.

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
#define ll long long
class Solution {
public:
    int lower_bound1(vector<vector<int>>& coins, int val){
        int n=coins.size();
        int l=0,h=n-1,indx=0;
        while(l<=h){
            int m=l+(h-l)/2;
            if(val>=coins[m][0]&&val<=coins[m][1]||coins[m][0]>=val){
                indx=m;
                h=m-1;
            }
            else l=m+1;
        }
        return indx;
    }
    int higher_bound1(vector<vector<int>>& coins, int val){
        int n=coins.size();
        int l=0,h=n-1,indx=0;
        while(l<=h){
            int m=l+(h-l)/2;
            if(val>=coins[m][0]&&val<=coins[m][1]||coins[m][1]<=val){
                indx=m;
                l=m+1;
            }
            else h=m-1;
        }
        return indx;
    }
    long long maximumCoins(vector<vector<int>>& coins, int k) {
        // Hey Raj Khud se kiya!
        // let's first of all create a prefix array
        int n=coins.size();
        vector<ll>pre(n);
        sort(coins.begin(),coins.end());
        for(int i=0;i<n;i++){
            ll st=coins[i][0],end=coins[i][1];
            if(i==0)pre[i]=(end-st+1)*coins[i][2];
            else pre[i]=pre[i-1]+(end-st+1)*coins[i][2];
        }
        // nnow Traverse all the pairs/ranges and find out the max possible among them
        ll ans=0;
        for(int i=0;i<n;i++){
            // we will try from both ways from l to l+k-1 and from r to r-k+1
            // First Way
            int st=coins[i][0];
            int end=st+k-1;
            int lr=lower_bound1(coins,st);
            int hr=higher_bound1(coins,end);
            // these lr and hr are in respect to the index in the coins vector
            // so that we can calculate the sum of the range by subtracting the values before lr
            // REMEMBER TO SUBTRACT THE EXTRA SUM ADDED FROM A RANGE WHEN THE LOWER OR HR IS NOT AT THE 
            // BOUNDARY THAN WE HAVE TO SUBTRACT THE EXTRA
            ll csum=pre[hr];
            if(lr>0)csum-=pre[lr-1];
            // NOW REMOVE THE EXTRA FROM THE HIGHER BOUND AS IN WAY 1 ONLY THIS HAPPENS!
            if(end<=coins[hr][1])
            csum-=(ll)(coins[hr][1]-end)*(ll)coins[hr][2];
            ans=max(ans,csum);
            csum=0;

            // Second Way
            st=coins[i][1]-k+1;
            end=coins[i][1];
            lr=lower_bound1(coins,st);
            hr=higher_bound1(coins,end);
            // these lr and hr are in respect to the index in the coins vector
            // so that we can calculate the sum of the range by subtracting the values before lr
            // REMEMBER TO SUBTRACT THE EXTRA SUM ADDED FROM A RANGE WHEN THE LOWER OR HR IS NOT AT THE 
            // BOUNDARY THAN WE HAVE TO SUBTRACT THE EXTRA
            csum=pre[hr];
            if(lr>0)csum-=pre[lr-1];
            // NOW REMOVE THE EXTRA FROM THE Lower BOUND AS IN WAY 1 ONLY THIS HAPPENS!
            if(st>=coins[lr][0])
            csum-=(ll)(st-coins[lr][0])*(ll)coins[lr][2];
            ans=max(ans,csum);
        }
        return ans;
    }
};
```
['Array', 'Binary Search', 'Greedy', 'Sliding Window', 'Sorting', 'Prefix Sum', 'C++']