最长增长序列

2019-01-31  本文已影响4人  LuDon

问题:

思路:

import numpy as np
class Solution(object):
    def increasingTriplet(self, nums):
        """
        :type nums: List[int]
        :rtype: bool
        """
        if len(nums) < 3:
            return False
        record = np.zeros((len(nums)))
        record[0] = 1
        for i in range(1, len(nums)):
            n_max = 1
            for j in range(i):
                if nums[j]<nums[i]:
                    n = record[j]+1
                    if n>n_max:
                        n_max = n
            record[i] = n_max
return int(max(record))
上一篇下一篇

猜你喜欢

热点阅读