Java Sliding window Two side
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# 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
```python3 []
class Solution:
    def maximumCoins(self, coins: List[List[int]], k: int) -> int:
        coins.sort()
        l = 0
        temp = 0
        ans = 0
        print(coins)
        for r in range(len(coins)):
            temp+=coins[r][2]*(coins[r][1]-coins[r][0]+1)
        
            while coins[r][1] - coins[l][1] + 1 > k:
                
                temp-=coins[l][2]*(coins[l][1]-coins[l][0]+1)
                l+=1
            
            extra = max(0,coins[r][1] - coins[l][0] + 1 - k)
            ans = max(ans, temp - extra*coins[l][2] )
        l = len(coins)-1
        temp = 0
        for r in range(len(coins)-1,-1,-1):
            temp+=coins[r][2]*(coins[r][1]-coins[r][0]+1)
        
            while coins[l][0] - coins[r][0] + 1 > k:
                
                temp-=coins[l][2]*(coins[l][1]-coins[l][0]+1)
                l-=1
            
            extra = max(0, coins[l][1] - coins[r][0]  + 1 - k)
            ans = max(ans, temp - extra*coins[l][2])
        return ans
        
```
['Python3']