All Questions
4 questions
4
votes
1
answer
102
views
Swift Arrays: Write a rotate-right function
Task:
Write a function which rotates all elements of a given array to the right.
Example: [1, 2, 3] => [3, 1, 2]
My solution:
...
4
votes
1
answer
1k
views
Find minimum count of items where sum of them is X from an array
I recently faced an interview question where you have to find minimum needed items from an array that can added together to generate X value.
For example giving:
<...
4
votes
1
answer
2k
views
Swift - Finding longest binary gap of a given integer
I recently had the chance to try Codility's algorithm training, and the very first one in the list is finding the longest binary gap of a given integer.
I tried to implement this in Swift, and after ...
2
votes
0
answers
465
views
Filling a cumulative array in Swift
I have a "cumulative" lookup array for a custom collection view layout.
The idea is that I have an array of rectangles, each with an index. The index is not unique, and is monotonically increasing. ...