For my reference...
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- sort the coins and consider window (L,R C) that are valid (meaning the window size is < k). If added new range of L to R cause window invalid, consider the total obtain by including a much as possible before remove coins from start of window. -->

# Approach
<!-- 1) Sort the coins to obtain the ascending order.
2) Main Loop (extract the left, right and coin values, compute the total number of coins in the current range and adds it into total_accum_points):
for j in range(n):
    left, right, coin = coins[j]
    total_accum_coins += coin * (right-left+1)
3) Inner While Loop (This inner loop check currange range, which defined by coins[j] and coins[i] exceed k or not. If k is exceeded, it compute the extra, which is the amount by which range exceeds k. Then it update res to be the maximum of its current value with the total_accumulated coins minus the excess coins that cannot be counted, ie the maximum value computed by range of valid k):
while coins[j][1] - coins[i][0] > k-1:
    extra = coins[j][1] - coins[i][0] + 1 - k
    res = max(res, total_accum_coins - extra * coin)
4) Adjusting the left boundary(retrieve the left, right, coin values for current index i , if the range of the current coin at i exceeds the extra, it reduces the total accumulated coins by the excess and moves the left pointer of the range to the right. If range does not exceed extra, if not exceed extra, it substracts all coins from that range and move left boundary) :
left1, right1, coin1 = coins[i]
if right1 - left1 + 1 > extra:
    total_accum_coins -= coin1 * extra
    coins[i][0] += extra
else:
    total_accum_coins -= coin1 * (right1 - left1 + 1)
    i += 1


  -->

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

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

# Code
```python3 []
class Solution:
    def maximumCoins(self, coins: List[List[int]], k: int) -> int:
        coins.sort()
        n = len(coins)
        total_accum_coins = 0
        i = 0
        res = 0
        for j in range(n):
            left, right, coin = coins[j]
            total_accum_coins += coin * (right-left+1)
            while coins[j][1] - coins[i][0] > k-1:
                extra = coins[j][1] - coins[i][0] +1-k
                res = max(res, total_accum_coins-extra *coin)
                left1, right1, coin1 = coins[i]
                if right1-left1 +1 >extra:
                    total_accum_coins -= coin1 *extra
                    coins[i][0] +=extra
                else:
                    total_accum_coins -= coin1 * (right1-left1 +1)
                    i+=1
            res = max(res, total_accum_coins)
        return res
```
['Python3']