Find the number of players who roll the dice when the dice output sequence is given | C ++ implementation of the approach ; Function to return the number of players ; Initialize cnt as 0 ; Iterate in the string ; Check for numbers other than x ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int findM ( string s , int x ) { int cnt = 0 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { if ( s [ i ] - '0' != x ) cnt ++ ; } return cnt ; } int main ( ) { string s = "3662123" ; int x = 6 ; cout << findM ( s , x ) ; return 0 ; }