Editorial for Spring Coding Bowl '22 P1 - Student Numbers


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Take in the student number as an array of integers. For example, 123456 \to [1,2,3,4,5,6]. Replace every 0 with a 10, [9,0,9,8,9,0] \to [9,10,9,8,9,10]. Finally, check if every adjacent digit in the new array has an absolute difference equal to 1 and print accordingly. Note that other solutions exist.

Time Complexity: \mathcal{O}(1)


Comments

There are no comments at the moment.