# Sliding Window

## Blind 75

### Best Time to Buy & Sell Stock&#x20;

#### Question

![](https://2669959621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxncaDDrGpdjhVy86HbwM%2Fuploads%2FjPeJSNfU4RWM5xH1N87v%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202022-04-26%20%E1%84%8B%E1%85%A9%E1%84%8C%E1%85%A5%E1%86%AB%204.34.39.png?alt=media\&token=e9cd192a-4b7b-45d4-8476-0a3198d4d597)

#### Drawing Explanation

![](https://2669959621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxncaDDrGpdjhVy86HbwM%2Fuploads%2FV4TceiZJGTN3721IzzsF%2FCT-2.jpg?alt=media\&token=c374a9b7-ae9b-478c-95a5-991c61d2c6a2)

#### code

```java
public class BestTimeToBuySellStock {
    public int maxProfit(int[] prices) {
        int sell = 0;
        int buy = Integer.MAX_VALUE;
        for (int price: prices) {
            if (price < buy) {
                buy = price;
            }
            else {
                sell = Math.max(sell, price - buy);
            }
        }
        return sell;
    }
}
```

###

### Longest Substring Without Repeating Characters

#### Question

#### Drawing Explanation

#### Code



### Longest Repeating Character Replacement

#### Question

#### Drawing Explanation

#### Code



### Minimum Window Substring

#### Question

#### Drawing Explanation

#### Code
