Miaplaza Interview Question

algorithms refactoring a simple C# code