------
## 最终结论
```python
import bisect

def lengthOfLIS(nums):
    if not nums:
        return 0

    sub = []
    for num in nums:
        pos = bisect.bisect_left(sub, num)
        if pos == len(sub):
            sub.append(num)
        else:
            sub[pos] = num
            
    return len(sub)

# Example usage
print(lengthOfLIS([10,9,2,5,3,7,101,18]))  # Output: 4
```