← Amazon questions

Generate alternate 0s and 1s pattern following recurrence relation

Filed under Amazon

Given an array of 0s and 1s and a recurrence relation defined as f(1)=1, f(2)=2, f(n)=f(n-1)^2 - f(n-2)^2, output 0s and 1s alternatively according to the calculated sequence values.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Amazon questions

Collected from public candidate posts and coding forums. Updated Nov 2026.