#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# max increasing subsequence
# @param arr int整型一维数组 the array
# @return int整型
#
class Solution:
def MLS(self, arr: List[int]) -> int:
# write code here
s = sorted(list(set(arr)))#数组去重后升序排列
n = len(s)
dp = [1] * n
for i in range(1, n):#查找去重后的数组中最长的连续差值为1的递增序列
if s[i] == s[i - 1] + 1:
dp[i] = dp[i - 1] + 1
return max(dp)



京公网安备 11010502036488号