• + 0 comments

    A Short and Easy C# Solution using Ternary operator With Time and Space Complexity of O(1).

    static string catAndMouse(int x, int y, int z) 
    {
    	int a = Math.Abs(x - z), b = Math.Abs(y - z);
    	return (a < b) ? "Cat A" : (a == b) ? "Mouse C" : "Cat B";
    }