The TransCompilator

Solved LeetCode program · 886 of 1,000

#1218 · Longest Arithmetic Subsequence of Given Difference

Medium Array chunk-18.md

Original English source

The readings is a list of 1, 5, 7, 8, 5, 3, 4, 2, and 1. The step is -2. The lengths is a list of 9 zeros.
For every finish from 0 to 8.
Set item finish of lengths to 1.
For every prior from 0 to finish minus 1.
If item prior of readings plus step is item finish of readings and item prior of lengths plus 1 is more than item finish of lengths, set item finish of lengths to item prior of lengths plus 1.

The longest is 1.
For every finish from 0 to 8.
If item finish of lengths is more than longest, set longest to item finish of lengths.

Show longest.

Open in Playground Browse all 1,000 problems

Expected stdout

4