From 4fd3ad344dc09cbf24eb1247318f6acee9f3b968 Mon Sep 17 00:00:00 2001 From: VasanthThallam <96721657+VasanthThallam@users.noreply.github.com> Date: Sun, 16 Oct 2022 11:13:07 +0530 Subject: [PATCH] Added 2437. Number of Valid Clock Times added leetcode problem https://leetcode.com/contest/biweekly-contest-89/problems/number-of-valid-clock-times/ please add hacktober tag --- C++/leetcode2.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 C++/leetcode2.cpp diff --git a/C++/leetcode2.cpp b/C++/leetcode2.cpp new file mode 100644 index 00000000..b27266d3 --- /dev/null +++ b/C++/leetcode2.cpp @@ -0,0 +1,19 @@ +class Solution { +public: + int countTime(string timer) { + int ans=1; + if(timer[0]=='?'&&timer[1]=='?') ans*=24; + else if(timer[1]=='?' && timer[0]=='2') ans*=4; + else if(timer[1]=='?' && timer[0]!='2') ans*=10; + else if(timer[0]=='?') + { + if(timer[1]=='0'||timer[1]=='1'||timer[1]=='2'||timer[1]=='3') + ans*=3; + else ans*=2; + } + if(timer[3]=='?'&& timer[4]=='?') ans*=60; + else if(timer[4]=='?') ans*=10; + else if(timer[3]=='?') ans*=6; + return ans; + } +};