Longest Arithmetic Subsequence

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

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

Note: The subsequence does not need to be contiguous.

Examples
Input: [3,6,9,12]
Output: 4
Hints

Longest Arithmetic Subsequence

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