Algoworks Interview Question

Puzzle , Swift, Coding logic skills