Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coin Gift #133

Open
rosdyana opened this issue Oct 9, 2019 · 0 comments
Open

Coin Gift #133

rosdyana opened this issue Oct 9, 2019 · 0 comments

Comments

@rosdyana
Copy link
Contributor

rosdyana commented Oct 9, 2019

Intro
It's Maria's birthday today and Alfonso has brought a string as a gift. Maria isn't happy with the gift and comes up with a plan to exchage it. First, generate one string of size 3, and ask Alfonso to give as many coins as the number of times the string occurs as sub-sequence in Alfonso's string. Determine the number of coins Maria will get, i.e given two strings mariaString and alfonsoString, the goal is to find the count of the number of times mariaString appears as a sub-sequence in the alfonsoString. A sub-sequence is created by eliminating an number of characters from a string, from 0 to the length of the string, without changing the order of the characters retained.

for example:
mariaString = ABC
alfonsoString = ABCBABC
mariaString appears 5 times as subsqeuence in alfonsoString at 1-indexed positions (1,2,3), (1,2,7), (1,4,7), (1,6,7), and (5,6,7)

another example:
mariaString = ELO
alfonsoString = HELLOWORLD
output = 4
ELO appears as sub-sequence of HELLOWORLD at positions (2,3,5), (2,3,7), (2,4,5) and (2,4,7)

Function Description
The function should return the number of times Maria's string appears as the sub-sequence in Alfonso's string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant