solution from LIS

  • 0

    class Solution {
    bool increasingTriplet(vector<int>& nums) {
    vector<int> ans;
    for(int num : nums) {
    auto t = lower_bound(ans.begin(), ans.end(), num);
    if(t != ans.end())
    *t = num;
    else ans.push_back(num);
    if(ans.size()==3) return true;
    return false;
    when the size is 3, return true.the cost is O(n) time complexity and O(1) space complexity, right?

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.