Python (Simple BIT)
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 BIT:
    def __init__(self,n):
        self.ans = [0]*(n+1)

    def update(self,i,val):
        while i < len(self.ans):
            self.ans[i] += val 
            i += i&-i 

    def query(self,i):
        total = 0 

        while i:
            total += self.ans[i]
            i -= i&-i 

        return total 

class LUPrefix:
    def __init__(self, n):
        self.res = BIT(n)
        self.n = n

    def upload(self, video):
        self.res.update(video,1)

    def longest(self):
        low, high = 1, self.n 

        while low <= high:
            mid = (low+high)//2 

            if self.res.query(mid) == mid:
                low = mid + 1 
            else:
                high = mid - 1 

        return high 
```
['Python3']