The code to this problem is very unclean, there are unnecessary if statement in the first section of the while loop, with a break statement. The value of res is being written more than once in every case, even though, its only is needed to be put once. All of this makes the solution less understandable and unclean.
The code to this problem is very unclean, there are unnecessary if statement in the first section of the while loop, with a break statement. The value of res is being written more than once in every case, even though, its only is needed to be put once. All of this makes the solution less understandable and unclean.
given solution:
My solution: