Neudesic Interview Question

Write an algorithm