1027. Longest Arithmetic Subsequence
https://leetcode.com/problems/longest-arithmetic-subsequence
Description
Given an array nums
of integers, return the length of the longest arithmetic subsequence in nums
.
Recall that a subsequence of an array nums
is a list nums[i1], nums[i2], ..., nums[ik]
with 0 <= i1 < i2 < ... < ik <= nums.length - 1
, and that a sequence seq
is arithmetic if seq[i+1] - seq[i]
are all the same value (for 0 <= i < seq.length - 1
).
Example 1:
Example 2:
Example 3:
Constraints:
2 <= nums.length <= 1000
0 <= nums[i] <= 500
ac
Previous1026. Maximum Difference Between Node and AncestorNext1028. Recover a Tree From Preorder Traversal
Last updated