Pattern matching using switch expression
Approach\nPattern match using switch expression.\n\n# Complexity\n- Time complexity:\nO(1)\n\n- Space complexity:\nO(1)\n\n# Code\n\npublic class Solution {\n  
# Approach\nPattern match using switch expression.\n\n# Complexity\n- Time complexity:\n$$O(1)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\npublic class Solution {\n    public int CountTime(string time) {\n        int hours = (time[0], time[1]) switch {\n            (\'?\', \'?\')   => 24,  // ?? => 00 .. 23\n            (\'?\', < \'4\') => 3,   // ?3 => 03, 13, 23\n            (\'?\', _)     => 2,   // ?4 => 04, 14\n            (\'2\', \'?\')   => 4,   // 2? => 20 .. 23\n            ( _ , \'?\')   => 10,  // 1? => 10 .. 19\n            _            => 1    // no wildcards\n        };\n        int minutes = (time[3], time[4]) switch {\n            (\'?\', \'?\')   => 60,  // ?? => 00 .. 59\n            (\'?\',  _)    => 6,   // ?5 => 05, 15, 25, 35, 45, 55\n            ( _ , \'?\')   => 10,  // 3? => 30 .. 39\n            _            => 1    // no wildcards\n        };\n        return hours * minutes;\n    }\n}\n```
['C#']