leetcode1027】的更多相关文章

Given an array A of integers, return the length of the longest arithmetic subsequence in A. Recall that a subsequence of A is a list A[i_1], A[i_2], ..., A[i_k]with 0 <= i_1 < i_2 < ... < i_k <= A.length - 1, and that a sequence B is arithm…
最直接的思路是三层循环,但是会超时,代码如下: public class Solution { public int LongestArithSeqLength2(int[] A) { ; var len = A.Count(); ; i < len; i++) { ; j < len; j++) { ; var target = A[i] - A[j]; var next = A[j] - target; ; k < len; k++) { if (A[k] == next) { cu…