From d10271e0fb043ec8d687a146a642dd875483563e Mon Sep 17 00:00:00 2001 From: Udhay <72250606+Udhay-Brahmi@users.noreply.github.com> Date: Fri, 25 Dec 2020 08:00:02 +0530 Subject: [PATCH] Create Count rotations divisible by 4 --- Count rotations divisible by 4 | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Count rotations divisible by 4 diff --git a/Count rotations divisible by 4 b/Count rotations divisible by 4 new file mode 100644 index 0000000..e589cca --- /dev/null +++ b/Count rotations divisible by 4 @@ -0,0 +1,38 @@ +// { Driver Code Starts +// Initial Template for C++ + +#include +using namespace std; + + // } Driver Code Ends + + +// User function Template for C++ + +class Solution{ +public: + int countRotations(string N){ + // code here + int count=0; + if(((N[0] -'0') + (N[N.length()-1] - '0')*10)%4==0){count++;} + for(int i=0;i<(N.length()-1);i++){ + if(((N[i] - '0')*10 + (N[i+1] - '0'))%4==0)count++; + } + return count; + } +}; + +// { Driver Code Starts. + +int main(){ + int t; + cin>>t; + while(t--){ + string N; + cin>>N; + + Solution ob; + cout<