Type the Question

Monday, February 18, 2019

Question Name:INTELLIGENT GIRL

#include<iostream>
using namespace std ;
 
int main()
{
    string s ;
    cin>>s ;
    int size = s.size();
    int arr[size] ;
    int count = 0 ;
    for(int i = size-1 ; i>=0 ; i--)
    {
        if(s[i]%2 == 0)
          count++;
          
        arr[i]= count ;
    }
    
    for(int i =0 ; i<size ; i++)
    {
        cout<<arr[i]<<" ";
    }
}
  • Problem Description
    Soumika has a string S and its starting index is 1. The string S consists of characters from 19. As she is very intelligent, she wants to test his brother Vinay Tendulkar.

    She asked her brother Vinay Tendulkar to count the number of even numbered characters ( i.e 2,4,6,8 ) for every index
    (1<=i<=|S|). For an index i, the result should be calculated from i to the end of the string. As Vinay doesn’t know about programming, he wants you to help him find the solution.

    Input:
    First line contains a string S.

    Output:
    Print |S| space-separated integers,the result of every index.

    Constraints:

    1<= |S| <= 10^4
  • Test Case 1
    Input (stdin)574674546
    Expected Output5 5 5 4 3 3 2 2 1
  • Test Case 2
    Input (stdin)54566987543
    Expected Output5 5 4 4 3 2 2 1 1 1 0

No comments:

Post a Comment

Question Name:TOWER OF HANOI

#include < bits / stdc ++. h > #define lli long long using namespace std ; lli dp [ 202 ]; int main () { int t , n ; ...