Tap here to switch tabs
Problem
Submissions

Problem: Longest Arithmetic Subsequence

med
30 min
Try to solve the Longest Arithmetic Subsequence problem.

Statement

Given an integer array nums, return the length of the longest arithmetic subsequence in nums.

A subsequence is a sequence obtained from nums by deleting zero or more elements without altering the relative order of the remaining elements.

A sequence seq is arithmetic if the difference between any two consecutive elements is constant.

Constraints:

  • 2≤2 \le nums.length ≤1000\le 1000

  • 0≤0 \le nums[i] ≤500\le 500

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Arithmetic Subsequence

med
30 min
Try to solve the Longest Arithmetic Subsequence problem.

Statement

Given an integer array nums, return the length of the longest arithmetic subsequence in nums.

A subsequence is a sequence obtained from nums by deleting zero or more elements without altering the relative order of the remaining elements.

A sequence seq is arithmetic if the difference between any two consecutive elements is constant.

Constraints:

  • 2≤2 \le nums.length ≤1000\le 1000

  • 0≤0 \le nums[i] ≤500\le 500