You are viewing a single comment's thread. Return to all 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"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Cats and a Mouse
You are viewing a single comment's thread. Return to all comments →
A Short and Easy C# Solution using Ternary operator With Time and Space Complexity of O(1).