Lazy Calc Longest, constant upload, using array
Intuitionwhen the longest is requested, start from the previously calculated longest and step forward and capture any additional uploads to prefix.ApproachMost
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
when the longest is requested, start from the previously calculated longest and step forward and capture any additional uploads to prefix.

# Approach
Most other solutions do the longest calculation at the end of upload(), this keeps the calculation time averaged, but is also unnecessary work in the case where longest() is not called after upload(). So I did the calculation at the beginning of longest(), essentially a lazier approach.

# Complexity
- Time complexity:
upload: O(1)
longest: O(1) amortized, no more than O(n)
- Space complexity:
O(n)

# Code
```typescript []
class LUPrefix {
    data: boolean[];
    long_pre: number;

    constructor(n: number) {
        this.data = new Array(n);
        this.long_pre = 0;    
    }

    upload(video: number): void {
        this.data[video-1] = true;
    }

    longest(): number {
        while (this.data[this.long_pre]) this.long_pre++;
        return this.long_pre;
    }
}

/**
 * Your LUPrefix object will be instantiated and called as such:
 * var obj = new LUPrefix(n)
 * obj.upload(video)
 * var param_2 = obj.longest()
 */
```
['TypeScript']