← Questions

Fewest sum-replacement steps to reach a target array

0
CognitionCodingLast asked Dec 2024

A coding interview question asked in Cognition's coding screen, last asked Dec 2024. It tests arrays, heaps and math.

An array of length n starts with every element equal to 1. One step picks one element and replaces it with the sum of the whole array.

Sign in to unlock this question

The full prompt, the worked answer and your own canvas or code with the AI tutor. New accounts get 5 credits: each one unlocks a question for good.

Where it's asked

What it tests

arrays · heaps · math

Your code and the AI tutor open when you unlock this question.