1027. Longest Arithmetic Subsequence
Given an array nums
of integers, return the length of the longest arithmetic subsequence in nums
.
Note that:
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:
nums.length
<= 1000nums[i]
<= 500放假很閒,嘗試各種優化
Yen-Chi ChenFri, Jun 23, 2023
Runtime 3391 ms Beats 39.18%
Yen-Chi ChenFri, Jun 23, 2023
Runtime 2825 ms Beats 80.4%
Yen-Chi ChenFri, Jun 23, 2023
Runtime 2055 ms Beats 90.59%
Yen-Chi ChenFri, Jun 23, 2023
Runtime 215 ms Beats 100%
Yen-Chi ChenFri, Jun 23, 2023
Jerry23 June, 2023