Monday, November 13, 2017

Chef and digits of a number Codechef Problem Solution

https://www.codechef.com/problems/LONGSEQ



In C++....................

    #include<bits/stdc++.h>

    using namespace std;

    int main()

    {

       int t;
       string s;
       cin>>t;
       while(t--)
       {
           cin>>s;
           int one=0,zero=0;
           for(int i=0;i<s.size();i++)
           {
               if(s[i]=='1')
               {
                   one++;
               }
               if(s[i]=='0')
               {
                   zero++;
               }
           }
           if((min(one,zero)==1||s.size()==1))
           {
               cout<<"Yes"<<endl;
           }
           else
           {
               cout<<"No"<<endl;
           }
       }
       return 0;
    }

No comments:

Post a Comment