Daily iOS
Swift

Combining higher-order functions

Take ["a", "b", "c"] as input and produce ["c-0", "b-1", "a-2"]. You can't use a for loop, only higher-order functions. Which functions would you combine, and in what order?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

First reversed() to flip the order, then enumerated() to number the flipped order from 0, then map to interpolate element and index into a string. enumerated numbers whatever order it's called on, so reversed has to come first for c to get 0.

Share a question