← All problemsSign in

1027. Longest Arithmetic Subsequence

LeetCodeArrayHash TableBinary SearchDynamic ProgrammingOpen on judge ↗

Given an array nums of integers, return the length of the longest arithmetic subsequence in nums. Note that: - A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements. - A sequence seq is arithmetic if seq[i + 1] - seq[i] are all the same value (for 0 <= i < seq.length - 1). Example 1: Input: nums

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start