Answer
The first algorithm provides a clear and easy way to follow an algorithm. The second one is a result of more in-depth thinking and allows us to find the result in a single step.
---
Although the first algorithm leads us to the correct result and it is very
easy to understand and implement, the second one saves us a huge amount of
time. It is superior to the first one in terms of elegance and efficiency. It is
an example of how valuable the time we spend on developing more efficient
algorithms is. Just by applying logic to a task, we can find a shortcut like
this which saves us a lot of time. We could say they are both quite equal in
terms of clarity.
Work Step by Step
--