Given a string S and a number X. There are M players who roll the dice. A player keeps on rolling the dice until he gets a number other than X. In the string S, S[i] represents the number at ith roll of a dice. The task is to find M. Note that the last character in S will never be X.
Input: s = “3662123”, X = 6
First player rolls and gets 3.
Second player rolls and gets 6, 6 and 2.
Third player rolls and gets 1.
Fourth player rolls and gets 2.
Fifth player rolls and gets 3.
Input: s = “1234223”, X = 2
Approach: Iterate in the string and count the characters which are not X. The number of characters which are not X will be the number of players.
Below is the implementation of the above approach:
- Roll the characters of string
- Find nth term of the Dragon Curve Sequence
- Find Bit whose minimum sequence flips makes all bits same
- Form minimum number from given sequence
- Number of words in a camelcase sequence
- Total number of odd length palindrome sub-sequence around each centre
- Convert an unbalanced bracket sequence to a balanced sequence
- Number of closing brackets needed to complete a regular bracket sequence
- Given a number as a string, find the number of contiguous subsequences which recursively add up to 9 | Set 2
- Given a number as a string, find the number of contiguous subsequences which recursively add up to 9
- Find the Number which contain the digit d
- Given a number, find the next smallest palindrome
- Function to find Number of customers who could not get a computer
- Find Nth smallest number that is divisible by 100 exactly K times
- Find the maximum possible Binary Number from given string
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.