Find the number of players who roll the dice when the dice output sequence is given | Java 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
import java . util . * ; class GFG { static int findM ( String s , int x ) { int cnt = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) - '0' != x ) cnt ++ ; } return cnt ; } public static void main ( String args [ ] ) { String s = "3662123" ; int x = 6 ; System . out . println ( findM ( s , x ) ) ; } }